Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions dev/src/views/Theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ export default class Theme extends EventDispatcher {
this.targetNode = this._node = null;
this._dark = false;
this._initUI();
this.dark = !!app.prefs.read("dark");

if (app.prefs.read("dark") !== undefined) {
this.dark = app.prefs.read("dark");
} else {
// Use the browser preference if no setting was previously saved
this.dark = window.matchMedia("(prefers-color-scheme: dark)").matches;
}
}

set dark(val) {
Expand All @@ -40,7 +46,7 @@ export default class Theme extends EventDispatcher {
$.toggleClass(this.themeBtn, "selected", val);
app.prefs.write("dark", val);
}

get dark() {
return this._dark;
}
Expand Down Expand Up @@ -71,4 +77,4 @@ export default class Theme extends EventDispatcher {
this.dark = !this.dark;
}

}
}