Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

chore(gallery):close-modal-on-exit

Aswin Asok17c39c966a1c
diff --git a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
index e55988e0f8..a238937258 100644
--- a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
@@ -311,7 +311,8 @@ const buildMapIndexPoints = async (files: EnteFile[]) => {
let latestFileId: number | undefined;
for (let index = 0; index < files.length; index += 1) {
- const file = files[index]!;
+ const file = files[index];
+ if (!file) continue;
const loc = fileLocation(file);
if (!loc) continue;
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index bc61a5b543..a69cbf6d19 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -287,6 +287,7 @@ const Page: React.FC = () => {
} = useModalVisibility();
const { show: showCollectionMap, props: collectionMapVisibilityProps } =
useModalVisibility();
+ const closeCollectionMap = collectionMapVisibilityProps.onClose;
const handleShowCollectionMap = useCallback(() => {
void (async () => {
@@ -622,6 +623,15 @@ const Page: React.FC = () => {
void router.push(href, undefined, { shallow: true });
}, [activeCollectionID, router.isReady]);
+ // The map dialog is only mounted when there is an active collection
+ // summary, and MUI only invokes onClose for escape / backdrop dismissal,
+ // so if the user navigates somewhere without one (e.g. to a person) while
+ // the map is open, the open flag would stay latched and the map would
+ // reopen on the next visit to an albums view unless we reset it here.
+ useEffect(() => {
+ if (!activeCollectionSummary) closeCollectionMap();
+ }, [activeCollectionSummary, closeCollectionMap]);
+
useEffect(() => {
if (router.isReady && haveMasterKeyInSession()) {
void handleSubscriptionCompletionRedirectIfNeeded(
@@ -1468,18 +1478,26 @@ const Page: React.FC = () => {
[],
);
+ // These can be invoked from the file viewer hosted by the map dialog, so
+ // close the map (if open) to land the user in the gallery grid instead of
+ // silently swapping the contents of the still open map.
const handleSelectCollection = useCallback(
- (collectionID: number) =>
+ (collectionID: number) => {
+ closeCollectionMap();
dispatch({
type: "showCollectionSummary",
collectionSummaryID: collectionID,
- }),
- [],
+ });
+ },
+ [closeCollectionMap],
);
const handleSelectPerson = useCallback(
- (personID: string) => dispatch({ type: "showPerson", personID }),
- [],
+ (personID: string) => {
+ closeCollectionMap();
+ dispatch({ type: "showPerson", personID });
+ },
+ [closeCollectionMap],
);
const handleOpenCollectionSelector = useCallback(