mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 05:24:55 +03:00
feat: add account updated listener
This commit is contained in:
parent
44fd971c95
commit
d866face54
@ -291,7 +291,8 @@
|
|||||||
"update_email": "Update email",
|
"update_email": "Update email",
|
||||||
"update_password": "Update password",
|
"update_password": "Update password",
|
||||||
"current_email": "Current email:",
|
"current_email": "Current email:",
|
||||||
"no_email_account": "You have not set an email yet"
|
"no_email_account": "You have not set an email yet",
|
||||||
|
"account_data_updated_successfully": "Account data updated successfully"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"download_complete": "Download complete",
|
"download_complete": "Download complete",
|
||||||
|
@ -279,7 +279,8 @@
|
|||||||
"update_email": "Atualizar email",
|
"update_email": "Atualizar email",
|
||||||
"update_password": "Atualizar senha",
|
"update_password": "Atualizar senha",
|
||||||
"current_email": "Email atual:",
|
"current_email": "Email atual:",
|
||||||
"no_email_account": "Você ainda não adicionou um email a sua conta"
|
"no_email_account": "Você ainda não adicionou um email a sua conta",
|
||||||
|
"account_data_updated_successfully": "Dados da conta atualizados com sucesso"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"download_complete": "Download concluído",
|
"download_complete": "Download concluído",
|
||||||
|
@ -178,6 +178,13 @@ export class WindowManager {
|
|||||||
authWindow.close();
|
authWindow.close();
|
||||||
|
|
||||||
HydraApi.handleExternalAuth(url);
|
HydraApi.handleExternalAuth(url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url.startsWith("hydralauncher://update-account")) {
|
||||||
|
authWindow.close();
|
||||||
|
|
||||||
|
WindowManager.mainWindow?.webContents.send("on-account-updated");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -299,6 +299,11 @@ contextBridge.exposeInMainWorld("electron", {
|
|||||||
ipcRenderer.on("on-signin", listener);
|
ipcRenderer.on("on-signin", listener);
|
||||||
return () => ipcRenderer.removeListener("on-signin", listener);
|
return () => ipcRenderer.removeListener("on-signin", listener);
|
||||||
},
|
},
|
||||||
|
onAccountUpdated: (cb: () => void) => {
|
||||||
|
const listener = (_event: Electron.IpcRendererEvent) => cb();
|
||||||
|
ipcRenderer.on("on-account-updated", listener);
|
||||||
|
return () => ipcRenderer.removeListener("on-account-updated", listener);
|
||||||
|
},
|
||||||
onSignOut: (cb: () => void) => {
|
onSignOut: (cb: () => void) => {
|
||||||
const listener = (_event: Electron.IpcRendererEvent) => cb();
|
const listener = (_event: Electron.IpcRendererEvent) => cb();
|
||||||
ipcRenderer.on("on-signout", listener);
|
ipcRenderer.on("on-signout", listener);
|
||||||
|
1
src/renderer/src/declaration.d.ts
vendored
1
src/renderer/src/declaration.d.ts
vendored
@ -211,6 +211,7 @@ declare global {
|
|||||||
openAuthWindow: (page: AuthPage) => Promise<void>;
|
openAuthWindow: (page: AuthPage) => Promise<void>;
|
||||||
getSessionHash: () => Promise<string | null>;
|
getSessionHash: () => Promise<string | null>;
|
||||||
onSignIn: (cb: () => void) => () => Electron.IpcRenderer;
|
onSignIn: (cb: () => void) => () => Electron.IpcRenderer;
|
||||||
|
onAccountUpdated: (cb: () => void) => () => Electron.IpcRenderer;
|
||||||
onSignOut: (cb: () => void) => () => Electron.IpcRenderer;
|
onSignOut: (cb: () => void) => () => Electron.IpcRenderer;
|
||||||
|
|
||||||
/* User */
|
/* User */
|
||||||
|
@ -52,11 +52,18 @@ export function SettingsAccount() {
|
|||||||
}, [userDetails, setValue]);
|
}, [userDetails, setValue]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchUserDetails().then((response) => {
|
const unsubscribe = window.electron.onAccountUpdated(() => {
|
||||||
if (response) {
|
fetchUserDetails().then((response) => {
|
||||||
updateUserDetails(response);
|
if (response) {
|
||||||
}
|
updateUserDetails(response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
showSuccessToast(t("account_data_updated_successfully"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsubscribe();
|
||||||
|
};
|
||||||
}, [fetchUserDetails, updateUserDetails]);
|
}, [fetchUserDetails, updateUserDetails]);
|
||||||
|
|
||||||
const visibilityOptions = [
|
const visibilityOptions = [
|
||||||
|
Loading…
Reference in New Issue
Block a user