Saving theme in local storage

This commit is contained in:
Piotr Pekala 2019-11-28 05:25:07 -08:00
parent 6870f707bf
commit f9af6e32be
3 changed files with 9 additions and 2 deletions

View File

@ -28,6 +28,11 @@ export class AppComponent implements OnInit {
this.electronService.ipcRenderer.send('settings.changed', settings);
});
}
this.themeService.setDarkMode(true);
let theme = localStorage.getItem('theme');
if (theme === 'light') {
this.themeService.setDarkMode(false);
} else {
this.themeService.setDarkMode(true);
}
}
}

View File

@ -32,6 +32,5 @@ export class SettingsComponent implements OnInit {
setDarkMode(value: boolean) {
this.themeService.setDarkMode(value);
//this value should be saved and stored in local memory
}
}

View File

@ -41,12 +41,15 @@ export class ThemeService {
setDarkMode(value: boolean) {
this._darkMode$.next(value);
localStorage.removeItem('theme');
if (value) {
this.savedTheme = 'dark';
this.themeChanged.emit(this.savedTheme);
localStorage.setItem('theme', 'dark');
} else {
this.savedTheme = 'light';
this.themeChanged.emit(this.savedTheme);
localStorage.setItem('theme', 'light');
}
}