diff --git a/net/web/src/dashboard/Dashboard.jsx b/net/web/src/dashboard/Dashboard.jsx index 524e2a89..d25dc785 100644 --- a/net/web/src/dashboard/Dashboard.jsx +++ b/net/web/src/dashboard/Dashboard.jsx @@ -28,7 +28,7 @@ console.log("IN DASHBOARD here"); <>
} - onClick={() => actions.getAccounts()}> + onClick={() => actions.reload()}>
} @@ -38,7 +38,7 @@ console.log("IN DASHBOARD here"); } onClick={() => actions.logout()}>
- { state.errorMessage && ( + { (state.configError || state.accountsError) && ( @@ -54,7 +54,7 @@ console.log("IN DASHBOARD here");
} - onClick={() => actions.getAccounts()}> + onClick={() => actions.reload()}>
@@ -69,8 +69,15 @@ console.log("IN DASHBOARD here"); onClick={() => actions.logout()}>
- { state.errorMessage && ( - + { state.configError && ( + + + + + + )} + { state.accountsError && ( + diff --git a/net/web/src/dashboard/useDashboard.hook.js b/net/web/src/dashboard/useDashboard.hook.js index f9024f1e..02093663 100644 --- a/net/web/src/dashboard/useDashboard.hook.js +++ b/net/web/src/dashboard/useDashboard.hook.js @@ -18,7 +18,8 @@ export function useDashboard() { enableAudio: null, enableVideo: null, - errorMessage: null, + configError: false, + accountsError: false, createToken: null, showSettings: false, showCreate: false, @@ -91,7 +92,8 @@ export function useDashboard() { logout: () => { app.actions.clearAdmin(); }, - getAccounts: async () => { + reload: async () => { + await syncConfig(); await syncAccounts(); }, setSettings: async () => { @@ -118,13 +120,12 @@ export function useDashboard() { const config = await getNodeConfig(app.state.adminToken); const { storage, domain, keyType, pushSupported, enableImage, enableAudio, enableVideo } = config; const accountStorage = Math.ceil(storage / 1073741824); - updateState({ domain, accountStorage, keyType, enableImage, enableAudio, enableVideo, pushSupported }); + updateState({ configError: false, domain, accountStorage, keyType, enableImage, enableAudio, enableVideo, pushSupported }); } catch(err) { console.log(err); - updateState({ errorMessage: 'failed to sync config' }); + updateState({ configError: true }); } - updateState({ errorMessage: 'failed to sync config' }); }; const syncAccounts = async () => { @@ -139,11 +140,11 @@ export function useDashboard() { } return 0; }); - updateState({ accounts }); + updateState({ accounstError: false, accounts }); } catch(err) { console.log(err); - updateState({ errorMessage: 'failed to sync accounts' }); + updateState({ accountsError: true }); } };