π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web][photos] Add Links rail navigation and listing
AswinAsok50d5ca777d1c
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsxindex 6738c001f8..ff7b853f39 100644--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx@@ -151,16 +151,26 @@ export const GalleryBarAndListHeader: React.FC<collectionShareVisibilityProps.onClose();}, [collectionShareVisibilityProps]);- const [collectionsSortBy, setCollectionsSortBy] =+ const [albumSortBy, setAlbumSortBy] =useCollectionsSortByLocalState("updation-time-desc");+ const [linksSortBy, setLinksSortBy] =+ useState<CollectionsSortBy>("updation-time-desc");+ const collectionsSortBy = mode == "links" ? linksSortBy : albumSortBy;+ const setCollectionsSortBy =+ mode == "links" ? setLinksSortBy : setAlbumSortBy;+ useEffect(() => {+ if (mode == "links") setLinksSortBy("updation-time-desc");+ }, [mode]);const sortedCollectionSummaries = useMemo(() =>sortCollectionSummaries([...toShowCollectionSummaries.values()],collectionsSortBy,- ).sort((a, b) => b.sortPriority - a.sortPriority),- [collectionsSortBy, toShowCollectionSummaries],+ ).sort((a, b) =>+ mode == "links" ? 0 : b.sortPriority - a.sortPriority,+ ),+ [collectionsSortBy, toShowCollectionSummaries, mode],);const eligibleCollectionSummaries = useMemo(() =>@@ -170,10 +180,12 @@ export const GalleryBarAndListHeader: React.FC<cs.id !== PseudoCollectionID.hiddenItems &&cs.id !== PseudoCollectionID.archiveItems &&cs.id !== PseudoCollectionID.trash &&- (mode == "albums"- ? !cs.attributes.has("system") ||- (cs.id > 0 && cs.type == "uncategorized")- : !cs.attributes.has("hideFromCollectionBar")),+ (mode == "links"+ ? true+ : mode == "albums"+ ? !cs.attributes.has("system") ||+ (cs.id > 0 && cs.type == "uncategorized")+ : !cs.attributes.has("hideFromCollectionBar")),),[sortedCollectionSummaries, uncategorizedCollectionSummaryID, mode],);@@ -243,7 +255,7 @@ export const GalleryBarAndListHeader: React.FC<);useEffect(() => {- if (shouldHide) return;+ if (shouldHide || mode == "links") return;const collectionSummary = toShowCollectionSummaries.get(activeCollectionID!,diff --git a/web/apps/photos/src/components/gallery/BarImpl.tsx b/web/apps/photos/src/components/gallery/BarImpl.tsxindex 537a09f5ef..e43384185a 100644--- a/web/apps/photos/src/components/gallery/BarImpl.tsx+++ b/web/apps/photos/src/components/gallery/BarImpl.tsx@@ -171,6 +171,7 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({case "albums":case "hidden-albums":case "archive-albums":+ case "links":i = collectionSummaries.findIndex(({ id }) => id == activeCollectionID,);@@ -199,11 +200,13 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({() =>mode == "albums" ||mode == "hidden-albums" ||- mode == "archive-albums"+ mode == "archive-albums" ||+ mode == "links"? {type: "collections",collectionSummaries: collectionSummaries,indented: mode == "albums",+ isLink: mode == "links",activeCollectionID: activeCollectionID!,onSelectCollectionID,}@@ -227,11 +230,13 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({const title =mode == "people"? t("people")- : mode == "hidden-albums"- ? t("hidden_albums")- : mode == "archive-albums"- ? t("section_archive")- : t("albums");+ : mode == "links"+ ? t("links")+ : mode == "hidden-albums"+ ? t("hidden_albums")+ : mode == "archive-albums"+ ? t("section_archive")+ : t("albums");const albumShortcuts = [{@@ -437,13 +442,17 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({placeholder={t(mode == "people"? "people_search_hint"- : "search_in_albums",+ : mode == "links"+ ? "search_links"+ : "search_in_albums",)}inputProps={{"aria-label": t(mode == "people"? "people_search_hint"- : "search_in_albums",+ : mode == "links"+ ? "search_links"+ : "search_in_albums",),}}value={searchQuery}@@ -538,7 +547,7 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({) : (items)}- {mode != "people" && (+ {mode != "people" && mode != "links" && (<Stack sx={{ flexShrink: 0, gap: "2px", pb: "8px" }}><Dividersx={{@@ -624,6 +633,7 @@ type ItemData =type: "collections";collectionSummaries: CollectionSummary[];indented: boolean;+ isLink: boolean;activeCollectionID: number;onSelectCollectionID: (id: number) => void;}@@ -679,6 +689,7 @@ const ListItem = memo((props: ListChildComponentProps<ItemData>) => {activeCollectionID,onSelectCollectionID,}}+ isLink={data.isLink}indented={data.indented &&!collectionSummary.attributes.has("system")@@ -707,6 +718,7 @@ const ListItem = memo((props: ListChildComponentProps<ItemData>) => {interface CollectionBarCardProps {collectionSummary: CollectionSummary;indented: boolean;+ isLink: boolean;activeCollectionID: number;onSelectCollectionID: (collectionID: number) => void;}@@ -714,6 +726,7 @@ interface CollectionBarCardProps {const CollectionBarCard: React.FC<CollectionBarCardProps> = ({collectionSummary,indented,+ isLink,activeCollectionID,onSelectCollectionID,}: CollectionBarCardProps) => (@@ -737,7 +750,9 @@ const CollectionBarCard: React.FC<CollectionBarCardProps> = ({/></Box><CardText>{collectionSummary.name}</CardText>- <CollectionBarCardIcon attributes={collectionSummary.attributes} />+ {!isLink && (+ <CollectionBarCardIcon attributes={collectionSummary.attributes} />+ )}</BarCard>);diff --git a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsxindex 8a50382268..47756ba741 100644--- a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx+++ b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx@@ -7,6 +7,7 @@ import { uploadManager } from "@/services/upload-manager";import {Album02Icon,Home01Icon,+ Link05Icon,Settings01Icon,Upload01Icon,UserGroupIcon,@@ -336,7 +337,7 @@ const NormalNavigationRail: React.FC<...theme.applyStyles("dark", { bgcolor: "#3E3E3E" }),})}/>- {(["albums", "people"] as const).map((item) =>+ {(["albums", "people", "links"] as const).map((item) =>item == "people" && !isMLSupported ? null : (<Tooltip key={item} title={t(item)}><FocusVisibleButton@@ -370,7 +371,11 @@ const NormalNavigationRail: React.FC<><HugeiconsIconicon={- item == "albums" ? Album02Icon : UserGroupIcon+ item == "albums"+ ? Album02Icon+ : item == "links"+ ? Link05Icon+ : UserGroupIcon}size={20}strokeWidth={1.8}diff --git a/web/apps/photos/src/components/gallery/reducer.ts b/web/apps/photos/src/components/gallery/reducer.tsindex e07e0dcf73..582a250b4f 100644--- a/web/apps/photos/src/components/gallery/reducer.ts+++ b/web/apps/photos/src/components/gallery/reducer.ts@@ -44,13 +44,15 @@ import { splitByPredicate } from "ente-utils/array";import { includes } from "ente-utils/type-guards";import { t } from "i18next";import React, { useReducer } from "react";+import { visibleQuickLinks } from "../../utils/quick-links";// TODO: Deprecated(?). Use GalleryView instead. Deprecated if it can be used in// all cases where the bar mode was in use.export type GalleryBarMode =- "albums" | "hidden-albums" | "archive-albums" | "people";+ "albums" | "hidden-albums" | "archive-albums" | "people" | "links";type GalleryView =+ | { type: "links"; selectedLinkID: number | undefined }| { type: "album-overview"; albumFilter: AlbumFilter }| {type: "albums" | "hidden-albums" | "archive-albums";@@ -155,6 +157,8 @@ type GalleryAction =| { type: "showAll" }| { type: "showHidden" }| { type: "showAlbumOverview"; albumFilter: AlbumFilter }+ | { type: "showLinks"; collectionID?: number }+ | { type: "selectLink"; collectionID: number }| { type: "showAlbums" }| { type: "showCollectionSummary"; collectionSummaryID: number | undefined }| { type: "showPeople" }@@ -227,7 +231,7 @@ export const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (hiddenCollections,hiddenCollectionIDs,hiddenFileIDs,- } = deriveHiddenInfo(collections, collectionFiles);+ } = deriveHiddenInfo(collections, collectionFiles, user.id);const archivedCollectionIDs =deriveArchivedCollectionIDs(normalCollections);@@ -339,7 +343,11 @@ export const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (hiddenCollections,hiddenCollectionIDs,hiddenFileIDs,- } = deriveHiddenInfo(collections, state.collectionFiles);+ } = deriveHiddenInfo(+ collections,+ state.collectionFiles,+ state.user!.id,+ );const archivedCollectionIDs =deriveArchivedCollectionIDs(normalCollections);@@ -715,6 +723,20 @@ export const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (isInSearchMode: false,});+ case "showLinks":+ case "selectLink":+ return stateByUpdatingFilteredFiles({+ ...state,+ selectedCollectionSummaryID: undefined,+ extraVisiblePerson: undefined,+ searchSuggestion: undefined,+ searchResults: undefined,+ isRecomputingSearchResults: false,+ pendingSearchSuggestions: [],+ isInSearchMode: false,+ view: { type: "links", selectedLinkID: action.collectionID },+ });+case "showAlbumOverview":return stateByUpdatingFilteredFiles({...state,@@ -936,10 +958,11 @@ const deriveCollectionFiles = (const deriveHiddenInfo = (collections: GalleryState["collections"],collectionFiles: GalleryState["collectionFiles"],+ userID: number,) => {const [hiddenCollections, normalCollections] = splitByPredicate(collections,- isHiddenCollection,+ (collection) => isHiddenCollection(collection, userID),);const hiddenCollectionIDs = new Set(hiddenCollections.map((c) => c.id));return {@@ -1648,6 +1671,18 @@ const stateForUpdatedCollectionFiles = (};const stateByUpdatingFilteredFiles = (state: GalleryState) => {+ if (state.view?.type == "links") {+ const links = visibleQuickLinks(+ state.collections,+ state.user!.id,+ state.hiddenCollectionIDs,+ );+ const previousLinkID = state.view.selectedLinkID;+ const selectedLinkID = links.some(({ id }) => id == previousLinkID)+ ? state.view.selectedLinkID+ : links[0]?.id;+ state = { ...state, view: { type: "links", selectedLinkID } };+ }if (state.isInSearchMode) {const searchFiles = state.searchResults ?? state.filteredFiles;const visibleSearchFiles = suppressSharedFilesSavedByUser(@@ -1682,7 +1717,10 @@ const stateByUpdatingFilteredFiles = (state: GalleryState) => {state.user?.id,);return { ...state, filteredFiles };- } else if (state.view?.type == "album-overview") {+ } else if (+ state.view?.type == "album-overview" ||+ state.view?.type == "links"+ ) {return { ...state, filteredFiles: [] };} else if (state.view?.type == "people") {const filteredFiles = derivePeopleFilteredFiles(diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex cf3d720be1..b8a434742e 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -65,6 +65,7 @@ import {type AlbumFilter,} from "@/utils/album-filters";import type { PeopleSortBy } from "@/utils/people-sort";+import { visibleQuickLinks } from "@/utils/quick-links";import CheckCircleIcon from "@mui/icons-material/CheckCircle";import { Link, Typography } from "@mui/material";import { sessionExpiredDialogAttributes } from "ente-accounts/components/utils/dialog";@@ -78,7 +79,7 @@ import { ensureLocalUser } from "ente-accounts/services/user";import { isDesktop } from "ente-base/app";import type { MiniDialogAttributes } from "ente-base/components/MiniDialog";import { SingleInputDialog } from "ente-base/components/SingleInputDialog";-import { CenteredRow } from "ente-base/components/containers";+import { CenteredFill, CenteredRow } from "ente-base/components/containers";import { TranslucentLoadingOverlay } from "ente-base/components/loaders";import { errorDialogAttributes } from "ente-base/components/utils/dialog";import { useModalVisibility } from "ente-base/components/utils/modal";@@ -447,17 +448,46 @@ const Page: React.FC = () => {? ItemVisibility.hidden: ItemVisibility.visible;const activeCollectionID =- state.view?.type == "people" || state.view?.type == "album-overview"+ state.view?.type == "people" ||+ state.view?.type == "album-overview" ||+ state.view?.type == "links"? undefined: state.view?.activeCollectionSummaryID;const activeCollection =- state.view?.type == "people" || state.view?.type == "album-overview"+ state.view?.type == "people" ||+ state.view?.type == "album-overview" ||+ state.view?.type == "links"? undefined: state.view?.activeCollection;const activeCollectionSummary =- state.view?.type == "people" || state.view?.type == "album-overview"+ state.view?.type == "people" ||+ state.view?.type == "album-overview" ||+ state.view?.type == "links"? undefined: state.view?.activeCollectionSummary;+ const selectedLinkID =+ state.view?.type == "links" ? state.view.selectedLinkID : undefined;+ const quickLinks = useMemo(+ () =>+ visibleQuickLinks(+ state.collections,+ user?.id ?? 0,+ state.hiddenCollectionIDs,+ ),+ [state.collections, user?.id, state.hiddenCollectionIDs],+ );+ const linkSummaries = useMemo(+ () =>+ new Map(+ quickLinks.flatMap((collection) => {+ const summary = normalCollectionSummaries.get(+ collection.id,+ );+ return summary ? [[collection.id, summary] as const] : [];+ }),+ ),+ [quickLinks, normalCollectionSummaries],+ );const activePerson =state.view?.type == "people" ? state.view.activePerson : undefined;const activePersonID = activePerson?.id;@@ -563,11 +593,13 @@ const Page: React.FC = () => {selectedFilesInView.length === filteredFiles.length;const barCollectionSummaries =- barMode == "hidden-albums"- ? state.hiddenCollectionSummaries- : barMode == "archive-albums"- ? state.archivedCollectionSummaries- : state.normalCollectionSummaries;+ barMode == "links"+ ? linkSummaries+ : barMode == "hidden-albums"+ ? state.hiddenCollectionSummaries+ : barMode == "archive-albums"+ ? state.archivedCollectionSummaries+ : state.normalCollectionSummaries;useEffect(() => {setAlbumSearchQuery("");@@ -1574,6 +1606,12 @@ const Page: React.FC = () => {};const handleChangeBarMode = (mode: GalleryBarMode) => {+ if (mode == "links") {+ setCleanupView(undefined);+ clearSelection();+ dispatch({ type: "showLinks" });+ return true;+ }if (mode == "people") {return handleShowPeople();}@@ -2106,7 +2144,9 @@ const Page: React.FC = () => {// TODO: These are incorrect assertions, the types of the// component need to be updated.activeCollection: activeCollection!,- activeCollectionID: activeCollectionID!,+ activeCollectionID: (barMode == "links"+ ? selectedLinkID+ : activeCollectionID)!,activePerson,albumFilter,albumSearchQuery,@@ -2142,7 +2182,13 @@ const Page: React.FC = () => {: undefined) ?? [],setBlockingLoad,setActiveCollectionID:- handleShowCollectionSummaryWithID,+ barMode == "links"+ ? (collectionID) =>+ dispatch({+ type: "selectLink",+ collectionID,+ })+ : handleShowCollectionSummaryWithID,hasActiveFileSelection,onRemotePull: remotePull,onSelectPerson: handleSelectPerson,@@ -2197,6 +2243,12 @@ const Page: React.FC = () => {<DuplicatesView onRemoteFilesPull={remoteFilesPull} />) : cleanupView === "large-files" ? (<LargeFilesView onRemoteFilesPull={remoteFilesPull} />+ ) : !isInSearchMode && barMode == "links" ? (+ <CenteredFill>+ <Typography variant="h3">+ {t("nothing_here")}+ </Typography>+ </CenteredFill>) : !isInSearchMode &&!isFirstLoad &&!state.collectionFiles.length &&diff --git a/web/apps/photos/src/utils/album-filters.ts b/web/apps/photos/src/utils/album-filters.tsindex 96065bf754..cf297bb716 100644--- a/web/apps/photos/src/utils/album-filters.ts+++ b/web/apps/photos/src/utils/album-filters.ts@@ -4,8 +4,7 @@ import {} from "ente-new/photos/services/collection-summary";import { t } from "i18next";-export type AlbumFilter =- "ente" | "shared" | "received" | "links" | "empty-albums";+export type AlbumFilter = "ente" | "shared" | "received" | "empty-albums";export const albumFilters: {value: AlbumFilter;@@ -23,11 +22,6 @@ export const albumFilters: {label: () => t("received_albums_label"),title: () => t("received_albums_title"),},- {- value: "links",- label: () => t("links_albums_label"),- title: () => t("links_albums_title"),- },{value: "empty-albums",label: () => t("empty_albums"),@@ -61,8 +55,6 @@ export const matchesAlbumFilter = (!cs.attributes.has("archived") &&cs.attributes.has("sharedIncoming"));- case "links":- return cs.attributes.has("quickLink");case "empty-albums":return isBulkDeletableEmptyAlbum(cs);}diff --git a/web/apps/photos/src/utils/photoFrame/index.ts b/web/apps/photos/src/utils/photoFrame/index.tsindex d24038b3da..8bc71857e6 100644--- a/web/apps/photos/src/utils/photoFrame/index.ts+++ b/web/apps/photos/src/utils/photoFrame/index.ts@@ -118,6 +118,17 @@ const createSelectedAndContext = (activePersonID: string | undefined,selected: SelectedState,) => {+ if (mode == "links") {+ return {+ selected: {+ count: 0,+ ownCount: 0,+ collectionID: 0,+ context: undefined,+ },+ newContext: undefined,+ };+ }if (!mode) {// Retain older behavior for non-gallery call sites.if (selected.collectionID !== activeCollectionID) {diff --git a/web/apps/photos/src/utils/quick-links.ts b/web/apps/photos/src/utils/quick-links.tsnew file mode 100644index 0000000000..3a0c810930--- /dev/null+++ b/web/apps/photos/src/utils/quick-links.ts@@ -0,0 +1,19 @@+import { CollectionSubType, type Collection } from "ente-media/collection";++/** Quick links managed here must never expose collections in Hidden. */+export const visibleQuickLinks = (+ collections: Collection[],+ userID: number,+ hiddenCollectionIDs: ReadonlySet<number>,+) =>+ collections+ .filter(+ (collection) =>+ collection.owner.id == userID &&+ collection.magicMetadata?.data.subType ==+ CollectionSubType.quicklink &&+ !collection.sharees.length &&+ collection.publicURLs.length > 0 &&+ !hiddenCollectionIDs.has(collection.id),+ )+ .sort((a, b) => b.updationTime - a.updationTime || b.id - a.id);diff --git a/web/apps/photos/tests/album-filters.test.ts b/web/apps/photos/tests/album-filters.test.tsindex 570160f515..66ff147112 100644--- a/web/apps/photos/tests/album-filters.test.ts+++ b/web/apps/photos/tests/album-filters.test.ts@@ -85,7 +85,9 @@ describe("album filters shared by the dialog and sidebar", () => {expect(ids("ente")).toEqual([1, 2, 3, 4]);expect(ids("shared")).toEqual([2, 4]);expect(ids("received")).toEqual([3]);- expect(ids("links")).toEqual([5]);+ expect(+ visibleAlbumFilters(albums).map(({ value }) => value),+ ).not.toContain("links");expect(albums.map(({ id }) => id)).toEqual([1, 2, 3, 4, 5]);});@@ -130,7 +132,6 @@ describe("album filters shared by the dialog and sidebar", () => {"ente","shared","received",- "links","empty-albums",]);expect(visibleAlbumFilters([]).map(({ value }) => value)).toEqual([diff --git a/web/apps/photos/tests/quick-links.test.ts b/web/apps/photos/tests/quick-links.test.tsnew file mode 100644index 0000000000..8f95eae4b8--- /dev/null+++ b/web/apps/photos/tests/quick-links.test.ts@@ -0,0 +1,156 @@+import type { LocalUser } from "ente-accounts/services/user";+import { CollectionSubType, type Collection } from "ente-media/collection";+import { ItemVisibility } from "ente-media/file-metadata";+import { describe, expect, test } from "vitest";+import {+ galleryReducer,+ initialGalleryState,+} from "../src/components/gallery/reducer";+import { visibleQuickLinks } from "../src/utils/quick-links";++const link = (id: number, overrides: Partial<Collection> = {}): Collection => ({+ id,+ name: `Link ${id}`,+ type: "album",+ owner: { id: 1 },+ key: "test-key",+ sharees: [],+ updationTime: id,+ magicMetadata: {+ version: 1,+ count: 1,+ data: { subType: CollectionSubType.quicklink },+ },+ publicURLs: [+ {+ url: `https://albums.ente.com/?t=${id}`,+ validTill: 0,+ deviceLimit: 0,+ enableDownload: true,+ enableCollect: false,+ enableComment: false,+ enableJoin: false,+ passwordEnabled: false,+ },+ ],+ ...overrides,+});+const mounted = (collections = [link(1), link(2)]) =>+ galleryReducer(initialGalleryState, {+ type: "mount",+ user: { id: 1 } as LocalUser,+ familyData: undefined,+ collections,+ collectionFiles: [],+ trashItems: [],+ });++describe("quick link membership", () => {+ test("lists owned public quick links, including expired and empty links", () => {+ const expired = link(2);+ expired.publicURLs[0]!.validTill = 1;+ const collections = [+ link(1),+ expired,+ link(3, { owner: { id: 2 } }),+ link(4, { magicMetadata: undefined }),+ link(5, { sharees: [{ id: 2 }] }),+ link(6, { publicURLs: [] }),+ link(7),+ ];+ expect(+ visibleQuickLinks(collections, 1, new Set([7])).map(({ id }) => id),+ ).toEqual([2, 1]);+ expect(collections.map(({ id }) => id)).toEqual([1, 2, 3, 4, 5, 6, 7]);+ });+});++describe("Links navigation", () => {+ test("selects the latest link and clears stale photo search state", () => {+ const state = galleryReducer(+ {+ ...mounted(),+ isInSearchMode: true,+ isRecomputingSearchResults: true,+ searchResults: [],+ },+ { type: "showLinks" },+ );+ expect(state.view).toEqual({ type: "links", selectedLinkID: 2 });+ expect(state.selectedCollectionSummaryID).toBeUndefined();+ expect(state.filteredFiles).toEqual([]);+ expect(state.searchResults).toBeUndefined();+ expect(state.isInSearchMode).toBe(false);+ expect(state.isRecomputingSearchResults).toBe(false);+ });++ test("preserves selection when the list refreshes", () => {+ let state = galleryReducer(mounted(), {+ type: "selectLink",+ collectionID: 1,+ });+ state = galleryReducer(state, {+ type: "setCollections",+ collections: [link(1, { name: "Updated" }), link(2), link(3)],+ });+ expect(state.view).toEqual({ type: "links", selectedLinkID: 1 });+ expect(state.normalCollectionSummaries.get(1)?.name).toBe("Updated");+ });++ test.each(["removed", "hidden", "unlinked", "shared"])(+ "reconciles a selected link that becomes %s",+ (change) => {+ let state = galleryReducer(mounted(), {+ type: "selectLink",+ collectionID: 2,+ });+ const updated = link(2);+ if (change == "hidden")+ updated.magicMetadata!.data.visibility = ItemVisibility.hidden;+ if (change == "unlinked") updated.publicURLs = [];+ if (change == "shared") updated.sharees = [{ id: 2 }];+ state = galleryReducer(state, {+ type: "setCollections",+ collections:+ change == "removed" ? [link(1)] : [link(1), updated],+ });+ expect(state.view).toEqual({ type: "links", selectedLinkID: 1 });+ },+ );++ test("keeps an empty Links view after removing the final link", () => {+ let state = galleryReducer(mounted([link(1)]), { type: "showLinks" });+ state = galleryReducer(state, {+ type: "setCollections",+ collections: [],+ });+ expect(state.view).toEqual({+ type: "links",+ selectedLinkID: undefined,+ });+ state = galleryReducer(state, {+ type: "setCollections",+ collections: [link(3)],+ });+ expect(state.view).toEqual({ type: "links", selectedLinkID: 3 });+ });++ test("does not open a hidden link by an explicit ID", () => {+ const hidden = link(3);+ hidden.magicMetadata!.data.visibility = ItemVisibility.hidden;+ const state = galleryReducer(mounted([link(1), hidden]), {+ type: "selectLink",+ collectionID: 3,+ });+ expect(state.view).toEqual({ type: "links", selectedLinkID: 1 });+ });++ test("supports returning to Home and People", () => {+ let state = galleryReducer(mounted(), { type: "showLinks" });+ state = galleryReducer(state, { type: "showAll" });+ expect(state.view?.type).toBe("albums");+ state = galleryReducer(state, { type: "showLinks" });+ state = galleryReducer(state, { type: "showPeople" });+ expect(state.view?.type).toBe("people");+ });+});diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.jsonindex e2ece4511a..ce964e8811 100644--- a/web/packages/base/locales/en-US/translation.json+++ b/web/packages/base/locales/en-US/translation.json@@ -779,6 +779,8 @@"filter_albums": "Filter albums","shared_albums_label": "Shared","received_albums_label": "Received",+ "links": "Links",+ "search_links": "Search links","links_albums_label": "Links","empty_albums": "Empty","shared_albums_title": "Shared Albums",