From 584cd3d2e60d93ea0d2279ecfcc88e3e8194bc2f Mon Sep 17 00:00:00 2001 From: mochie Date: Tue, 11 Feb 2025 12:58:05 +0100 Subject: [PATCH] dataStore in local backup (#146) * add preferFriends to showMeYourName * add dataStores to local backup * Add dataStores to export contains in settings --- src/components/VencordSettings/BackupAndRestoreTab.tsx | 1 + src/utils/settingsSync.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/VencordSettings/BackupAndRestoreTab.tsx b/src/components/VencordSettings/BackupAndRestoreTab.tsx index 9c12fbf0..7e0f32e3 100644 --- a/src/components/VencordSettings/BackupAndRestoreTab.tsx +++ b/src/components/VencordSettings/BackupAndRestoreTab.tsx @@ -44,6 +44,7 @@ function BackupRestoreTab() {
  • — Custom QuickCSS
  • — Theme Links
  • — Plugin Settings
  • +
  • — Plugin DataStores (e.g. Timezones or IRememberYou)
  • diff --git a/src/utils/settingsSync.ts b/src/utils/settingsSync.ts index fc5c4172..a31aa621 100644 --- a/src/utils/settingsSync.ts +++ b/src/utils/settingsSync.ts @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import { DataStore } from "@api/index"; import { showNotification } from "@api/Notifications"; import { PlainSettings, Settings } from "@api/Settings"; import { moment, Toasts } from "@webpack/common"; @@ -34,18 +35,20 @@ export async function importSettings(data: string) { throw new Error("Failed to parse JSON: " + String(err)); } - if ("settings" in parsed && "quickCss" in parsed) { + if ("settings" in parsed && "quickCss" in parsed && "dataStore" in parsed) { Object.assign(PlainSettings, parsed.settings); await VencordNative.settings.set(parsed.settings); await VencordNative.quickCss.set(parsed.quickCss); + await DataStore.setMany(parsed.dataStore); } else - throw new Error("Invalid Settings. Is this even a Equicord Settings file?"); + throw new Error("Invalid Settings. Is this even an Equicord Settings file?"); } export async function exportSettings({ minify }: { minify?: boolean; } = {}) { const settings = VencordNative.settings.get(); const quickCss = await VencordNative.quickCss.get(); - return JSON.stringify({ settings, quickCss }, null, minify ? undefined : 4); + const dataStore = await DataStore.entries(); + return JSON.stringify({ settings, quickCss, dataStore }, null, minify ? undefined : 4); } export async function downloadSettingsBackup() {