diff --git a/scripts/apps/users/directives/UserPreferencesDirective.ts b/scripts/apps/users/directives/UserPreferencesDirective.ts index f1a1204c7e..69d097db25 100644 --- a/scripts/apps/users/directives/UserPreferencesDirective.ts +++ b/scripts/apps/users/directives/UserPreferencesDirective.ts @@ -48,7 +48,7 @@ export function UserPreferencesDirective( const NOTIFICATIONS_KEY = 'notifications'; scope.activeNavigation = null; - scope.activeTheme = localStorage.getItem('theme'); + scope.activeTheme = ''; const registeredNotifications: IExtensionActivationResult['contributions']['notifications'] = (() => { const result = {}; @@ -81,6 +81,14 @@ export function UserPreferencesDirective( scope.$applyAsync(); }; + scope.toggleUiTheme = function(theme) { + scope.activeTheme = theme; + if (orig['application:theme'] == null) { + orig['application:theme'] = {}; + } + orig['application:theme']['theme'] = theme; + }; + scope.toggleEmailNotification = function(notificationId: string) { scope.preferences[NOTIFICATIONS_KEY][notificationId].email = !scope.preferences[NOTIFICATIONS_KEY][notificationId].email; @@ -149,7 +157,6 @@ export function UserPreferencesDirective( preferencesService.desktopNotification.requestPermission(); } - localStorage.setItem('theme', scope.activeTheme); body.attr('data-theme', scope.activeTheme); notify.success(gettext('User preferences saved')); scope.cancel(); @@ -281,6 +288,7 @@ export function UserPreferencesDirective( } }); + scope.activeTheme = data['application:theme']?.['theme'] ?? 'light-ui'; // metadata service initialization is needed if its // values object is undefined or any of the needed // data buckets are missing in it diff --git a/scripts/apps/users/views/user-preferences.html b/scripts/apps/users/views/user-preferences.html index 6ec1f938e0..78eea376d8 100644 --- a/scripts/apps/users/views/user-preferences.html +++ b/scripts/apps/users/views/user-preferences.html @@ -308,7 +308,7 @@