diff options
author | V <vendicated@riseup.net> | 2023-05-02 02:50:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-02 02:50:51 +0200 |
commit | c62d05e1b32361425474928004a92338d98ba200 (patch) | |
tree | 63e2d718807055dbdbbe7d2624270d8aa138fa2d /src/utils/settingsSync.ts | |
parent | 6a1cb133cd6cbe2946e4c830291318e873da1d8b (diff) | |
download | Vencord-c62d05e1b32361425474928004a92338d98ba200.tar.gz Vencord-c62d05e1b32361425474928004a92338d98ba200.tar.bz2 Vencord-c62d05e1b32361425474928004a92338d98ba200.zip |
Refactor ipc to be strongly typed and hide impl details (#1018)
Diffstat (limited to 'src/utils/settingsSync.ts')
-rw-r--r-- | src/utils/settingsSync.ts | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/utils/settingsSync.ts b/src/utils/settingsSync.ts index ff49529..3ec2d43 100644 --- a/src/utils/settingsSync.ts +++ b/src/utils/settingsSync.ts @@ -22,7 +22,6 @@ import { Toasts } from "@webpack/common"; import { deflateSync, inflateSync } from "fflate"; import { getCloudAuth, getCloudUrl } from "./cloud"; -import IpcEvents from "./IpcEvents"; import Logger from "./Logger"; import { saveFile } from "./web"; @@ -36,15 +35,15 @@ export async function importSettings(data: string) { if ("settings" in parsed && "quickCss" in parsed) { Object.assign(PlainSettings, parsed.settings); - await VencordNative.ipc.invoke(IpcEvents.SET_SETTINGS, JSON.stringify(parsed.settings, null, 4)); - await VencordNative.ipc.invoke(IpcEvents.SET_QUICK_CSS, parsed.quickCss); + await VencordNative.settings.set(JSON.stringify(parsed.settings, null, 4)); + await VencordNative.quickCss.set(parsed.quickCss); } else throw new Error("Invalid Settings. Is this even a Vencord Settings file?"); } export async function exportSettings() { - const settings = JSON.parse(VencordNative.ipc.sendSync(IpcEvents.GET_SETTINGS)); - const quickCss = await VencordNative.ipc.invoke(IpcEvents.GET_QUICK_CSS); + const settings = JSON.parse(VencordNative.settings.get()); + const quickCss = await VencordNative.quickCss.get(); return JSON.stringify({ settings, quickCss }, null, 4); } @@ -147,7 +146,7 @@ export async function putCloudSettings() { const { written } = await res.json(); PlainSettings.cloud.settingsSyncVersion = written; - VencordNative.ipc.invoke(IpcEvents.SET_SETTINGS, JSON.stringify(PlainSettings, null, 4)); + VencordNative.settings.set(JSON.stringify(PlainSettings, null, 4)); cloudSettingsLogger.info("Settings uploaded to cloud successfully"); showNotification({ @@ -230,7 +229,7 @@ export async function getCloudSettings(shouldNotify = true, force = false) { // sync with server timestamp instead of local one PlainSettings.cloud.settingsSyncVersion = written; - VencordNative.ipc.invoke(IpcEvents.SET_SETTINGS, JSON.stringify(PlainSettings, null, 4)); + VencordNative.settings.set(JSON.stringify(PlainSettings, null, 4)); cloudSettingsLogger.info("Settings loaded from cloud successfully"); if (shouldNotify) |