Theme: Theme toggle is only persisted for signed in users (#33163)

This commit is contained in:
Hugo Häggmark 2021-04-20 15:15:56 +02:00 committed by GitHub
parent 888667abbc
commit 527b7bd756
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ import { ThemeChangedEvent } from 'app/types/events';
import appEvents from '../app_events';
import { config } from '../config';
import { PreferencesService } from './PreferencesService';
import { contextSrv } from '../core';
export async function toggleTheme(runtimeOnly: boolean) {
const currentTheme = config.theme;
@ -32,6 +33,10 @@ export async function toggleTheme(runtimeOnly: boolean) {
}
}
if (!contextSrv.isSignedIn) {
return;
}
// Persist new theme
const service = new PreferencesService('user');
const currentPref = await service.load();