diff --git a/src/app/actions/searchActions.ts b/src/app/actions/searchActions.ts index fe22034..89ec589 100644 --- a/src/app/actions/searchActions.ts +++ b/src/app/actions/searchActions.ts @@ -17,14 +17,23 @@ export async function searchUserFiles(fileId: string) { if (parsed.message_code === 0) { return parsed.message_body; } else { - throw parsed; + throw parsed.message_desc; } } else { throw (`${response.status}`); } } catch (error) { - return error + + if (error === 'File for search unsupported') { + return { + errorMessage: 'file-for-search-unsupported' + } + } else { + return { + errorMessage: 'error' + } + } } } diff --git a/src/app/ui/search/file-search-panel.tsx b/src/app/ui/search/file-search-panel.tsx index b015d4e..5ebea19 100644 --- a/src/app/ui/search/file-search-panel.tsx +++ b/src/app/ui/search/file-search-panel.tsx @@ -70,7 +70,11 @@ export function FileSearchPanel( try { let result = await searchUserFiles(fileId); - if (result.content.length) { + if (result.errorMessage) { + throw result.errorMessage + } + + if (result?.content?.length) { setSearchedUserFiles(result.content); if (fileType === 'image') { setShowGlobalSearch(true); @@ -80,7 +84,12 @@ export function FileSearchPanel( setSearchedUserFilesShowNull(true); } } catch (error) { - setErrorMessage('error'); + + if (error === 'file-for-search-unsupported') { + setErrorMessage(error); + } else { + setErrorMessage('search-error'); + } } }, [fileId]) @@ -138,7 +147,7 @@ export function FileSearchPanel( {errorMessage && (
- {t('search-error')} + {t(errorMessage)}
)} diff --git a/src/i18n/messages/en.json b/src/i18n/messages/en.json index a21f010..ee6d121 100644 --- a/src/i18n/messages/en.json +++ b/src/i18n/messages/en.json @@ -286,7 +286,8 @@ "DIFFERENT": "DIFFERENT", "file-information": "File information", "id-in-the-system": "ID in the system", - "protection-status": "Protection status" + "protection-status": "Protection status", + "file-for-search-unsupported": "File for search unsupported" }, "Login-register-form": { "and": "and", diff --git a/src/i18n/messages/ru.json b/src/i18n/messages/ru.json index 74bd73d..e414c68 100644 --- a/src/i18n/messages/ru.json +++ b/src/i18n/messages/ru.json @@ -286,7 +286,8 @@ "DIFFERENT": "ДРУГОЙ", "file-information": "Информация о файле", "id-in-the-system": "ID в системе", - "protection-status": "Статус защиты" + "protection-status": "Статус защиты", + "file-for-search-unsupported": "Файл для поиска не поддерживается" }, "Login-register-form": { "and": "и",