fix(dashboard): leave the temporary-account state once the account is saved

Saving a temporary account from the user menu promoted the user in place
without a reload, but Home kept its Save session warning (reopening the
save dialog for a saved account) and Account and Security stayed without
their password and email cards until the page was reloaded. The dashboard
now reacts to account-saved, which fires after the user is updated.
This commit is contained in:
Nariman Jelveh committed 2026-10-23 14:19:37 -07:00
1 parent 22cc279075
commit e18860f1e8
2 files changed
+14 -2

No files matched your search

+12
View File
@@ -228,6 +228,18 @@ async function UIDashboard (options) {
}
}
// Saving a temporary account promotes this session's user in place: the
// save prompt goes, and the tabs that leave out cards for a temporary
// user (password, email) render again.
window.addEventListener('account-saved', () => {
$el_window.find('.bento-save-account-warning').remove();
for ( const tab of tabs ) {
if ( tab.id !== 'account' && tab.id !== 'security' ) continue;
$el_window.find(`.dashboard-section-${tab.id}`).html(tab.html());
tab.init?.($el_window);
}
});
// Dispatch 'dashboard-ready' event for extensions
window.dispatchEvent(new CustomEvent('dashboard-ready', { detail: { window: $el_window } }));
+2 -2
View File
@@ -156,11 +156,11 @@ async function UIWindowSaveAccount (options) {
'Authorization': `Bearer ${window.auth_token}`,
},
success: async function (data) {
window.dispatchEvent(new CustomEvent('account-saved', { detail: { data: data } }));
// /save_account promotes the current session's user in place
// and does not rotate the token, so keep the one we have.
await window.update_auth_data(data.token ?? window.auth_token, data.user);
// After the update, so listeners read the saved user.
window.dispatchEvent(new CustomEvent('account-saved', { detail: { data: data } }));
//close this window
if ( data.user.requires_email_confirmation && !data.user.email_confirmed ) {