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,9 +465,13 @@ 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) {
await performImport(data);
return;
}
if ( if (
application.protocolService.supportedVersions().includes(version) application.protocolService.supportedVersions().includes(version)
) { ) {
@@ -478,9 +480,6 @@ const AccountMenu = observer(({ application, appState, closeAccountMenu }: Props
setIsImportDataLoading(false); setIsImportDataLoading(false);
void alertDialog({ text: STRING_UNSUPPORTED_BACKUP_FILE_VERSION }); void alertDialog({ text: STRING_UNSUPPORTED_BACKUP_FILE_VERSION });
} }
} else {
await performImport(data);
}
}; };
const toggleErrorReportingEnabled = () => { const toggleErrorReportingEnabled = () => {