Skip to content

Commit

Permalink
fixed dark mode bug
Browse files Browse the repository at this point in the history
  • Loading branch information
István Kreisz authored and István Kreisz committed Jul 18, 2021
1 parent c1db9a9 commit 5d2863b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 6 additions & 6 deletions electron/databaseCoordinator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ const databaseCoordinator = () => {

const getSettings = (): Settings => {
const settings = get('settings');
if (settings['darkModeOn'] === undefined) {
settings['darkModeOn'] = false;
if (settings !== undefined && settings?.darkModeOn === undefined) {
settings.darkModeOn = false;
}
if (is(settings, SettingsSchema)) {
return settings;
Expand Down Expand Up @@ -132,8 +132,8 @@ const databaseCoordinator = () => {
callback: (oldValue?: Settings, newValue?: Settings) => void
) => {
store.onDidChange('settings', (newValue: any, oldValue: any) => {
if (newValue['darkModeOn'] === undefined) {
newValue['darkModeOn'] = false;
if (newValue !== undefined && newValue?.darkModeOn === undefined) {
newValue.darkModeOn = false;
}
if (newValue && is(newValue, SettingsSchema)) {
if (oldValue && is(oldValue, SettingsSchema)) {
Expand All @@ -145,8 +145,8 @@ const databaseCoordinator = () => {
});
const settings = get('settings');
if (settings) {
if (settings['darkModeOn'] === undefined) {
settings['darkModeOn'] = false;
if (settings !== undefined && settings?.darkModeOn === undefined) {
settings.darkModeOn = false;
}
assert(settings, SettingsSchema);
callback(undefined, settings);
Expand Down
2 changes: 0 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ const App = () => {
if (is(settings, SettingsSchema)) {
setCurrency(settings.currency);
const html = document?.getElementsByTagName('html')?.[0];
console.log(html);
console.log(settings.darkModeOn);
if (html) {
if (settings.darkModeOn) {
if (!html.classList.contains('dark')) {
Expand Down

0 comments on commit 5d2863b

Please sign in to comment.