From 0f0375a67e7091a4144a1f0560008deaa3136416 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 21 Jun 2023 15:18:00 -0500 Subject: [PATCH] feat(web): add album to search result (#2900) * Add album to search result page * Update web/src/routes/(user)/search/+page.svelte Co-authored-by: Thomas <9749173+uhthomas@users.noreply.github.com> * Update web/src/routes/(user)/search/+page.svelte Co-authored-by: Thomas <9749173+uhthomas@users.noreply.github.com> * change font weight * hide context menu in this view --------- Co-authored-by: Thomas <9749173+uhthomas@users.noreply.github.com> --- .../components/album-page/album-card.svelte | 14 +++++--- .../components/album-page/album-viewer.svelte | 4 +++ .../search-bar/search-bar.svelte | 2 +- web/src/routes/(user)/search/+page.svelte | 34 ++++++++++++++++++- web/src/routes/(user)/sharing/+page.svelte | 2 +- 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/web/src/lib/components/album-page/album-card.svelte b/web/src/lib/components/album-page/album-card.svelte index 5900abb030..17ec886761 100644 --- a/web/src/lib/components/album-page/album-card.svelte +++ b/web/src/lib/components/album-page/album-card.svelte @@ -10,6 +10,8 @@ export let album: AlbumResponseDto; export let isSharingView = false; export let user: UserResponseDto; + export let showItemCount = true; + export let showContextMenu = true; $: imageData = album.albumThumbnailAssetId ? api.getAssetThumbnailUrl(album.albumThumbnailAssetId, ThumbnailFormat.Webp) @@ -63,7 +65,7 @@ data-testid="album-card" > - {#if !isSharingView} + {#if showContextMenu}
-

- {album.assetCount.toLocaleString($locale)} - {album.assetCount == 1 ? `item` : `items`} -

+ {#if showItemCount} +

+ {album.assetCount.toLocaleString($locale)} + {album.assetCount == 1 ? `item` : `items`} +

+ {/if} {#if isSharingView || album.shared}

ยท

diff --git a/web/src/lib/components/album-page/album-viewer.svelte b/web/src/lib/components/album-page/album-viewer.svelte index aa4091e03e..2223fcbd2e 100644 --- a/web/src/lib/components/album-page/album-viewer.svelte +++ b/web/src/lib/components/album-page/album-viewer.svelte @@ -89,6 +89,10 @@ if (from?.url.pathname === '/sharing' && album.sharedUsers.length === 0) { isCreatingSharedAlbum = true; } + + if (from?.route.id === '/(user)/search') { + backUrl = from.url.href; + } }); const albumDateFormat: Intl.DateTimeFormatOptions = { diff --git a/web/src/lib/components/shared-components/search-bar/search-bar.svelte b/web/src/lib/components/shared-components/search-bar/search-bar.svelte index 61e6c3e627..8726da558a 100644 --- a/web/src/lib/components/shared-components/search-bar/search-bar.svelte +++ b/web/src/lib/components/shared-components/search-bar/search-bar.svelte @@ -94,7 +94,7 @@

Smart search is enabled by default, to search for metadata use the syntax m:your-search-term

diff --git a/web/src/routes/(user)/search/+page.svelte b/web/src/routes/(user)/search/+page.svelte index 0a7b699bfc..ce7585d715 100644 --- a/web/src/routes/(user)/search/+page.svelte +++ b/web/src/routes/(user)/search/+page.svelte @@ -20,19 +20,27 @@ import type { PageData } from './$types'; import SelectAll from 'svelte-material-icons/SelectAll.svelte'; import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte'; + import { AppRoute } from '$lib/constants'; + import AlbumCard from '$lib/components/album-page/album-card.svelte'; + import { flip } from 'svelte/animate'; export let data: PageData; // The GalleryViewer pushes it's own history state, which causes weird // behavior for history.back(). To prevent that we store the previous page // manually and navigate back to that. - let previousRoute = '/explore'; + let previousRoute = AppRoute.EXPLORE as string; + $: albums = data.results.albums.items; afterNavigate(({ from }) => { // Prevent setting previousRoute to the current page. if (from && from.route.id !== $page.route.id) { previousRoute = from.url.href; } + + if (from?.route.id === '/(user)/albums/[albumId]') { + previousRoute = AppRoute.EXPLORE; + } }); $: term = $page.url.searchParams.get('q') || data.term || ''; @@ -79,6 +87,30 @@
+ {#if albums.length} +
+
ALBUMS
+
+ {#each albums as album (album.id)} + + + + {/each} +
+ +
PHOTOS & VIDEOS
+
+ {/if}
{#if data.results?.assets?.items.length > 0}
diff --git a/web/src/routes/(user)/sharing/+page.svelte b/web/src/routes/(user)/sharing/+page.svelte index b783d6594f..a2327d271c 100644 --- a/web/src/routes/(user)/sharing/+page.svelte +++ b/web/src/routes/(user)/sharing/+page.svelte @@ -100,7 +100,7 @@ href={`albums/${album.id}`} animate:flip={{ duration: 200 }} > - + {/each}