diff options
author | V <vendicated@riseup.net> | 2023-04-04 01:16:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-04 01:16:29 +0200 |
commit | 6b26c12bfa1f28d40834478b50d2f7b09c9f54fb (patch) | |
tree | 48687349f9bf6803ee8993b3eafa3ea1e4f3dff2 /src/utils/settingsSync.ts | |
parent | 5bb08bdb6465eebc9dcf80ba2971d894b804abb8 (diff) | |
download | Vencord-6b26c12bfa1f28d40834478b50d2f7b09c9f54fb.tar.gz Vencord-6b26c12bfa1f28d40834478b50d2f7b09c9f54fb.tar.bz2 Vencord-6b26c12bfa1f28d40834478b50d2f7b09c9f54fb.zip |
Add additional build flavours for Vencord Desktop (#765)
Diffstat (limited to 'src/utils/settingsSync.ts')
-rw-r--r-- | src/utils/settingsSync.ts | 42 |
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); - } - } } } |