π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat(FileInfo, FileViewer, ImageEditorOverlay): add optional zIndex prop for overlay positioning
Aswin Asokf3b6e95726ae
diff --git a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsxindex 38540b9150..ba72af1992 100644--- a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx+++ b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx@@ -28,9 +28,15 @@ import {fileCreationTime,fileFileName,fileLocation,+ ItemVisibility,} from "ente-media/file-metadata";-import { findDefaultHiddenCollectionIDs } from "ente-new/photos/services/collection";+import {+ addToFavoritesCollection,+ findDefaultHiddenCollectionIDs,+ removeFromFavoritesCollection,+} from "ente-new/photos/services/collection";import { type CollectionSummary } from "ente-new/photos/services/collection-summary";+import { updateFilesVisibility } from "ente-new/photos/services/file";import {savedCollectionFiles,savedCollections,@@ -77,16 +83,18 @@ interface MapControlsProps {const FloatingIconButton: React.FC<IconButtonProps> = ({ sx, ...props }) => {const baseSx = {- bgcolor: (theme: { vars: { palette: { background: { paper: string } } } }) =>- theme.vars.palette.background.paper,+ bgcolor: (theme: {+ vars: { palette: { background: { paper: string } } };+ }) => theme.vars.palette.background.paper,boxShadow: (theme: { shadows: string[] }) => theme.shadows[4],width: 48,height: 48,borderRadius: "16px",transition: "transform 0.2s ease-out","&:hover": {- bgcolor: (theme: { vars: { palette: { background: { paper: string } } } }) =>- theme.vars.palette.background.paper,+ bgcolor: (theme: {+ vars: { palette: { background: { paper: string } } };+ }) => theme.vars.palette.background.paper,transform: "scale(1.05)",},};@@ -258,6 +266,17 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({const [currentFileIndex, setCurrentFileIndex] = useState(0);const [viewerFiles, setViewerFiles] = useState<EnteFile[]>([]);+ // Favorite and visibility state for FileViewer+ const [favoriteFileIDs, setFavoriteFileIDs] = useState<Set<number>>(+ new Set(),+ );+ const [pendingFavoriteUpdates, setPendingFavoriteUpdates] = useState<+ Set<number>+ >(new Set());+ const [pendingVisibilityUpdates, setPendingVisibilityUpdates] = useState<+ Set<number>+ >(new Set());+const user = useMemo(() => {try {return ensureLocalUser();@@ -325,6 +344,82 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({// eslint-disable-next-line react-hooks/exhaustive-deps}, [open, collectionSummary.id, activeCollection.id]);+ // Load favorite file IDs when dialog opens+ useEffect(() => {+ if (!open || !user) return;++ const loadFavorites = async () => {+ const collections = await savedCollections();+ const collectionFiles = await savedCollectionFiles();++ for (const collection of collections) {+ if (+ collection.type === "favorites" &&+ collection.owner.id === user.id+ ) {+ const favoriteIDs = new Set(+ collectionFiles+ .filter((f) => f.collectionID === collection.id)+ .map((f) => f.id),+ );+ setFavoriteFileIDs(favoriteIDs);+ break;+ }+ }+ };++ void loadFavorites();+ }, [open, user]);++ const handleToggleFavorite = useCallback(+ async (file: EnteFile) => {+ if (!user) return;+ const fileID = file.id;+ const isFavorite = favoriteFileIDs.has(fileID);++ setPendingFavoriteUpdates((prev) => new Set(prev).add(fileID));+ try {+ const action = isFavorite+ ? removeFromFavoritesCollection+ : addToFavoritesCollection;+ await action([file]);+ setFavoriteFileIDs((prev) => {+ const next = new Set(prev);+ if (isFavorite) {+ next.delete(fileID);+ } else {+ next.add(fileID);+ }+ return next;+ });+ } finally {+ setPendingFavoriteUpdates((prev) => {+ const next = new Set(prev);+ next.delete(fileID);+ return next;+ });+ }+ },+ [user, favoriteFileIDs],+ );++ const handleFileVisibilityUpdate = useCallback(+ async (file: EnteFile, visibility: ItemVisibility) => {+ const fileID = file.id;+ setPendingVisibilityUpdates((prev) => new Set(prev).add(fileID));+ try {+ await updateFilesVisibility([file], visibility);+ } finally {+ setPendingVisibilityUpdates((prev) => {+ const next = new Set(prev);+ next.delete(fileID);+ return next;+ });+ }+ },+ [],+ );+const loadAllThumbs = async (points: JourneyPoint[], files: EnteFile[]) => {const sortedPoints = [...points].sort((a, b) =>@@ -593,6 +688,11 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({initialIndex={currentFileIndex}files={viewerFiles}user={user}+ favoriteFileIDs={favoriteFileIDs}+ pendingFavoriteUpdates={pendingFavoriteUpdates}+ pendingVisibilityUpdates={pendingVisibilityUpdates}+ onToggleFavorite={handleToggleFavorite}+ onFileVisibilityUpdate={handleFileVisibilityUpdate}onVisualFeedback={() => {// No-op for map view}}diff --git a/web/packages/gallery/components/FileInfo.tsx b/web/packages/gallery/components/FileInfo.tsxindex d9693080a0..7c31b5649a 100644--- a/web/packages/gallery/components/FileInfo.tsx+++ b/web/packages/gallery/components/FileInfo.tsx@@ -176,6 +176,12 @@ export type FileInfoProps = ModalVisibilityProps & {* Called when the user selects a person in the file info panel.*/onSelectPerson?: (personID: string) => void;+ /**+ * Optional z-index for the file info drawer.+ *+ * Use this when FileInfo needs to appear above other dialogs/modals.+ */+ zIndex?: number;};export const FileInfo: React.FC<FileInfoProps> = ({@@ -192,6 +198,7 @@ export const FileInfo: React.FC<FileInfoProps> = ({onUpdateCaption,onSelectCollection,onSelectPerson,+ zIndex,}) => {const { mapEnabled } = useSettingsSnapshot();@@ -245,7 +252,7 @@ export const FileInfo: React.FC<FileInfoProps> = ({const uploaderName = file.pubMagicMetadata?.data.uploaderName;return (- <FileInfoSidebar {...{ open, onClose }}>+ <FileInfoSidebar {...{ open, onClose, zIndex }}><SidebarDrawerTitlebaronClose={onClose}onRootClose={onClose}@@ -426,7 +433,12 @@ const annotateExif = (};const FileInfoSidebar = styled(- (props: Pick<DialogProps, "open" | "onClose" | "children">) => (+ ({+ zIndex,+ ...props+ }: Pick<DialogProps, "open" | "onClose" | "children"> & {+ zIndex?: number;+ }) => (<SidebarDrawer{...props}anchor="right"@@ -436,6 +448,7 @@ const FileInfoSidebar = styled(// https://github.com/mui/material-ui/issues/43106#issuecomment-2514637251disableRestoreFocus={true}closeAfterTransition={true}+ sx={zIndex !== undefined ? { zIndex } : undefined}/>),)(({ theme }) => ({diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsxindex bb693df91f..13967bfc6e 100644--- a/web/packages/gallery/components/viewer/FileViewer.tsx+++ b/web/packages/gallery/components/viewer/FileViewer.tsx@@ -908,6 +908,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({onUpdateCaption={handleUpdateCaption}onSelectCollection={handleSelectCollection}onSelectPerson={handleSelectPerson}+ zIndex={zIndex !== undefined ? zIndex + 1 : undefined}{...{ collectionNameByID }}/><MoreMenu@@ -916,6 +917,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({anchorEl={moreMenuAnchorEl}id={moreMenuID}slotProps={{ list: { "aria-labelledby": moreButtonID } }}+ sx={zIndex !== undefined ? { zIndex: zIndex + 1 } : undefined}>{activeAnnotatedFile.annotation.showDownload == "menu" && (<MoreMenuItem onClick={handleDownloadMenuAction}>@@ -989,6 +991,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({open={openConfirmDelete}onClose={handleConfirmDeleteClose}onConfirm={handleDelete}+ zIndex={zIndex !== undefined ? zIndex + 1 : undefined}/>{handleSaveEditedCopy && (<ImageEditorOverlay@@ -996,11 +999,13 @@ export const FileViewer: React.FC<FileViewerProps> = ({onClose={handleImageEditorClose}file={activeAnnotatedFile.file}onSaveEditedCopy={handleSaveEditedCopy}+ zIndex={zIndex !== undefined ? zIndex + 1 : undefined}/>)}<Shortcutsopen={openShortcuts}onClose={handleShortcutsClose}+ zIndex={zIndex !== undefined ? zIndex + 1 : undefined}{...{ disableDownload, haveUser }}/></>@@ -1058,6 +1063,10 @@ type ConfirmDeleteFileDialogProps = ModalVisibilityProps & {* operation completes.*/onConfirm: () => Promise<void>;+ /**+ * Optional z-index for the dialog.+ */+ zIndex?: number;};/**@@ -1071,6 +1080,7 @@ const ConfirmDeleteFileDialog: React.FC<ConfirmDeleteFileDialogProps> = ({open,onClose,onConfirm,+ zIndex,}) => {const [phase, setPhase] = useState<"loading" | "failed" | undefined>();@@ -1108,6 +1118,7 @@ const ConfirmDeleteFileDialog: React.FC<ConfirmDeleteFileDialogProps> = ({backgroundColor: theme.vars.palette.backdrop.faint,},}),+ ...(zIndex !== undefined && { zIndex }),})}><Typography sx={{ color: "text.muted" }}>@@ -1143,6 +1154,10 @@ type ShortcutsProps = ModalVisibilityProps &* `true` if we're running in a context where there is a logged in user.*/haveUser: boolean;+ /**+ * Optional z-index for the dialog.+ */+ zIndex?: number;};const Shortcuts: React.FC<ShortcutsProps> = ({@@ -1150,12 +1165,14 @@ const Shortcuts: React.FC<ShortcutsProps> = ({onClose,disableDownload,haveUser,+ zIndex,}) => (<Dialog{...{ open, onClose }}fullWidthfullScreen={useIsSmallWidth()}slotProps={{ backdrop: { sx: { backdropFilter: "blur(30px)" } } }}+ sx={zIndex !== undefined ? { zIndex } : undefined}><SpacedRow sx={{ pt: 2, px: 2.5 }}><DialogTitle>{t("shortcuts")}</DialogTitle>diff --git a/web/packages/new/photos/components/ImageEditorOverlay.tsx b/web/packages/new/photos/components/ImageEditorOverlay.tsxindex 47b469029d..0886878727 100644--- a/web/packages/new/photos/components/ImageEditorOverlay.tsx+++ b/web/packages/new/photos/components/ImageEditorOverlay.tsx@@ -81,6 +81,13 @@ export type ImageEditorOverlayProps = ModalVisibilityProps & {collection: Collection,enteFile: EnteFile,) => void;+ /**+ * Optional z-index for the overlay.+ *+ * Use this when ImageEditorOverlay needs to appear above other+ * dialogs/modals.+ */+ zIndex?: number;};const filterDefaultValues = {@@ -105,6 +112,7 @@ export const ImageEditorOverlay: React.FC<ImageEditorOverlayProps> = ({onClose,file,onSaveEditedCopy,+ zIndex,}) => {const { showMiniDialog } = useBaseContext();@@ -526,7 +534,7 @@ export const ImageEditorOverlay: React.FC<ImageEditorOverlayProps> = ({sx={{backgroundColor: "background.default" /* Opaque */,width: "100%",- zIndex: "var(--mui-zIndex-modal)",+ zIndex: zIndex ?? "var(--mui-zIndex-modal)",}}open>