diff --git a/web/apps/photos/src/components/Sidebar/index.tsx b/web/apps/photos/src/components/Sidebar/index.tsx index 1dfe086046..7f9847e52f 100644 --- a/web/apps/photos/src/components/Sidebar/index.tsx +++ b/web/apps/photos/src/components/Sidebar/index.tsx @@ -1,4 +1,5 @@ import { openAccountsManagePasskeysPage } from "@/accounts/services/passkey"; +import { isDesktop } from "@/base/app"; import { EnteDrawer } from "@/base/components/EnteDrawer"; import log from "@/base/log"; import { savedLogs } from "@/base/log-web"; @@ -599,13 +600,10 @@ const HelpSection: React.FC = () => { const contactSupport = () => initiateEmail("support@ente.io"); - function openExport() { - if (isElectron()) { - openExportModal(); - } else { - setDialogMessage(getDownloadAppMessage()); - } - } + const handleExport = () => + isDesktop + ? openExportModal() + : setDialogMessage(getDownloadAppMessage()); return ( <> @@ -626,7 +624,7 @@ const HelpSection: React.FC = () => { variant="secondary" /> => { diff --git a/web/apps/photos/src/services/fileService.ts b/web/apps/photos/src/services/fileService.ts index a42701eca8..deb9bda779 100644 --- a/web/apps/photos/src/services/fileService.ts +++ b/web/apps/photos/src/services/fileService.ts @@ -14,6 +14,7 @@ import ComlinkCryptoWorker from "@ente/shared/crypto"; import HTTPService from "@ente/shared/network/HTTPService"; import { getToken } from "@ente/shared/storage/localStorage/helpers"; import { REQUEST_BATCH_SIZE } from "constants/api"; +import exportService from "services/export"; import { Collection } from "types/collection"; import { SetFiles } from "types/gallery"; import { batch } from "utils/common"; @@ -30,9 +31,11 @@ export const syncFiles = async ( ) => { const localFiles = await getLocalFiles(type); let files = await removeDeletedCollectionFiles(collections, localFiles); + let didUpdateFiles = false; if (files.length !== localFiles.length) { await setLocalFiles(type, files); setFiles(sortFiles(mergeMetadata(files))); + didUpdateFiles = true; } for (const collection of collections) { if (!getToken()) { @@ -46,8 +49,10 @@ export const syncFiles = async ( const newFiles = await getFiles(collection, lastSyncTime, setFiles); files = getLatestVersionFiles([...files, ...newFiles]); await setLocalFiles(type, files); + didUpdateFiles = true; setCollectionLastSyncTime(collection, collection.updationTime); } + if (didUpdateFiles) exportService.onLocalFilesUpdated(); return files; }; diff --git a/web/packages/new/photos/services/files.ts b/web/packages/new/photos/services/files.ts index 873dc5db59..6a0ad4faa1 100644 --- a/web/packages/new/photos/services/files.ts +++ b/web/packages/new/photos/services/files.ts @@ -1,5 +1,3 @@ -import log from "@/base/log"; -import { Events, eventBus } from "@ente/shared/events"; import localForage from "@ente/shared/storage/localForage"; import { type EnteFile, type Trash } from "../types/file"; import { mergeMetadata } from "../utils/file"; @@ -25,17 +23,17 @@ export const getLocalFiles = async (type: "normal" | "hidden" = "normal") => { return files; }; +/** + * Update the files that we know about locally. + * + * Sibling of {@link getLocalFiles}. + */ export const setLocalFiles = async ( type: "normal" | "hidden", files: EnteFile[], ) => { const tableName = type === "normal" ? FILES_TABLE : HIDDEN_FILES_TABLE; await localForage.setItem(tableName, files); - try { - eventBus.emit(Events.LOCAL_FILES_UPDATED); - } catch (e) { - log.error("Failed to save files", e); - } }; export const TRASH = "file-trash";