Skip to content

Commit

Permalink
fix: show alert when importing a zip file as a backup (#720)
Browse files Browse the repository at this point in the history
* fix: show alert when importing a zip file as a backup

* Update app/assets/javascripts/strings.ts

Co-authored-by: Mo <mo@standardnotes.org>

Co-authored-by: Johnny Almonte <johnny243@users.noreply.github.com>
Co-authored-by: Mo <mo@standardnotes.org>
  • Loading branch information
3 people authored Nov 5, 2021
1 parent 2fdb748 commit 261bb65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -36,6 +37,11 @@ export const DataBackups = observer(({
};

const readFile = async (file: File): Promise<any> => {
if (file.type === 'application/zip') {
application.alertService.alert(STRING_IMPORTING_ZIP_FILE);
return;
}

return new Promise((resolve) => {
const reader = new FileReader();
reader.onload = (e) => {
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`;
}
Expand Down

0 comments on commit 261bb65

Please sign in to comment.