π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web][photos] Add edit location button to file info panel
Anand Baburajan77ddddd6c8c8
diff --git a/web/packages/gallery/components/FileInfo.tsx b/web/packages/gallery/components/FileInfo.tsxindex 487c356915..7f154d6185 100644--- a/web/packages/gallery/components/FileInfo.tsx+++ b/web/packages/gallery/components/FileInfo.tsx@@ -72,9 +72,11 @@ import {usePeopleStateSnapshot,useSettingsSnapshot,} from "ente-new/photos/components/utils/use-snapshot";+import { EditLocationDialog } from "ente-new/photos/components/EditLocationDialog";import {updateFileCaption,updateFileFileName,+ updateFilesLocation,updateFilePublicMagicMetadata,} from "ente-new/photos/services/file";import {@@ -208,6 +210,8 @@ export const FileInfo: React.FC<FileInfoProps> = ({useModalVisibility();const { show: showAssignPerson, props: assignPersonVisibilityProps } =useModalVisibility();+ const { show: showEditLocation, props: editLocationVisibilityProps } =+ useModalVisibility();const assignablePeople = useMemo(() =>@@ -234,12 +238,21 @@ export const FileInfo: React.FC<FileInfoProps> = ({const canAddPerson = isMLEnabled() && assignablePeople.length > 0;- const location = useMemo(+ const fileLocationValue = useMemo(// Prefer the location in the EnteFile, then fall back to Exif.() => fileLocation(file) ?? exif?.parsed?.location,[file, exif],);+ // Local state to track updated location before file prop refreshes+ const [localLocation, setLocalLocation] = useState<Location | undefined>();+ const location = localLocation ?? fileLocationValue;++ // Reset local location when file changes+ useEffect(() => {+ setLocalLocation(undefined);+ }, [file.id]);+const annotatedExif = useMemo(() => annotateExif(exif), [exif]);useEffect(() => {@@ -285,6 +298,20 @@ export const FileInfo: React.FC<FileInfoProps> = ({}};+ const handleEditLocationConfirm = async (newLocation: Location) => {+ try {+ await updateFilesLocation(+ [file],+ newLocation.latitude,+ newLocation.longitude,+ );+ setLocalLocation(newLocation);+ await onFileMetadataUpdate?.();+ } catch (e) {+ onGenericError(e);+ }+ };+const uploaderName = file.pubMagicMetadata?.data.uploaderName;return (@@ -350,14 +377,20 @@ export const FileInfo: React.FC<FileInfoProps> = ({)}trailingButton={- <CopyButton- size="medium"- text={openStreetMapLink(location)}- />+ <Stack direction="row" sx={{ gap: 1 }}>+ {allowEdits && (+ <EditButton onClick={showEditLocation} />+ )}+ <CopyButton+ size="medium"+ text={openStreetMapLink(location)}+ />+ </Stack>}/>{allowMap && (<MapBox+ key={`${location.latitude}-${location.longitude}`}location={location}mapEnabled={mapEnabled}/>@@ -435,6 +468,14 @@ export const FileInfo: React.FC<FileInfoProps> = ({onSelectPerson={handleAddPerson}/>)}++ {allowEdits && (+ <EditLocationDialog+ {...editLocationVisibilityProps}+ files={[file]}+ onConfirm={handleEditLocationConfirm}+ />+ )}</FileInfoSidebar>);};diff --git a/web/packages/new/photos/components/SelectedFileOptions.tsx b/web/packages/new/photos/components/SelectedFileOptions.tsxindex 4bd4472714..cd576f6806 100644--- a/web/packages/new/photos/components/SelectedFileOptions.tsx+++ b/web/packages/new/photos/components/SelectedFileOptions.tsx@@ -7,7 +7,7 @@ import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline";import CloseIcon from "@mui/icons-material/Close";import DeleteIcon from "@mui/icons-material/Delete";import DownloadIcon from "@mui/icons-material/Download";-import LocationOnIcon from "@mui/icons-material/LocationOn";+import EditLocationAltIcon from "@mui/icons-material/EditLocationAlt";import PersonAddIcon from "@mui/icons-material/PersonAdd";import RemoveIcon from "@mui/icons-material/RemoveCircleOutline";import RestoreIcon from "@mui/icons-material/Restore";@@ -563,7 +563,7 @@ const FixTimeButton: React.FC<ButtonishProps> = ({ onClick }) => (const EditLocationButton: React.FC<ButtonishProps> = ({ onClick }) => (<Tooltip title={t("edit_location")}><IconButton {...{ onClick }}>- <LocationOnIcon />+ <EditLocationAltIcon /></IconButton></Tooltip>);