Move store-related code from menu.js to store.js

This commit is contained in:
Agampreet Singh
2024-07-21 16:53:30 +05:30
parent e2abaca1e8
commit 55d3e94cf9
2 changed files with 21 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
import { app, dialog, BrowserWindow, ShareMenu, clipboard } from "electron";
import { getValue, setValue, getValueOrDefault } from './store.js';
import { getValue, setValue } from './store.js';
import { ElectronBlocker } from "@cliqz/adblocker-electron";
import { clearActivity, setActivity } from './rpc.js';
import { fileURLToPath } from 'url';
@@ -99,25 +99,6 @@ function setUserAgent(useragent) {
}
}
getValueOrDefault("enterprise-or-normal", "?auth=1");
getValueOrDefault("websites-in-new-window", "true");
getValueOrDefault("autohide-menubar", "false");
getValueOrDefault("useragentstring", useragents.Windows);
getValueOrDefault("discordrpcstatus", "false");
getValueOrDefault("blockadsandtrackers", "false");
getValueOrDefault("dynamicicons", "true");
getValueOrDefault("autoupdater", "true");
getValueOrDefault("custompage", "home");
// temporary code to change the value of enterprise-or-normal to the new values for the update, will be removed in the next update.
if (getValue("enterprise-or-normal") === "https://microsoft365.com/?auth=1") {
setValue("enterprise-or-normal", "?auth=1");
} else if (
getValue("enterprise-or-normal") === "https://microsoft365.com/?auth=2"
) {
setValue("enterprise-or-normal", "?auth=2");
}
const commonPreferencesSubmenu = [
{
label: "Open MS 365 with Personal Account",

View File

@@ -1,4 +1,6 @@
import useragents from "./useragents.json" with { type: "json" }
import Store from "electron-store";
const store = new Store();
export function getValue(key) {
@@ -17,3 +19,21 @@ export function getValueOrDefault(key, defaultValue) {
}
return value;
}
getValueOrDefault("enterprise-or-normal", "?auth=1");
getValueOrDefault("websites-in-new-window", "true");
getValueOrDefault("autohide-menubar", "false");
getValueOrDefault("useragentstring", useragents.Windows);
getValueOrDefault("discordrpcstatus", "false");
getValueOrDefault("blockadsandtrackers", "false");
getValueOrDefault("dynamicicons", "true");
getValueOrDefault("autoupdater", "true");
getValueOrDefault("custompage", "home");
if (getValue("enterprise-or-normal") === "https://microsoft365.com/?auth=1") {
setValue("enterprise-or-normal", "?auth=1");
} else if (
getValue("enterprise-or-normal") === "https://microsoft365.com/?auth=2"
) {
setValue("enterprise-or-normal", "?auth=2");
}