diff options
Diffstat (limited to 'src/Vencord.ts')
-rw-r--r-- | src/Vencord.ts | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/Vencord.ts b/src/Vencord.ts index 73b53e8..a23b1a8 100644 --- a/src/Vencord.ts +++ b/src/Vencord.ts @@ -30,17 +30,44 @@ import "./webpack/patchWebpack"; import { showNotification } from "./api/Notifications"; import { PlainSettings, Settings } from "./api/settings"; import { patches, PMLogger, startAllPlugins } from "./plugins"; -import { checkForUpdates, rebuild, update,UpdateLogger } from "./utils/updater"; +import { localStorage } from "./utils/localStorage"; +import { getCloudSettings, putCloudSettings } from "./utils/settingsSync"; +import { checkForUpdates, rebuild, update, UpdateLogger } from "./utils/updater"; import { onceReady } from "./webpack"; import { SettingsRouter } from "./webpack/common"; export let Components: any; +async function syncSettings() { + if ( + Settings.cloud.settingsSync && // if it's enabled + Settings.cloud.authenticated // if cloud integrations are enabled + ) { + if (localStorage.Vencord_settingsDirty) { + await putCloudSettings(); + delete localStorage.Vencord_settingsDirty; + } else if (await getCloudSettings(false)) { // if we synchronized something (false means no sync) + // we show a notification here instead of allowing getCloudSettings() to show one to declutter the amount of + // potential notifications that might occur. getCloudSettings() will always send a notification regardless if + // there was an error to notify the user, but besides that we only want to show one notification instead of all + // of the possible ones it has (such as when your settings are newer). + showNotification({ + title: "Cloud Settings", + body: "Your settings have been updated! Click here to restart to fully apply changes!", + color: "var(--green-360)", + onClick: () => window.DiscordNative.app.relaunch() + }); + } + } +} + async function init() { await onceReady; startAllPlugins(); Components = await import("./components"); + syncSettings(); + if (!IS_WEB) { try { const isOutdated = await checkForUpdates(); |