feat: add account updated listener

This commit is contained in:
Zamitto
2025-01-16 00:21:44 -03:00
parent 44fd971c95
commit d866face54
6 changed files with 28 additions and 6 deletions

View File

@@ -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 */

View File

@@ -52,11 +52,18 @@ export function SettingsAccount() {
}, [userDetails, setValue]);
useEffect(() => {
fetchUserDetails().then((response) => {
if (response) {
updateUserDetails(response);
}
const unsubscribe = window.electron.onAccountUpdated(() => {
fetchUserDetails().then((response) => {
if (response) {
updateUserDetails(response);
}
});
showSuccessToast(t("account_data_updated_successfully"));
});
return () => {
unsubscribe();
};
}, [fetchUserDetails, updateUserDetails]);
const visibilityOptions = [