π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat(mapView):added-for-all
Aswin Asokbcfe28f5c543
diff --git a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsxindex 7cdbcd3981..b254803949 100644--- a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx+++ b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx@@ -169,6 +169,7 @@ function useCurrentUser() {*/function useMapData(open: boolean,+ collectionSummary: CollectionSummary,activeCollection: Collection | undefined,onGenericError: (e: unknown) => void,): MapDataResult {@@ -215,13 +216,16 @@ function useMapData();useEffect(() => {- if (!open || !activeCollection) return;+ if (!open) return;const loadMapData = async () => {setState((prev) => ({ ...prev, isLoading: true, error: null }));try {- const files = await getFilesForCollection(activeCollection);+ const files = await getFilesForCollection(+ collectionSummary,+ activeCollection,+ );const locationPoints = extractLocationPoints(files); // transforms the files into JourneyData[]if (locationPoints.length) {@@ -278,7 +282,7 @@ function useMapData(};void loadMapData();- }, [open, activeCollection, onGenericError, loadAllThumbs]);+ }, [open, collectionSummary, activeCollection, onGenericError, loadAllThumbs]);const removeFiles = useCallback((fileIDs: number[]) => {if (!fileIDs.length) return;@@ -714,9 +718,16 @@ function sortPhotosByTimestamp(photos: JourneyPoint[]): JourneyPoint[] {* target collection, removes duplicates by ID, and returns the unique set.*/async function getFilesForCollection(- activeCollection: Collection,+ collectionSummary: CollectionSummary,+ activeCollection: Collection | undefined,): Promise<EnteFile[]> {const allFiles = await savedCollectionFiles();+ if (collectionSummary.type === "all") {+ return uniqueFilesByID(allFiles);+ }+ if (!activeCollection) {+ return [];+ }const filtered = allFiles.filter((file) => file.collectionID === activeCollection.id,);@@ -784,7 +795,7 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({error,removeFiles: removeFilesFromMap,updateFileVisibility,- } = useMapData(open, activeCollection, onGenericError);+ } = useMapData(open, collectionSummary, activeCollection, onGenericError);const { visiblePhotos, setVisiblePhotos } = useVisiblePhotos();@@ -830,9 +841,9 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({ownCount: 0,count: 0,context: undefined,- collectionID: activeCollection?.id,+ collectionID: activeCollection?.id ?? collectionSummary.id,}),- [activeCollection?.id],+ [activeCollection?.id, collectionSummary.id],);const noOpSetSelected = useCallback(() => {/* no-op */diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsxindex 23dafaa5bf..254d622fa3 100644--- a/web/apps/photos/src/components/FileListWithViewer.tsx+++ b/web/apps/photos/src/components/FileListWithViewer.tsx@@ -1,4 +1,7 @@-import { styled } from "@mui/material";+import { IconButton, Tooltip, styled } from "@mui/material";+import { CollectionMapDialog } from "components/Collections/CollectionMapDialog";+import { useModalVisibility } from "ente-base/components/utils/modal";+import { useBaseContext } from "ente-base/context";import { isSameDay } from "ente-base/date";import { formattedDate } from "ente-base/i18n-date";import type { AddSaveGroup } from "ente-gallery/components/utils/save-groups";@@ -10,8 +13,12 @@ import { downloadAndSaveFiles } from "ente-gallery/services/save";import type { Collection } from "ente-media/collection";import type { EnteFile } from "ente-media/file";import { fileCreationTime, fileFileName } from "ente-media/file-metadata";+import { useSettingsSnapshot } from "ente-new/photos/components/utils/use-snapshot";import { moveToTrash } from "ente-new/photos/services/collection";+import type { CollectionSummary } from "ente-new/photos/services/collection-summary";import { PseudoCollectionID } from "ente-new/photos/services/collection-summary";+import { updateMapEnabled } from "ente-new/photos/services/settings";+import { GlobalIcon } from "hugeicons-react";import { t } from "i18next";import { useCallback, useMemo, useState } from "react";import AutoSizer from "react-virtualized-auto-sizer";@@ -48,6 +55,8 @@ export type FileListWithViewerProps = {* pull from remote.*/onRemotePull: () => Promise<void>;+ activeCollectionSummary?: CollectionSummary;+ activeCollection?: Collection;/*** A function that can be used to create a UI notification to track the* progress of user-initiated download, and to cancel it if needed.@@ -119,6 +128,8 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({setSelected,activeCollectionID,activePersonID,+ activeCollectionSummary,+ activeCollection,favoriteFileIDs,emailByUserID,listBorderRadius,@@ -144,6 +155,10 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({}) => {const [openFileViewer, setOpenFileViewer] = useState(false);const [currentIndex, setCurrentIndex] = useState(0);+ const { show: showMapDialog, props: mapDialogVisibilityProps } =+ useModalVisibility();+ const { onGenericError } = useBaseContext();+ const { mapEnabled } = useSettingsSnapshot();const annotatedFiles = useMemo((): FileListAnnotatedFile[] =>@@ -199,6 +214,45 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({};}, [enableImageEditing]);+ const shouldShowMapButton =+ activeCollectionSummary?.type === "all" &&+ activeCollectionSummary.fileCount > 0;++ const handleShowMap = useCallback(async () => {+ if (!activeCollectionSummary) return;+ if (!mapEnabled) {+ try {+ await updateMapEnabled(true);+ } catch (e) {+ onGenericError(e);+ return;+ }+ }+ showMapDialog();+ }, [activeCollectionSummary, mapEnabled, onGenericError, showMapDialog]);++ const headerWithMap = useMemo(() => {+ if (!shouldShowMapButton || !header) return header;+ return {+ ...header,+ component: (+ <HeaderWithMap>+ <HeaderMain>{header.component}</HeaderMain>+ <Tooltip title={t("map")}>+ <IconButton+ className="map-button"+ size="small"+ aria-label={t("map")}+ onClick={handleShowMap}+ >+ <GlobalIcon size={24} />+ </IconButton>+ </Tooltip>+ </HeaderWithMap>+ ),+ };+ }, [header, handleShowMap, shouldShowMapButton]);+return (<Container><AutoSizer>@@ -208,7 +262,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({{...{mode,modePlus,- header,+ header: headerWithMap,footer,user,disableGrouping,@@ -259,6 +313,25 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({onAddFileToCollection={onAddFileToCollection}activeCollectionID={activeCollectionID}/>+ {shouldShowMapButton && (+ <CollectionMapDialog+ {...mapDialogVisibilityProps}+ collectionSummary={activeCollectionSummary}+ activeCollection={activeCollection}+ onRemotePull={onRemotePull}+ {...{+ onAddSaveGroup,+ onMarkTempDeleted,+ onAddFileToCollection,+ onRemoteFilesPull,+ onVisualFeedback,+ fileNormalCollectionIDs,+ collectionNameByID,+ onSelectCollection,+ onSelectPerson,+ }}+ />+ )}</Container>);};@@ -268,6 +341,23 @@ const Container = styled("div")`width: 100%;`;+const HeaderWithMap = styled("div")`+ display: flex;+ align-items: center;+ justify-content: flex-start;+ gap: 12px;+ width: 100%;+ & > .map-button {+ flex-shrink: 0;+ margin-left: auto;+ }+`;++const HeaderMain = styled("div")`+ flex: 1;+ min-width: 0;+`;+/*** See: [Note: Timeline date string]*/diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 8e350fc7ff..098c7049c2 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -1396,6 +1396,8 @@ const Page: React.FC = () => {setSelected={setSelected}// TODO: Incorrect assertion, need to update the typeactiveCollectionID={activeCollectionID!}+ activeCollectionSummary={activeCollectionSummary}+ activeCollection={activeCollection}activePersonID={activePerson?.id}isInIncomingSharedCollection={activeCollectionSummary?.attributes.has("sharedIncoming",