π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web][photos] Add location support and improve edit location dialog
Anand Baburajan3decfdadb408
diff --git a/docs/docs/photos/faq/metadata-and-editing.md b/docs/docs/photos/faq/metadata-and-editing.mdindex 4012029ad8..4309f86b9b 100644--- a/docs/docs/photos/faq/metadata-and-editing.md+++ b/docs/docs/photos/faq/metadata-and-editing.md@@ -114,12 +114,21 @@ This is useful for:### Can I bulk edit photo locations? {#bulk-edit-locations}-Yes! You can bulk-edit location coordinates from the mobile app:+Yes! You can bulk-edit location coordinates:++**On mobile:**1. Long press to multi-select the photos you want to edit-2. Select "Edit location" from the action bar+2. Tap "Edit location" from the action bar3. Choose the correct location on the map-4. Apply to all selected photos+4. Tap Save++**On web:**++1. Click to select photos (Ctrl/Cmd+click or Shift+click for multiple)+2. Click the edit location icon in the selection bar+3. Click on the map to set the location, or drag the pin to adjust+4. Click "Save location"This is useful for:@@ -127,8 +136,6 @@ This is useful for:- Correcting wrong GPS coordinates- Organizing photos by location after the fact-**Note**: This feature is currently only available on the mobile app.-### How do I fix incorrect photo dates? {#fix-incorrect-dates}Photos sometimes have incorrect dates due to:@@ -182,9 +189,18 @@ Yes! You can manually add location data to any photo:**On mobile:**1. Select the photo(s)-2. Choose "Edit location" from the menu+2. Tap "Edit location" from the menu3. Select the location on the map-4. Save+4. Tap Save++**On web:**++1. Open the photo and click the info button (i)+2. In the Location section, click "Add"+3. Click on the map to set the location, or drag the pin to adjust+4. Click "Save location"++You can also add location to multiple photos at once. Learn more at [Bulk edit photo locations](#bulk-edit-locations).This adds GPS coordinates to the photo's metadata, allowing you to:@@ -192,8 +208,6 @@ This adds GPS coordinates to the photo's metadata, allowing you to:- Search by location- Organize photos by where they were taken-See [Bulk edit photo locations](#can-i-bulk-edit-photo-locations) for editing multiple photos at once.-## Exporting Metadata### Does the exported data preserve metadata? {#export-data-preserve-metadata}@@ -283,20 +297,17 @@ When you edit metadata on one device:### Can I edit metadata on all platforms? {#platform-support}-**Available on mobile and desktop:**+**Available on mobile, web, and desktop:**- Adding descriptions- Editing filenames- Viewing all EXIF data+- Adding and editing locations**Desktop only:**- Bulk editing dates ("Fix time" feature)-**Mobile only:**--- Bulk editing locations-We're working on bringing all editing features to all platforms.### Does Ente modify any file metadata? {#modify-file-metadata}diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.jsonindex 1b9c2e9b8a..d95af76d1f 100644--- a/web/packages/base/locales/en-US/translation.json+++ b/web/packages/base/locales/en-US/translation.json@@ -106,6 +106,8 @@"exit_fullscreen": "Exit fullscreen","go_fullscreen": "Go fullscreen","zoom": "Zoom",+ "zoom_in": "Zoom in",+ "zoom_out": "Zoom out","play": "Play","pause": "Pause","previous": "Previous",@@ -801,6 +803,8 @@"album_layout": "Album layout","maps_privacy_notice": "Approximate coordinates will be sent to privacy conscious third parties like OpenStreetMap to show the map and location.","edit_location": "Edit location",+ "add_location": "Add location",+ "add_location_button": "Add","save_location": "Save location","tap_to_select_location": "Click on the map to select a location"}diff --git a/web/packages/gallery/components/FileInfo.tsx b/web/packages/gallery/components/FileInfo.tsxindex 7f154d6185..aa89da02a8 100644--- a/web/packages/gallery/components/FileInfo.tsx+++ b/web/packages/gallery/components/FileInfo.tsx@@ -66,18 +66,18 @@ import {} from "ente-media/file-metadata";import { FileType } from "ente-media/file-type";import { AssignPersonDialog } from "ente-new/photos/components/AssignPersonDialog";+import { EditLocationDialog } from "ente-new/photos/components/EditLocationDialog";import { FileDateTimePicker } from "ente-new/photos/components/FileDateTimePicker";import { FilePeopleList } from "ente-new/photos/components/PeopleList";import {usePeopleStateSnapshot,useSettingsSnapshot,} from "ente-new/photos/components/utils/use-snapshot";-import { EditLocationDialog } from "ente-new/photos/components/EditLocationDialog";import {updateFileCaption,updateFileFileName,- updateFilesLocation,updateFilePublicMagicMetadata,+ updateFilesLocation,} from "ente-new/photos/services/file";import {addManualFileAssignmentsToPerson,@@ -353,7 +353,7 @@ export const FileInfo: React.FC<FileInfoProps> = ({/>)}- {location && (+ {location ? (<><InfoItemicon={<LocationOnOutlinedIcon />}@@ -379,7 +379,9 @@ export const FileInfo: React.FC<FileInfoProps> = ({trailingButton={<Stack direction="row" sx={{ gap: 1 }}>{allowEdits && (- <EditButton onClick={showEditLocation} />+ <EditButton+ onClick={showEditLocation}+ />)}<CopyButtonsize="medium"@@ -396,6 +398,20 @@ export const FileInfo: React.FC<FileInfoProps> = ({/>)}</>+ ) : (+ allowEdits && (+ <InfoItem+ icon={<LocationOnOutlinedIcon />}+ title={t("location")}+ caption={+ <LinkButtonUndecorated+ onClick={showEditLocation}+ >+ {t("add_location_button")}+ </LinkButtonUndecorated>+ }+ />+ ))}<InfoItemicon={<TextSnippetOutlinedIcon />}diff --git a/web/packages/new/photos/components/EditLocationDialog.tsx b/web/packages/new/photos/components/EditLocationDialog.tsxindex 8aa4fc2ad2..95a7cb4c06 100644--- a/web/packages/new/photos/components/EditLocationDialog.tsx+++ b/web/packages/new/photos/components/EditLocationDialog.tsx@@ -67,6 +67,9 @@ export const EditLocationDialog: React.FC<EditLocationDialogProps> = ({return file ? fileLocation(file) : undefined;}, [files]);+ // Capture whether we're adding (vs editing) when dialog opens+ const [isAddingLocation, setIsAddingLocation] = useState(false);+// Reset selected location and states only when dialog opensconst prevOpenRef = useRef(false);useEffect(() => {@@ -74,9 +77,11 @@ export const EditLocationDialog: React.FC<EditLocationDialogProps> = ({setSelectedLocation(initialLocation);setIsLoading(false);setIsSuccess(false);+ // Determine add vs edit based on whether any file has location at open time+ setIsAddingLocation(!files.some((file) => fileLocation(file)));}prevOpenRef.current = open;- }, [open, initialLocation]);+ }, [open, initialLocation, files]);const hasLocationChanged = useMemo(() => {if (!selectedLocation) return false;@@ -124,6 +129,7 @@ export const EditLocationDialog: React.FC<EditLocationDialogProps> = ({canConfirm={hasLocationChanged}isLoading={isLoading}isSuccess={isSuccess}+ isAddingLocation={isAddingLocation}/><Box sx={{ flex: 1, position: "relative" }}><EditableMap@@ -151,6 +157,7 @@ interface TitleBarProps {canConfirm: boolean;isLoading: boolean;isSuccess: boolean;+ isAddingLocation: boolean;}const TitleBar: React.FC<TitleBarProps> = ({@@ -159,6 +166,7 @@ const TitleBar: React.FC<TitleBarProps> = ({canConfirm,isLoading,isSuccess,+ isAddingLocation,}) => (<Stackdirection="row"@@ -170,11 +178,11 @@ const TitleBar: React.FC<TitleBarProps> = ({borderColor: "divider",}}>- <IconButton onClick={onBack}>+ <IconButton onClick={onBack} aria-label={t("close")}><ArrowBackIcon /></IconButton><Typography variant="h6" sx={{ flex: 1 }}>- {t("edit_location")}+ {t(isAddingLocation ? "add_location" : "edit_location")}</Typography>{isLoading ? (<Box@@ -341,21 +349,21 @@ const EditableMap: React.FC<EditableMapProps> = ({<MapContainer ref={mapContainerRef} /><MapOverlay>{selectedLocation ? (- <Typography variant="body2" sx={{ color: "text.muted" }}>+ <Typography variant="body" sx={{ color: "text.muted" }}>{selectedLocation.latitude.toFixed(6)},{" "}{selectedLocation.longitude.toFixed(6)}</Typography>) : (- <Typography variant="body2" sx={{ color: "text.muted" }}>+ <Typography variant="body" sx={{ color: "text.muted" }}>{t("tap_to_select_location")}</Typography>)}</MapOverlay><ZoomControls>- <ZoomButton onClick={handleZoomIn}>+ <ZoomButton onClick={handleZoomIn} aria-label={t("zoom_in")}><AddIcon /></ZoomButton>- <ZoomButton onClick={handleZoomOut}>+ <ZoomButton onClick={handleZoomOut} aria-label={t("zoom_out")}><RemoveIcon /></ZoomButton></ZoomControls>@@ -369,10 +377,7 @@ const MapWrapper = styled("div")({position: "relative",});-const MapContainer = styled("div")({- height: "100%",- width: "100%",-});+const MapContainer = styled("div")({ height: "100%", width: "100%" });const MapOverlay = styled("div")(({ theme }) => ({position: "absolute",diff --git a/web/packages/new/photos/services/file.ts b/web/packages/new/photos/services/file.tsindex 914c57b243..ee41a9a2f8 100644--- a/web/packages/new/photos/services/file.ts+++ b/web/packages/new/photos/services/file.ts@@ -289,8 +289,12 @@ const putFilesPublicMagicMetadata = async (** @param long The new longitude.*/-export const updateFilesLocation = (+export const updateFilesLocation = async (files: EnteFile[],lat: number,long: number,-) => batched(files, (b) => updateFilesPublicMagicMetadata(b, { lat, long }));+): Promise<void> => {+ await batched(files, (b) =>+ updateFilesPublicMagicMetadata(b, { lat, long }),+ );+};