refactor: reviewer's comment

This commit is contained in:
VardanHakobyan
2021-06-04 16:52:58 +04:00
parent 3ef77fe14b
commit 5349ec8550

View File

@@ -441,19 +441,17 @@ const AccountMenu = observer(({ application, appState, closeAccountMenu }: Props
if (!result) { if (!result) {
return; return;
} else if ('error' in result) {
void alertDialog({
text: result.error,
});
} else if (result.errorCount) {
void alertDialog({
text: StringImportError(result.errorCount),
});
} else {
void alertDialog({
text: STRING_IMPORT_SUCCESS,
});
} }
let statusText = STRING_IMPORT_SUCCESS;
if ('error' in result) {
statusText = result.error;
} else if (result.errorCount) {
statusText = StringImportError(result.errorCount);
}
void alertDialog({
text: statusText
});
}; };
const importFileSelected = async (event: TargetedEvent<HTMLInputElement, Event>) => { const importFileSelected = async (event: TargetedEvent<HTMLInputElement, Event>) => {
@@ -467,19 +465,20 @@ const AccountMenu = observer(({ application, appState, closeAccountMenu }: Props
if (!data) { if (!data) {
return; return;
} }
if (data.version || data.auth_params || data.keyParams) {
const version = const version = data.version || data.keyParams?.version || data.auth_params?.version;
data.version || data.keyParams?.version || data.auth_params?.version; if (!version) {
if (
application.protocolService.supportedVersions().includes(version)
) {
await performImport(data);
} else {
setIsImportDataLoading(false);
void alertDialog({ text: STRING_UNSUPPORTED_BACKUP_FILE_VERSION });
}
} else {
await performImport(data); await performImport(data);
return;
}
if (
application.protocolService.supportedVersions().includes(version)
) {
await performImport(data);
} else {
setIsImportDataLoading(false);
void alertDialog({ text: STRING_UNSUPPORTED_BACKUP_FILE_VERSION });
} }
}; };