mirror of
https://github.com/immich-app/immich.git
synced 2025-06-05 06:35:07 -04:00
fix(web): search page navigation and asset select (#2191)
This commit is contained in:
parent
d7c1005a50
commit
b03ce897c7
@ -9,6 +9,7 @@
|
|||||||
export let assets: AssetResponseDto[];
|
export let assets: AssetResponseDto[];
|
||||||
export let sharedLink: SharedLinkResponseDto | undefined = undefined;
|
export let sharedLink: SharedLinkResponseDto | undefined = undefined;
|
||||||
export let selectedAssets: Set<AssetResponseDto> = new Set();
|
export let selectedAssets: Set<AssetResponseDto> = new Set();
|
||||||
|
export let disableAssetSelect = false;
|
||||||
|
|
||||||
let isShowAssetViewer = false;
|
let isShowAssetViewer = false;
|
||||||
|
|
||||||
@ -96,6 +97,7 @@
|
|||||||
<Thumbnail
|
<Thumbnail
|
||||||
{asset}
|
{asset}
|
||||||
{thumbnailSize}
|
{thumbnailSize}
|
||||||
|
readonly={disableAssetSelect}
|
||||||
publicSharedKey={sharedLink?.key}
|
publicSharedKey={sharedLink?.key}
|
||||||
format={assets.length < 7 ? ThumbnailFormat.Jpeg : ThumbnailFormat.Webp}
|
format={assets.length < 7 ? ThumbnailFormat.Jpeg : ThumbnailFormat.Webp}
|
||||||
on:click={(e) => (isMultiSelectionMode ? selectAssetHandler(e) : viewAssetHandler(e))}
|
on:click={(e) => (isMultiSelectionMode ? selectAssetHandler(e) : viewAssetHandler(e))}
|
||||||
|
@ -8,10 +8,6 @@
|
|||||||
export let value = '';
|
export let value = '';
|
||||||
export let grayTheme: boolean;
|
export let grayTheme: boolean;
|
||||||
|
|
||||||
// Replace state to immediately go back to previous page, instead
|
|
||||||
// of having to go through every search query.
|
|
||||||
export let replaceHistoryState = false;
|
|
||||||
|
|
||||||
let showBigSearchBar = false;
|
let showBigSearchBar = false;
|
||||||
$: showClearIcon = value.length > 0;
|
$: showClearIcon = value.length > 0;
|
||||||
|
|
||||||
@ -33,7 +29,7 @@
|
|||||||
clip: clipSearch
|
clip: clipSearch
|
||||||
});
|
});
|
||||||
|
|
||||||
goto(`${AppRoute.SEARCH}?${params}`, { replaceState: replaceHistoryState });
|
goto(`${AppRoute.SEARCH}?${params}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveSearchTerm = (saveValue: string) => {
|
const saveSearchTerm = (saveValue: string) => {
|
||||||
|
@ -6,15 +6,29 @@
|
|||||||
import ArrowLeft from 'svelte-material-icons/ArrowLeft.svelte';
|
import ArrowLeft from 'svelte-material-icons/ArrowLeft.svelte';
|
||||||
import ImageOffOutline from 'svelte-material-icons/ImageOffOutline.svelte';
|
import ImageOffOutline from 'svelte-material-icons/ImageOffOutline.svelte';
|
||||||
import SearchBar from '$lib/components/shared-components/search-bar/search-bar.svelte';
|
import SearchBar from '$lib/components/shared-components/search-bar/search-bar.svelte';
|
||||||
|
import { afterNavigate, goto } from '$app/navigation';
|
||||||
|
|
||||||
export let data: PageData;
|
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';
|
||||||
|
|
||||||
|
afterNavigate(({ from }) => {
|
||||||
|
// Prevent setting previousRoute to the current page.
|
||||||
|
if (from && from.route.id !== $page.route.id) {
|
||||||
|
previousRoute = from.url.href;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$: term = $page.url.searchParams.get('q') || data.term || '';
|
$: term = $page.url.searchParams.get('q') || data.term || '';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<ControlAppBar on:close-button-click={() => history.back()} backIcon={ArrowLeft}>
|
<ControlAppBar on:close-button-click={() => goto(previousRoute)} backIcon={ArrowLeft}>
|
||||||
<div class="w-full max-w-2xl flex-1 pl-4">
|
<div class="w-full max-w-2xl flex-1 pl-4">
|
||||||
<SearchBar grayTheme={false} value={term} replaceHistoryState={true} />
|
<SearchBar grayTheme={false} value={term} />
|
||||||
</div>
|
</div>
|
||||||
</ControlAppBar>
|
</ControlAppBar>
|
||||||
</section>
|
</section>
|
||||||
@ -24,7 +38,7 @@
|
|||||||
<section id="search-content" class="relative bg-immich-bg dark:bg-immich-dark-bg">
|
<section id="search-content" class="relative bg-immich-bg dark:bg-immich-dark-bg">
|
||||||
{#if data.results?.assets?.items.length > 0}
|
{#if data.results?.assets?.items.length > 0}
|
||||||
<div class="pl-4">
|
<div class="pl-4">
|
||||||
<GalleryViewer assets={data.results.assets.items} />
|
<GalleryViewer assets={data.results.assets.items} disableAssetSelect />
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div
|
<div
|
||||||
|
Loading…
x
Reference in New Issue
Block a user