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_password": "Update password",
|
||||
"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": {
|
||||
"download_complete": "Download complete",
|
||||
|
@ -279,7 +279,8 @@
|
||||
"update_email": "Atualizar email",
|
||||
"update_password": "Atualizar senha",
|
||||
"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": {
|
||||
"download_complete": "Download concluído",
|
||||
|
@ -178,6 +178,13 @@ export class WindowManager {
|
||||
authWindow.close();
|
||||
|
||||
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);
|
||||
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) => {
|
||||
const listener = (_event: Electron.IpcRendererEvent) => cb();
|
||||
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>;
|
||||
getSessionHash: () => Promise<string | null>;
|
||||
onSignIn: (cb: () => void) => () => Electron.IpcRenderer;
|
||||
onAccountUpdated: (cb: () => void) => () => Electron.IpcRenderer;
|
||||
onSignOut: (cb: () => void) => () => Electron.IpcRenderer;
|
||||
|
||||
/* User */
|
||||
|
@ -52,11 +52,18 @@ export function SettingsAccount() {
|
||||
}, [userDetails, setValue]);
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = window.electron.onAccountUpdated(() => {
|
||||
fetchUserDetails().then((response) => {
|
||||
if (response) {
|
||||
updateUserDetails(response);
|
||||
}
|
||||
});
|
||||
showSuccessToast(t("account_data_updated_successfully"));
|
||||
});
|
||||
|
||||
return () => {
|
||||
unsubscribe();
|
||||
};
|
||||
}, [fetchUserDetails, updateUserDetails]);
|
||||
|
||||
const visibilityOptions = [
|
||||
|
Loading…
Reference in New Issue
Block a user