π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix(ContextMenu):lint-fixed-added-condition-for-showing-add-person-on-web
Aswin Asoka36317a75c4b
diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsxindex 16e19b7b55..43e9f030af 100644--- a/web/apps/photos/src/components/FileList.tsx+++ b/web/apps/photos/src/components/FileList.tsx@@ -325,6 +325,11 @@ export const FileList: React.FC<FileListProps> = ({fileIndex: number;} | null>(null);+ // Track selection state before right-click modified it+ const previousSelectionRef = useRef<SelectedState | null>(null);+ // Track if an action was taken from the context menu+ const contextMenuActionTakenRef = useRef(false);+const listRef = useRef<VariableSizeList | null>(null);const outerRef = useRef<HTMLDivElement | null>(null);@@ -648,8 +653,15 @@ export const FileList: React.FC<FileListProps> = ({event.preventDefault();event.stopPropagation();+ // Reset tracking for this menu open.+ previousSelectionRef.current = null;+ contextMenuActionTakenRef.current = false;+// Handle selection behavior on right-clickif (!selected[file.id]) {+ // Store current selection before replacing it+ previousSelectionRef.current = { ...selected };+// File not selected: clear selection and select only this fileconst isOwnFile = file.ownerID === user?.id;const context =@@ -690,8 +702,28 @@ export const FileList: React.FC<FileListProps> = ({// Handle context menu closeconst handleContextMenuClose = useCallback(() => {+ // Defer restore so a menu-item click can mark the close as action-driven.+ void Promise.resolve().then(() => {+ if (+ !contextMenuActionTakenRef.current &&+ previousSelectionRef.current+ ) {+ setSelected(previousSelectionRef.current);+ }+ previousSelectionRef.current = null;+ contextMenuActionTakenRef.current = false;+ });+setContextMenu(null);- }, []);+ }, [setSelected]);++ const handleContextMenuActionWithTracking = useCallback(+ (action: FileContextAction) => {+ contextMenuActionTakenRef.current = true;+ onContextMenuAction?.(action);+ },+ [onContextMenuAction],+ );const renderListItem = useCallback((item: FileListItem, isScrolling: boolean) => {@@ -934,7 +966,7 @@ export const FileList: React.FC<FileListProps> = ({anchorPosition={contextMenu?.position}onClose={handleContextMenuClose}actions={contextMenuActions}- onAction={onContextMenuAction}+ onAction={handleContextMenuActionWithTracking}selectedCount={selected.count}/>)}diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 5c2668a4a0..361f7fb864 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -1439,8 +1439,9 @@ const Page: React.FC = () => {createOnCreateForCollectionOp,createOnSelectForCollectionOp,createFileOpHandler,- onShowAssignPersonDialog:- showContextMenuAssignPerson,+ onShowAssignPersonDialog: showAddPersonAction+ ? showContextMenuAssignPerson+ : undefined,}}/>) : barMode == "hidden-albums" ? (diff --git a/web/packages/new/photos/components/SelectedFileOptions.tsx b/web/packages/new/photos/components/SelectedFileOptions.tsxindex cf20ef8c81..4c880e38e7 100644--- a/web/packages/new/photos/components/SelectedFileOptions.tsx+++ b/web/packages/new/photos/components/SelectedFileOptions.tsx@@ -315,7 +315,9 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({onClick={handleAddToCollection}/>{!!onShowAssignPersonDialog && (- <AddPersonButton onClick={onShowAssignPersonDialog} />+ <AddPersonButton+ onClick={onShowAssignPersonDialog}+ />)}<ArchiveButton onClick={handleArchive} /><HideButton onClick={handleHide} />@@ -329,7 +331,9 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({onClick={handleAddToCollection}/>{!!onShowAssignPersonDialog && (- <AddPersonButton onClick={onShowAssignPersonDialog} />+ <AddPersonButton+ onClick={onShowAssignPersonDialog}+ />)}<ArchiveButton onClick={handleArchive} /><HideButton onClick={handleHide} />@@ -346,7 +350,9 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({<><DownloadButton onClick={handleDownload} />{!!onShowAssignPersonDialog && (- <AddPersonButton onClick={onShowAssignPersonDialog} />+ <AddPersonButton+ onClick={onShowAssignPersonDialog}+ />)}<MoveToCollectionButtononClick={handleMoveToCollection}@@ -357,7 +363,9 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({<><DownloadButton onClick={handleDownload} />{!!onShowAssignPersonDialog && (- <AddPersonButton onClick={onShowAssignPersonDialog} />+ <AddPersonButton+ onClick={onShowAssignPersonDialog}+ />)}<RemoveFromCollectionButtononClick={handleRemoveFromCollection}@@ -367,7 +375,9 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({<><DownloadButton onClick={handleDownload} />{!!onShowAssignPersonDialog && (- <AddPersonButton onClick={onShowAssignPersonDialog} />+ <AddPersonButton+ onClick={onShowAssignPersonDialog}+ />)}<UnhideButton onClick={handleUnhide} /><DeleteButton onClick={handleDelete} />@@ -385,7 +395,9 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({onClick={handleAddToCollection}/>{!!onShowAssignPersonDialog && (- <AddPersonButton onClick={onShowAssignPersonDialog} />+ <AddPersonButton+ onClick={onShowAssignPersonDialog}+ />)}{collectionSummary?.id === PseudoCollectionID.all ? (<ArchiveButton onClick={handleArchive} />diff --git a/web/packages/new/photos/utils/file-actions.ts b/web/packages/new/photos/utils/file-actions.tsindex 0b8e07d311..857c81e2fd 100644--- a/web/packages/new/photos/utils/file-actions.ts+++ b/web/packages/new/photos/utils/file-actions.ts@@ -93,7 +93,14 @@ function getBaseActions(// People mode actionsif (barMode === "people") {- return ["favorite", "download", "addToAlbum", "archive", "hide", "trash"];+ return [+ "favorite",+ "download",+ "addToAlbum",+ "archive",+ "hide",+ "trash",+ ];}// Trash actions@@ -161,8 +168,12 @@ const modificationActions: FileContextAction[] = [/*** Inserts "addPerson" before the first modification action in the array.*/-function insertAddPersonBeforeModifications(actions: FileContextAction[]): void {- const insertIndex = actions.findIndex((a) => modificationActions.includes(a));+function insertAddPersonBeforeModifications(+ actions: FileContextAction[],+): void {+ const insertIndex = actions.findIndex((a) =>+ modificationActions.includes(a),+ );if (insertIndex !== -1) {actions.splice(insertIndex, 0, "addPerson");} else {