aboutsummaryrefslogtreecommitdiff
path: root/src/utils/settingsSync.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/settingsSync.ts')
-rw-r--r--src/utils/settingsSync.ts42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/utils/settingsSync.ts b/src/utils/settingsSync.ts
index 18e1854..781899f 100644
--- a/src/utils/settingsSync.ts
+++ b/src/utils/settingsSync.ts
@@ -47,7 +47,9 @@ export async function downloadSettingsBackup() {
const backup = await exportSettings();
const data = new TextEncoder().encode(backup);
- if (IS_WEB) {
+ if (IS_DISCORD_DESKTOP) {
+ DiscordNative.fileManager.saveWithDialog(data, filename);
+ } else {
const file = new File([data], filename, { type: "application/json" });
const a = document.createElement("a");
a.href = URL.createObjectURL(file);
@@ -59,8 +61,6 @@ export async function downloadSettingsBackup() {
URL.revokeObjectURL(a.href);
document.body.removeChild(a);
});
- } else {
- DiscordNative.fileManager.saveWithDialog(data, filename);
}
}
@@ -77,7 +77,24 @@ const toastFailure = (err: any) => Toasts.show({
});
export async function uploadSettingsBackup(showToast = true): Promise<void> {
- if (IS_WEB) {
+ if (IS_DISCORD_DESKTOP) {
+ const [file] = await DiscordNative.fileManager.openFiles({
+ filters: [
+ { name: "Vencord Settings Backup", extensions: ["json"] },
+ { name: "all", extensions: ["*"] }
+ ]
+ });
+
+ if (file) {
+ try {
+ await importSettings(new TextDecoder().decode(file.data));
+ if (showToast) toastSuccess();
+ } catch (err) {
+ new Logger("SettingsSync").error(err);
+ if (showToast) toastFailure(err);
+ }
+ }
+ } else {
const input = document.createElement("input");
input.type = "file";
input.style.display = "none";
@@ -102,22 +119,5 @@ export async function uploadSettingsBackup(showToast = true): Promise<void> {
document.body.appendChild(input);
input.click();
setImmediate(() => document.body.removeChild(input));
- } else {
- const [file] = await DiscordNative.fileManager.openFiles({
- filters: [
- { name: "Vencord Settings Backup", extensions: ["json"] },
- { name: "all", extensions: ["*"] }
- ]
- });
-
- if (file) {
- try {
- await importSettings(new TextDecoder().decode(file.data));
- if (showToast) toastSuccess();
- } catch (err) {
- new Logger("SettingsSync").error(err);
- if (showToast) toastFailure(err);
- }
- }
}
}