From 261bb65a85769c93ff95d613683c447549500dc2 Mon Sep 17 00:00:00 2001 From: Johnny A <5891646+johnny243@users.noreply.github.com> Date: Fri, 5 Nov 2021 11:31:23 -0400 Subject: [PATCH] fix: show alert when importing a zip file as a backup (#720) * fix: show alert when importing a zip file as a backup * Update app/assets/javascripts/strings.ts Co-authored-by: Mo Co-authored-by: Johnny Almonte Co-authored-by: Mo --- .../preferences/panes/security-segments/DataBackups.tsx | 6 ++++++ app/assets/javascripts/strings.ts | 2 ++ 2 files changed, 8 insertions(+) diff --git a/app/assets/javascripts/preferences/panes/security-segments/DataBackups.tsx b/app/assets/javascripts/preferences/panes/security-segments/DataBackups.tsx index 13637dab5..9dec8bcbc 100644 --- a/app/assets/javascripts/preferences/panes/security-segments/DataBackups.tsx +++ b/app/assets/javascripts/preferences/panes/security-segments/DataBackups.tsx @@ -3,6 +3,7 @@ import { alertDialog } from '@Services/alertService'; import { STRING_IMPORT_SUCCESS, STRING_INVALID_IMPORT_FILE, + STRING_IMPORTING_ZIP_FILE, STRING_UNSUPPORTED_BACKUP_FILE_VERSION, StringImportError } from '@/strings'; @@ -36,6 +37,11 @@ export const DataBackups = observer(({ }; const readFile = async (file: File): Promise => { + if (file.type === 'application/zip') { + application.alertService.alert(STRING_IMPORTING_ZIP_FILE); + return; + } + return new Promise((resolve) => { const reader = new FileReader(); reader.onload = (e) => { diff --git a/app/assets/javascripts/strings.ts b/app/assets/javascripts/strings.ts index 15d69e72c..1f6f647d8 100644 --- a/app/assets/javascripts/strings.ts +++ b/app/assets/javascripts/strings.ts @@ -80,6 +80,8 @@ export const STRING_GENERATING_LOGIN_KEYS = 'Generating Login Keys...'; export const STRING_GENERATING_REGISTER_KEYS = 'Generating Account Keys...'; export const STRING_INVALID_IMPORT_FILE = 'Unable to open file. Ensure it is a proper JSON file and try again.'; +export const STRING_IMPORTING_ZIP_FILE = + 'The file you selected is not a valid backup file. Please extract the contents of the zip file, then upload the contained .txt file.'; export function StringImportError(errorCount: number) { return `Import complete. ${errorCount} items were not imported because there was an error decrypting them. Make sure the password is correct and try again.`; }