diff --git a/apps/photos/public/locales/de/translation.json b/apps/photos/public/locales/de/translation.json index dab07989a..d9928fbf4 100644 --- a/apps/photos/public/locales/de/translation.json +++ b/apps/photos/public/locales/de/translation.json @@ -209,7 +209,8 @@ "DATE": "Datum", "FILE_NAME": "Dateiname", "THING": "Inhalt", - "FILE_CAPTION": "Beschreibung" + "FILE_CAPTION": "Beschreibung", + "FILE_TYPE": "" }, "photos_count_zero": "Keine Erinnerungen", "photos_count_one": "", @@ -583,5 +584,12 @@ "DOWNLOAD_COMPLETE": "", "DOWNLOADING_COLLECTION": "", "DOWNLOAD_FAILED": "", - "DOWNLOAD_PROGRESS": "" + "DOWNLOAD_PROGRESS": "", + "CHRISTMAS": "", + "CHRISTMAS_EVE": "", + "NEW_YEAR": "", + "NEW_YEAR_EVE": "", + "IMAGE": "", + "VIDEO": "", + "LIVE_PHOTO": "" } diff --git a/apps/photos/public/locales/en/translation.json b/apps/photos/public/locales/en/translation.json index 591c9ae5f..4be9ae890 100644 --- a/apps/photos/public/locales/en/translation.json +++ b/apps/photos/public/locales/en/translation.json @@ -209,7 +209,8 @@ "DATE": "Date", "FILE_NAME": "File name", "THING": "Content", - "FILE_CAPTION": "Description" + "FILE_CAPTION": "Description", + "FILE_TYPE": "File type" }, "photos_count_zero": "No memories", "photos_count_one": "1 memory", @@ -584,5 +585,12 @@ "DOWNLOADING_COLLECTION": "Downloading {{name}}", "DOWNLOAD_FAILED": "Download failed", "DOWNLOAD_PROGRESS": "{{progress.current}} / {{progress.total}} files", - "CRASH_REPORTING": "Crash reporting" + "CRASH_REPORTING": "Crash reporting", + "CHRISTMAS": "Christmas", + "CHRISTMAS_EVE": "Christmas Eve", + "NEW_YEAR": "New Year", + "NEW_YEAR_EVE": "New Year's Eve", + "IMAGE": "Image", + "VIDEO": "Video", + "LIVE_PHOTO": "Live Photo" } diff --git a/apps/photos/public/locales/es/translation.json b/apps/photos/public/locales/es/translation.json index b7dfd8d6b..f0b7245cd 100644 --- a/apps/photos/public/locales/es/translation.json +++ b/apps/photos/public/locales/es/translation.json @@ -209,7 +209,8 @@ "DATE": "Fecha", "FILE_NAME": "Nombre del archivo", "THING": "Contenido", - "FILE_CAPTION": "Descripción" + "FILE_CAPTION": "Descripción", + "FILE_TYPE": "" }, "photos_count_zero": "No hay recuerdos", "photos_count_one": "1 recuerdo", @@ -583,5 +584,12 @@ "DOWNLOAD_COMPLETE": "", "DOWNLOADING_COLLECTION": "", "DOWNLOAD_FAILED": "", - "DOWNLOAD_PROGRESS": "" + "DOWNLOAD_PROGRESS": "", + "CHRISTMAS": "", + "CHRISTMAS_EVE": "", + "NEW_YEAR": "", + "NEW_YEAR_EVE": "", + "IMAGE": "", + "VIDEO": "", + "LIVE_PHOTO": "" } diff --git a/apps/photos/public/locales/fa/translation.json b/apps/photos/public/locales/fa/translation.json index a5b0d54ef..87f1e8167 100644 --- a/apps/photos/public/locales/fa/translation.json +++ b/apps/photos/public/locales/fa/translation.json @@ -209,7 +209,8 @@ "DATE": "", "FILE_NAME": "", "THING": "", - "FILE_CAPTION": "" + "FILE_CAPTION": "", + "FILE_TYPE": "" }, "photos_count_zero": "", "photos_count_one": "", @@ -583,5 +584,12 @@ "DOWNLOAD_COMPLETE": "", "DOWNLOADING_COLLECTION": "", "DOWNLOAD_FAILED": "", - "DOWNLOAD_PROGRESS": "" + "DOWNLOAD_PROGRESS": "", + "CHRISTMAS": "", + "CHRISTMAS_EVE": "", + "NEW_YEAR": "", + "NEW_YEAR_EVE": "", + "IMAGE": "", + "VIDEO": "", + "LIVE_PHOTO": "" } diff --git a/apps/photos/public/locales/fi/translation.json b/apps/photos/public/locales/fi/translation.json index d0da15f6f..46f300083 100644 --- a/apps/photos/public/locales/fi/translation.json +++ b/apps/photos/public/locales/fi/translation.json @@ -209,7 +209,8 @@ "DATE": "", "FILE_NAME": "", "THING": "", - "FILE_CAPTION": "" + "FILE_CAPTION": "", + "FILE_TYPE": "" }, "photos_count_zero": "", "photos_count_one": "", @@ -583,5 +584,12 @@ "DOWNLOAD_COMPLETE": "", "DOWNLOADING_COLLECTION": "", "DOWNLOAD_FAILED": "", - "DOWNLOAD_PROGRESS": "" + "DOWNLOAD_PROGRESS": "", + "CHRISTMAS": "", + "CHRISTMAS_EVE": "", + "NEW_YEAR": "", + "NEW_YEAR_EVE": "", + "IMAGE": "", + "VIDEO": "", + "LIVE_PHOTO": "" } diff --git a/apps/photos/public/locales/fr/translation.json b/apps/photos/public/locales/fr/translation.json index 93823309f..1c716b09a 100644 --- a/apps/photos/public/locales/fr/translation.json +++ b/apps/photos/public/locales/fr/translation.json @@ -209,7 +209,8 @@ "DATE": "Date", "FILE_NAME": "Nom de fichier", "THING": "Chose", - "FILE_CAPTION": "Description" + "FILE_CAPTION": "Description", + "FILE_TYPE": "" }, "photos_count_zero": "Pas de souvenirs", "photos_count_one": "1 souvenir", @@ -583,5 +584,12 @@ "DOWNLOAD_COMPLETE": "", "DOWNLOADING_COLLECTION": "", "DOWNLOAD_FAILED": "", - "DOWNLOAD_PROGRESS": "" + "DOWNLOAD_PROGRESS": "", + "CHRISTMAS": "", + "CHRISTMAS_EVE": "", + "NEW_YEAR": "", + "NEW_YEAR_EVE": "", + "IMAGE": "", + "VIDEO": "", + "LIVE_PHOTO": "" } diff --git a/apps/photos/public/locales/it/translation.json b/apps/photos/public/locales/it/translation.json index 9dbfaddf1..46c44b9e9 100644 --- a/apps/photos/public/locales/it/translation.json +++ b/apps/photos/public/locales/it/translation.json @@ -209,7 +209,8 @@ "DATE": "Data", "FILE_NAME": "Nome file", "THING": "", - "FILE_CAPTION": "Descrizione" + "FILE_CAPTION": "Descrizione", + "FILE_TYPE": "" }, "photos_count_zero": "", "photos_count_one": "", @@ -583,5 +584,12 @@ "DOWNLOAD_COMPLETE": "", "DOWNLOADING_COLLECTION": "", "DOWNLOAD_FAILED": "", - "DOWNLOAD_PROGRESS": "" + "DOWNLOAD_PROGRESS": "", + "CHRISTMAS": "", + "CHRISTMAS_EVE": "", + "NEW_YEAR": "", + "NEW_YEAR_EVE": "", + "IMAGE": "", + "VIDEO": "", + "LIVE_PHOTO": "" } diff --git a/apps/photos/public/locales/nl/translation.json b/apps/photos/public/locales/nl/translation.json index 4e7e97b91..607b56a92 100644 --- a/apps/photos/public/locales/nl/translation.json +++ b/apps/photos/public/locales/nl/translation.json @@ -209,7 +209,8 @@ "DATE": "Datum", "FILE_NAME": "Bestandsnaam", "THING": "Inhoud", - "FILE_CAPTION": "Omschrijving" + "FILE_CAPTION": "Omschrijving", + "FILE_TYPE": "Bestandstype" }, "photos_count_zero": "Geen herinneringen", "photos_count_one": "1 herinnering", @@ -423,9 +424,9 @@ "STOP_ALL_UPLOADS_MESSAGE": "Weet u zeker dat u wilt stoppen met alle uploads die worden uitgevoerd?", "STOP_UPLOADS_HEADER": "Stoppen met uploaden?", "YES_STOP_UPLOADS": "Ja, stop uploaden", - "STOP_DOWNLOADS_HEADER": "", - "YES_STOP_DOWNLOADS": "", - "STOP_ALL_DOWNLOADS_MESSAGE": "", + "STOP_DOWNLOADS_HEADER": "Downloaden stoppen?", + "YES_STOP_DOWNLOADS": "Ja, downloads stoppen", + "STOP_ALL_DOWNLOADS_MESSAGE": "Weet je zeker dat je wilt stoppen met alle downloads die worden uitgevoerd?", "albums_one": "1 Album", "albums_other": "{{count, number}} Albums", "ALL_ALBUMS": "Alle albums", @@ -580,8 +581,15 @@ "SELECT_COLLECTION": "Album selecteren", "PIN_ALBUM": "Album bovenaan vastzetten", "UNPIN_ALBUM": "Album losmaken", - "DOWNLOAD_COMPLETE": "", - "DOWNLOADING_COLLECTION": "", - "DOWNLOAD_FAILED": "", - "DOWNLOAD_PROGRESS": "" + "DOWNLOAD_COMPLETE": "Download compleet", + "DOWNLOADING_COLLECTION": "{{name}} downloaden", + "DOWNLOAD_FAILED": "Download mislukt", + "DOWNLOAD_PROGRESS": "{{progress.current}} / {{progress.total}} bestanden", + "CHRISTMAS": "Kerst", + "CHRISTMAS_EVE": "Kerstavond", + "NEW_YEAR": "Nieuwjaar", + "NEW_YEAR_EVE": "Oudjaarsavond", + "IMAGE": "Afbeelding", + "VIDEO": "Video", + "LIVE_PHOTO": "Live foto" } diff --git a/apps/photos/public/locales/pt/translation.json b/apps/photos/public/locales/pt/translation.json index e4864c5fc..96902e088 100644 --- a/apps/photos/public/locales/pt/translation.json +++ b/apps/photos/public/locales/pt/translation.json @@ -209,7 +209,8 @@ "DATE": "", "FILE_NAME": "", "THING": "", - "FILE_CAPTION": "" + "FILE_CAPTION": "", + "FILE_TYPE": "" }, "photos_count_zero": "", "photos_count_one": "", @@ -583,5 +584,12 @@ "DOWNLOAD_COMPLETE": "", "DOWNLOADING_COLLECTION": "", "DOWNLOAD_FAILED": "", - "DOWNLOAD_PROGRESS": "" + "DOWNLOAD_PROGRESS": "", + "CHRISTMAS": "", + "CHRISTMAS_EVE": "", + "NEW_YEAR": "", + "NEW_YEAR_EVE": "", + "IMAGE": "", + "VIDEO": "", + "LIVE_PHOTO": "" } diff --git a/apps/photos/public/locales/ru/translation.json b/apps/photos/public/locales/ru/translation.json index d0da15f6f..46f300083 100644 --- a/apps/photos/public/locales/ru/translation.json +++ b/apps/photos/public/locales/ru/translation.json @@ -209,7 +209,8 @@ "DATE": "", "FILE_NAME": "", "THING": "", - "FILE_CAPTION": "" + "FILE_CAPTION": "", + "FILE_TYPE": "" }, "photos_count_zero": "", "photos_count_one": "", @@ -583,5 +584,12 @@ "DOWNLOAD_COMPLETE": "", "DOWNLOADING_COLLECTION": "", "DOWNLOAD_FAILED": "", - "DOWNLOAD_PROGRESS": "" + "DOWNLOAD_PROGRESS": "", + "CHRISTMAS": "", + "CHRISTMAS_EVE": "", + "NEW_YEAR": "", + "NEW_YEAR_EVE": "", + "IMAGE": "", + "VIDEO": "", + "LIVE_PHOTO": "" } diff --git a/apps/photos/public/locales/tr/translation.json b/apps/photos/public/locales/tr/translation.json index d0da15f6f..46f300083 100644 --- a/apps/photos/public/locales/tr/translation.json +++ b/apps/photos/public/locales/tr/translation.json @@ -209,7 +209,8 @@ "DATE": "", "FILE_NAME": "", "THING": "", - "FILE_CAPTION": "" + "FILE_CAPTION": "", + "FILE_TYPE": "" }, "photos_count_zero": "", "photos_count_one": "", @@ -583,5 +584,12 @@ "DOWNLOAD_COMPLETE": "", "DOWNLOADING_COLLECTION": "", "DOWNLOAD_FAILED": "", - "DOWNLOAD_PROGRESS": "" + "DOWNLOAD_PROGRESS": "", + "CHRISTMAS": "", + "CHRISTMAS_EVE": "", + "NEW_YEAR": "", + "NEW_YEAR_EVE": "", + "IMAGE": "", + "VIDEO": "", + "LIVE_PHOTO": "" } diff --git a/apps/photos/public/locales/zh/translation.json b/apps/photos/public/locales/zh/translation.json index 1d2fe70f4..4927c7a33 100644 --- a/apps/photos/public/locales/zh/translation.json +++ b/apps/photos/public/locales/zh/translation.json @@ -77,7 +77,7 @@ "DOWNLOAD_OPTION": "下载 (D)", "DOWNLOAD_FAVORITES": "下载收藏", "DOWNLOAD_UNCATEGORIZED": "下载未分类的", - "DOWNLOAD_HIDDEN_ITEMS": "", + "DOWNLOAD_HIDDEN_ITEMS": "下载隐藏项目", "COPY_OPTION": "复制为 PNG (Ctrl/Cmd - C)", "TOGGLE_FULLSCREEN": "切换至全屏 (F)", "ZOOM_IN_OUT": "放大/缩小", @@ -209,7 +209,8 @@ "DATE": "日期", "FILE_NAME": "文件名", "THING": "内容", - "FILE_CAPTION": "说明" + "FILE_CAPTION": "说明", + "FILE_TYPE": "" }, "photos_count_zero": "没有回忆", "photos_count_one": "1个回忆", @@ -306,8 +307,8 @@ "MOVE_TO_COLLECTION": "移动到相册", "UNARCHIVE": "取消存档", "UNARCHIVE_COLLECTION": "取消存档相册", - "HIDE_COLLECTION": "", - "UNHIDE_COLLECTION": "", + "HIDE_COLLECTION": "隐藏相册", + "UNHIDE_COLLECTION": "取消隐藏相册", "MOVE": "移动", "ADD": "添加", "REMOVE": "移除", @@ -393,7 +394,7 @@ "LINK_PASSWORD_LOCK": "密码锁", "PUBLIC_COLLECT": "允许添加照片", "LINK_DEVICE_LIMIT": "设备限制", - "NO_DEVICE_LIMIT": "", + "NO_DEVICE_LIMIT": "无", "LINK_EXPIRY": "链接过期", "NEVER": "永不", "DISABLE_FILE_DOWNLOAD": "禁止下载", @@ -423,17 +424,17 @@ "STOP_ALL_UPLOADS_MESSAGE": "您确定要停止所有正在进行的上传吗?", "STOP_UPLOADS_HEADER": "要停止上传吗?", "YES_STOP_UPLOADS": "是的,停止上传", - "STOP_DOWNLOADS_HEADER": "", - "YES_STOP_DOWNLOADS": "", - "STOP_ALL_DOWNLOADS_MESSAGE": "", + "STOP_DOWNLOADS_HEADER": "要停止下载吗?", + "YES_STOP_DOWNLOADS": "是,停止下载", + "STOP_ALL_DOWNLOADS_MESSAGE": "您确定要停止所有正在进行的下载?", "albums_one": "1个相册", "albums_other": "{{count, number}} 个相册", "ALL_ALBUMS": "所有相册", "ALBUMS": "相册", - "ALL_HIDDEN_ALBUMS": "", - "HIDDEN_ALBUMS": "", - "HIDDEN_ITEMS": "", - "HIDDEN_ITEMS_SECTION_NAME": "", + "ALL_HIDDEN_ALBUMS": "所有隐藏的相册", + "HIDDEN_ALBUMS": "隐藏的相册", + "HIDDEN_ITEMS": "隐藏的项目", + "HIDDEN_ITEMS_SECTION_NAME": "隐藏的项目", "ENTER_TWO_FACTOR_OTP": "请输入您从身份验证应用上获得的6位数代码", "CREATE_ACCOUNT": "创建账户", "COPIED": "已复制", @@ -538,9 +539,9 @@ "STOP_EXPORT": "停止", "EXPORT_PROGRESS": "{{progress.success}} / {{progress.total}} 个文件已导出", "MIGRATING_EXPORT": "准备中...", - "RENAMING_COLLECTION_FOLDERS": "", - "TRASHING_DELETED_FILES": "", - "TRASHING_DELETED_COLLECTIONS": "", + "RENAMING_COLLECTION_FOLDERS": "正在重命名相册文件夹...", + "TRASHING_DELETED_FILES": "正在回收删除的文件...", + "TRASHING_DELETED_COLLECTIONS": "正在回收已删除的相册...", "EXPORT_NOTIFICATION": { "START": "导出已开始", "IN_PROGRESS": "导出已在进行中", @@ -580,8 +581,15 @@ "SELECT_COLLECTION": "选择相册", "PIN_ALBUM": "置顶相册", "UNPIN_ALBUM": "取消置顶相册", - "DOWNLOAD_COMPLETE": "", - "DOWNLOADING_COLLECTION": "", - "DOWNLOAD_FAILED": "", - "DOWNLOAD_PROGRESS": "" + "DOWNLOAD_COMPLETE": "下载完成", + "DOWNLOADING_COLLECTION": "正在下载 {{name}}", + "DOWNLOAD_FAILED": "下载失败", + "DOWNLOAD_PROGRESS": "{{progress.current}} / {{progress.total}} 个文件", + "CHRISTMAS": "", + "CHRISTMAS_EVE": "", + "NEW_YEAR": "", + "NEW_YEAR_EVE": "", + "IMAGE": "", + "VIDEO": "", + "LIVE_PHOTO": "" } diff --git a/apps/photos/src/components/Login.tsx b/apps/photos/src/components/Login.tsx index ff462087b..1ee99622a 100644 --- a/apps/photos/src/components/Login.tsx +++ b/apps/photos/src/components/Login.tsx @@ -6,7 +6,6 @@ import FormPaperTitle from './Form/FormPaper/Title'; import FormPaperFooter from './Form/FormPaper/Footer'; import LinkButton from './pages/gallery/LinkButton'; import { t } from 'i18next'; -import { setUserSRPSetupPending } from 'utils/storage'; import { addLocalLog } from 'utils/logging'; import { Input } from '@mui/material'; import SingleInputForm, { SingleInputFormProps } from './SingleInputForm'; @@ -28,7 +27,6 @@ export default function Login(props: LoginProps) { addLocalLog( () => ` srpAttributes: ${JSON.stringify(srpAttributes)}` ); - setUserSRPSetupPending(!srpAttributes); if (!srpAttributes || srpAttributes.isEmailMFAEnabled) { await sendOtt(email); router.push(PAGES.VERIFY); diff --git a/apps/photos/src/components/PhotoList.tsx b/apps/photos/src/components/PhotoList.tsx index 8b10134b8..793be7193 100644 --- a/apps/photos/src/components/PhotoList.tsx +++ b/apps/photos/src/components/PhotoList.tsx @@ -105,6 +105,15 @@ function getGapFromScreenEdge(width: number) { } } +function getShrinkRatio(width: number, columns: number) { + return ( + (width - + 2 * getGapFromScreenEdge(width) - + (columns - 1) * GAP_BTW_TILES) / + (columns * IMAGE_CONTAINER_MAX_WIDTH) + ); +} + const ListContainer = styled(Box)<{ columns: number; shrinkRatio: number; @@ -264,10 +273,10 @@ export function PhotoList({ let skipMerge = false; if (columns < MIN_COLUMNS) { - columns = MIN_COLUMNS - 1; + columns = MIN_COLUMNS; skipMerge = true; } - const shrinkRatio = fittableColumns / columns; + const shrinkRatio = getShrinkRatio(width, columns); const listItemHeight = IMAGE_CONTAINER_MAX_HEIGHT * shrinkRatio + GAP_BTW_TILES; diff --git a/apps/photos/src/components/Search/SearchBar/searchInput/index.tsx b/apps/photos/src/components/Search/SearchBar/searchInput/index.tsx index 2dc31ea20..a5ca17b69 100644 --- a/apps/photos/src/components/Search/SearchBar/searchInput/index.tsx +++ b/apps/photos/src/components/Search/SearchBar/searchInput/index.tsx @@ -27,6 +27,7 @@ import { Person, Thing, WordGroup } from 'types/machineLearning'; import { t } from 'i18next'; import memoize from 'memoize-one'; import { LocationTagData } from 'types/entity'; +import { FILE_TYPE } from 'constants/file'; interface Iprops { isOpen: boolean; @@ -117,6 +118,10 @@ export default function SearchInput(props: Iprops) { break; case SuggestionType.TEXT: search = { text: selectedOption.value as WordGroup }; + break; + case SuggestionType.FILE_TYPE: + search = { fileType: selectedOption.value as FILE_TYPE }; + break; } props.updateSearch(search, { optionName: selectedOption.label, diff --git a/apps/photos/src/pages/credentials/index.tsx b/apps/photos/src/pages/credentials/index.tsx index 1180dd4ee..a4ff000db 100644 --- a/apps/photos/src/pages/credentials/index.tsx +++ b/apps/photos/src/pages/credentials/index.tsx @@ -23,12 +23,13 @@ import { generateSRPSetupAttributes, saveKeyInSessionStore, } from 'utils/crypto'; -import { logoutUser, configureSRP, loginViaSRP } from 'services/userService'; import { - getUserSRPSetupPending, - isFirstLogin, - setIsFirstLogin, -} from 'utils/storage'; + logoutUser, + configureSRP, + loginViaSRP, + getSRPAttributes, +} from 'services/userService'; +import { isFirstLogin, setIsFirstLogin } from 'utils/storage'; import { AppContext } from 'pages/_app'; import { logError } from 'utils/sentry'; import { KeyAttributes, SRPAttributes, User } from 'types/user'; @@ -99,7 +100,19 @@ export default function Credentials() { keyAttributes.keyDecryptionNonce, kek ); - useMasterPassword(key, kek, keyAttributes, kek); + useMasterPassword(key, kek, keyAttributes); + return; + } + if (keyAttributes) { + if ( + (!user?.token && !user?.encryptedToken) || + (keyAttributes && !keyAttributes.memLimit) + ) { + clearData(); + router.push(PAGES.ROOT); + return; + } + setKeyAttributes(keyAttributes); return; } @@ -108,23 +121,9 @@ export default function Credentials() { ); if (srpAttributes) { setSrpAttributes(srpAttributes); - return; - } - - if ( - (!user?.token && !user?.encryptedToken) || - (keyAttributes && !keyAttributes.memLimit) - ) { - clearData(); + } else { router.push(PAGES.ROOT); - return; } - - if (!keyAttributes) { - router.push(PAGES.GENERATE); - return; - } - setKeyAttributes(keyAttributes); }; main(); appContext.showNavBar(true); @@ -141,7 +140,6 @@ export default function Credentials() { id, twoFactorSessionID, } = await loginViaSRP(srpAttributes, kek); - setData(LS_KEYS.KEY_ATTRIBUTES, keyAttributes); if (twoFactorSessionID) { const sessionKeyAttributes = await cryptoWorker.generateKeyAndEncryptToB64(kek); @@ -167,6 +165,7 @@ export default function Credentials() { id, isTwoFactorEnabled: false, }); + setData(LS_KEYS.KEY_ATTRIBUTES, keyAttributes); return keyAttributes; } } catch (e) { @@ -194,9 +193,17 @@ export default function Credentials() { await saveKeyInSessionStore(SESSION_KEYS.ENCRYPTION_KEY, key); await decryptAndStoreToken(keyAttributes, key); try { - const userSRPSetupPending = getUserSRPSetupPending(); - addLocalLog(() => `userSRPSetupPending ${userSRPSetupPending}`); - if (userSRPSetupPending) { + let srpAttributes: SRPAttributes = getData( + LS_KEYS.SRP_ATTRIBUTES + ); + if (!srpAttributes) { + srpAttributes = await getSRPAttributes(user.email); + if (srpAttributes) { + setData(LS_KEYS.SRP_ATTRIBUTES, srpAttributes); + } + } + addLocalLog(() => `userSRPSetupPending ${!srpAttributes}`); + if (!srpAttributes) { const loginSubKey = await generateLoginSubKey(kek); const srpSetupAttributes = await generateSRPSetupAttributes( loginSubKey diff --git a/apps/photos/src/pages/gallery/index.tsx b/apps/photos/src/pages/gallery/index.tsx index 0fc44f7f2..c7eb48906 100644 --- a/apps/photos/src/pages/gallery/index.tsx +++ b/apps/photos/src/pages/gallery/index.tsx @@ -523,6 +523,12 @@ export default function Gallery() { if (search?.files && search.files.indexOf(item.id) === -1) { return false; } + if ( + typeof search?.fileType !== 'undefined' && + search.fileType !== item.metadata.fileType + ) { + return false; + } return true; } diff --git a/apps/photos/src/services/searchService.ts b/apps/photos/src/services/searchService.ts index f4ba3026a..48c09d436 100644 --- a/apps/photos/src/services/searchService.ts +++ b/apps/photos/src/services/searchService.ts @@ -25,6 +25,7 @@ import { getUniqueFiles } from 'utils/file'; import { getLatestEntities } from './entityService'; import { LocationTag, LocationTagData, EntityType } from 'types/entity'; import { addLogLine } from 'utils/logging'; +import { FILE_TYPE } from 'constants/file'; const DIGITS = new Set(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']); @@ -44,6 +45,7 @@ export const getAutoCompleteSuggestions = return []; } const suggestions: Suggestion[] = [ + ...getFileTypeSuggestion(searchPhrase), ...getHolidaySuggestion(searchPhrase), ...getYearSuggestion(searchPhrase), ...getDateSuggestion(searchPhrase), @@ -84,26 +86,47 @@ function convertSuggestionsToOptions( return previewImageAppendedOptions; } +function getFileTypeSuggestion(searchPhrase: string): Suggestion[] { + return [ + { + label: t('IMAGE'), + value: FILE_TYPE.IMAGE, + type: SuggestionType.FILE_TYPE, + }, + { + label: t('VIDEO'), + value: FILE_TYPE.VIDEO, + type: SuggestionType.FILE_TYPE, + }, + { + label: t('LIVE_PHOTO'), + value: FILE_TYPE.LIVE_PHOTO, + type: SuggestionType.FILE_TYPE, + }, + ].filter((suggestion) => + suggestion.label.toLowerCase().includes(searchPhrase) + ); +} function getHolidaySuggestion(searchPhrase: string): Suggestion[] { return [ { - label: 'Christmas', + label: t('CHRISTMAS'), value: { month: 11, date: 25 }, type: SuggestionType.DATE, }, { - label: 'Christmas Eve', + label: t('CHRISTMAS_EVE'), value: { month: 11, date: 24 }, type: SuggestionType.DATE, }, { - label: 'New Year', + label: t('NEW_YEAR'), value: { month: 0, date: 1 }, type: SuggestionType.DATE, }, { - label: 'New Year Eve', + label: t('NEW_YEAR_EVE'), value: { month: 11, date: 31 }, type: SuggestionType.DATE, }, @@ -353,6 +376,9 @@ function isSearchedFile(file: EnteFile, search: Search) { if (search?.text) { return search.text.files.indexOf(file.id) !== -1; } + if (typeof search?.fileType !== 'undefined') { + return search.fileType === file.metadata.fileType; + } return false; } @@ -382,5 +408,7 @@ function convertSuggestionToSearchQuery(option: Suggestion): Search { case SuggestionType.THING: return { thing: option.value as Thing }; + case SuggestionType.FILE_TYPE: + return { fileType: option.value as FILE_TYPE }; } } diff --git a/apps/photos/src/services/userService.ts b/apps/photos/src/services/userService.ts index de35a504f..a6357857b 100644 --- a/apps/photos/src/services/userService.ts +++ b/apps/photos/src/services/userService.ts @@ -45,7 +45,6 @@ import { getLocalFamilyData, isPartOfFamily } from 'utils/user/family'; import { AxiosResponse } from 'axios'; import { APPS, getAppName } from 'constants/apps'; import { addLocalLog } from 'utils/logging'; -import { setUserSRPSetupPending } from 'utils/storage'; import { convertBase64ToBuffer, convertBufferToBase64 } from 'utils/user'; import { setLocalMapEnabled } from 'utils/storage'; import InMemoryStore from './InMemoryStore'; @@ -588,8 +587,6 @@ export const configureSRP = async ({ }); srpClient.checkM2(convertBase64ToBuffer(srpM2)); - - setUserSRPSetupPending(false); } catch (e) { logError(e, 'srp configure failed'); throw e; diff --git a/apps/photos/src/types/search/index.ts b/apps/photos/src/types/search/index.ts index b7b669014..ea38e9737 100644 --- a/apps/photos/src/types/search/index.ts +++ b/apps/photos/src/types/search/index.ts @@ -2,6 +2,7 @@ import { Person, Thing, WordGroup } from 'types/machineLearning'; import { IndexStatus } from 'types/machineLearning/ui'; import { EnteFile } from 'types/file'; import { LocationTagData } from 'types/entity'; +import { FILE_TYPE } from 'constants/file'; export enum SuggestionType { DATE = 'DATE', @@ -13,6 +14,7 @@ export enum SuggestionType { THING = 'THING', TEXT = 'TEXT', FILE_CAPTION = 'FILE_CAPTION', + FILE_TYPE = 'FILE_TYPE', } export interface DateValue { @@ -31,7 +33,8 @@ export interface Suggestion { | IndexStatus | Thing | WordGroup - | LocationTagData; + | LocationTagData + | FILE_TYPE; hide?: boolean; } @@ -43,6 +46,7 @@ export type Search = { person?: Person; thing?: Thing; text?: WordGroup; + fileType?: FILE_TYPE; }; export type SearchResultSummary = { diff --git a/apps/photos/src/utils/storage/index.ts b/apps/photos/src/utils/storage/index.ts index ede5f9cca..87e858d43 100644 --- a/apps/photos/src/utils/storage/index.ts +++ b/apps/photos/src/utils/storage/index.ts @@ -27,14 +27,6 @@ export function getUserLocale(): Language { return getData(LS_KEYS.LOCALE)?.value; } -export function setUserSRPSetupPending(status) { - setData(LS_KEYS.USER_SRP_SETUP_PENDING, { status }); -} - -export function getUserSRPSetupPending() { - return getData(LS_KEYS.USER_SRP_SETUP_PENDING)?.status ?? true; -} - export function getLocalMapEnabled(): boolean { return getData(LS_KEYS.MAP_ENABLED)?.value ?? false; } diff --git a/apps/photos/src/utils/storage/localStorage.ts b/apps/photos/src/utils/storage/localStorage.ts index 66fea0cbc..1c1ce575c 100644 --- a/apps/photos/src/utils/storage/localStorage.ts +++ b/apps/photos/src/utils/storage/localStorage.ts @@ -22,7 +22,6 @@ export enum LS_KEYS { WAIT_TIME = 'waitTime', API_ENDPOINT = 'apiEndpoint', LOCALE = 'locale', - USER_SRP_SETUP_PENDING = 'userSRPSetupPending', MAP_ENABLED = 'mapEnabled', SRP_SETUP_ATTRIBUTES = 'srpSetupAttributes', SRP_ATTRIBUTES = 'srpAttributes',