This repository has been archived by the owner on Aug 18, 2024. It is now read-only.
generated from uwu/shelter-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd0cfef
commit 419cf42
Showing
2 changed files
with
53 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,59 @@ | ||
import { LegacyPage } from "./pages/LegacyPage"; | ||
import { SettingsPage } from "./pages/SettingsPage"; | ||
import { ThemesPage } from "./pages/ThemesPage"; | ||
import { UpdaterPage } from "./pages/UpdaterPage"; | ||
import { refreshSettings } from "./settings"; | ||
import {LegacyPage} from "./pages/LegacyPage"; | ||
import {SettingsPage} from "./pages/SettingsPage"; | ||
import {ThemesPage} from "./pages/ThemesPage"; | ||
import {UpdaterPage} from "./pages/UpdaterPage"; | ||
import {refreshSettings, isRestartRequired} from "./settings"; | ||
const { | ||
plugin: {store}, | ||
settings: {registerSection}, | ||
util: { log }, | ||
ui: {openConfirmationModal}, | ||
flux: {dispatcher} | ||
plugin: {store}, | ||
settings: {registerSection}, | ||
util: {log}, | ||
ui: {openConfirmationModal}, | ||
flux: {dispatcher} | ||
} = shelter; | ||
|
||
let settingsPages = [ | ||
registerSection('divider'), | ||
registerSection('header', "ArmCord"), | ||
registerSection('section', "armcord-legacy", "Legacy", LegacyPage), | ||
registerSection('section', "armcord-settings", "Settings", SettingsPage), | ||
registerSection('section', "armcord-themes", "Themes", ThemesPage), | ||
registerSection('section', "armcord-updater", "Updater", UpdaterPage), | ||
] | ||
registerSection("divider"), | ||
registerSection("header", "ArmCord"), | ||
registerSection("section", "armcord-legacy", "Legacy", LegacyPage), | ||
registerSection("section", "armcord-settings", "Settings", SettingsPage), | ||
registerSection("section", "armcord-themes", "Themes", ThemesPage), | ||
registerSection("section", "armcord-updater", "Updater", UpdaterPage) | ||
]; | ||
|
||
function restartRequired(payload) { | ||
if (payload.event === "settings_pane_viewed" && typeof payload.properties.origin_pane != "undefined") { | ||
if (payload.properties.origin_pane == "armcord-settings") { | ||
openConfirmationModal({ | ||
header: () => "Restart required", | ||
body: () => "You need to restart to apply these changes.", | ||
type: "danger", | ||
confirmText: "Restart", | ||
cancelText: "I'll do it later" | ||
}).then( | ||
() => armcord.restart(), | ||
() => console.log("restart skipped") | ||
); | ||
if (payload.event === "settings_pane_viewed" && typeof payload.properties.origin_pane != "undefined") { | ||
if (payload.properties.origin_pane == "armcord-settings") { | ||
if (isRestartRequired) { | ||
openConfirmationModal({ | ||
header: () => "Restart required", | ||
body: () => "You need to restart to apply these changes.", | ||
type: "danger", | ||
confirmText: "Restart", | ||
cancelText: "I'll do it later" | ||
}).then( | ||
() => armcord.restart(), | ||
() => console.log("restart skipped") | ||
); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
export function onLoad() { | ||
refreshSettings() | ||
store.i18n = window.armcord.translations | ||
// make this better | ||
if (window.armcord.settings.config.mods == "vencord") { | ||
store.vencord = true; | ||
} else { | ||
store.vencord = false; | ||
} | ||
log("ArmCord Settings") | ||
settingsPages | ||
dispatcher.subscribe("TRACK", restartRequired) | ||
refreshSettings(); | ||
// used for restart required dialog later | ||
store.i18n = window.armcord.translations; | ||
// make this better | ||
if (window.armcord.settings.config.mods == "vencord") { | ||
store.vencord = true; | ||
} else { | ||
store.vencord = false; | ||
} | ||
log("ArmCord Settings"); | ||
settingsPages; | ||
dispatcher.subscribe("TRACK", restartRequired); | ||
} | ||
export function onUnload() { | ||
settingsPages.forEach((e) => e()) | ||
dispatcher.unsubscribe("TRACK", restartRequired) | ||
settingsPages.forEach((e) => e()); | ||
dispatcher.unsubscribe("TRACK", restartRequired); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
const {plugin: { store }} = shelter | ||
export let isRestartRequired = false; | ||
export function refreshSettings() { | ||
store.settings = window.armcord.settings.config | ||
console.log(store.settings) | ||
} | ||
export function set(key, value) { | ||
isRestartRequired = true; | ||
if (key == "vencord" && value == true) { | ||
store.vencord = true; | ||
armcord.settings.setConfig("mods", "vencord") | ||
} else { | ||
} else if (key == "vencord" && value == false) { | ||
store.vencord = false; | ||
armcord.settings.setConfig("mods", "none") | ||
} else { | ||
store.settings[key] = value; | ||
console.log(key + ": " + store.settings[key]) | ||
armcord.settings.setConfig(key, value) | ||
} | ||
store.settings[key] = value; | ||
console.log(key + ": " + store.settings[key]) | ||
armcord.settings.setConfig(key, value) | ||
} |