Skip to content

Commit

Permalink
Added storing data persistent function and request theme change on DO…
Browse files Browse the repository at this point in the history
…MContentLoaded
  • Loading branch information
reacto11mecha committed Jan 16, 2021
1 parent 04965e0 commit 7566841
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 13 additions & 4 deletions js/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const path = require("path");
const appInfo = require("../package.json");
const { isDevelopment } = require("./config");
const product_name = "Google Classroom Desktop";
const store = require("./store");

const about = () =>
void openAboutWindow({
Expand Down Expand Up @@ -90,14 +91,20 @@ const template = (win) => {
{
label: "Light",
id: "theme-light",
enabled: false,
click: () => theme("light"),
enabled: store.get("theme") === "dark",
click: () => {
theme("light");
store.set("theme", "light");
},
},
{
label: "Dark",
id: "theme-dark",
enabled: true,
click: () => theme("dark"),
enabled: store.get("theme") === "light",
click: () => {
theme("dark");
store.set("theme", "dark");
},
},
],
},
Expand Down Expand Up @@ -129,6 +136,8 @@ const template = (win) => {
}
});

ipcMain.on("theme:request", () => theme(store.get("theme")));

return menu;
};

Expand Down
4 changes: 4 additions & 0 deletions js/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ ipcRenderer.on("theme:light", () => {
DisableDarkMode();
ipcRenderer.send("theme:update", { enabled: false });
});

document.addEventListener("DOMContentLoaded", () =>
ipcRenderer.send("theme:request")
);

0 comments on commit 7566841

Please sign in to comment.