From 55d3e94cf904d09adc2a84ebc645c2008757d7c8 Mon Sep 17 00:00:00 2001 From: Agampreet Singh <68941022+agam778@users.noreply.github.com> Date: Sun, 21 Jul 2024 16:53:30 +0530 Subject: [PATCH] Move store-related code from menu.js to store.js --- app/menu.js | 21 +-------------------- app/store.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/app/menu.js b/app/menu.js index 41a611c..7b62c96 100644 --- a/app/menu.js +++ b/app/menu.js @@ -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", diff --git a/app/store.js b/app/store.js index a9704ec..a49e584 100644 --- a/app/store.js +++ b/app/store.js @@ -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"); +}