Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
fix settings
Browse files Browse the repository at this point in the history
  • Loading branch information
smartfrigde committed Jul 21, 2024
1 parent bd0cfef commit 419cf42
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 47 deletions.
89 changes: 46 additions & 43 deletions plugins/armcordSettings/index.js
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);
}
11 changes: 7 additions & 4 deletions plugins/armcordSettings/settings.js
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)
}

0 comments on commit 419cf42

Please sign in to comment.