High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix(web): remove query parameter when clearing search (#8817)
martin7ce1662b0522
diff --git a/web/src/lib/utils/navigation.ts b/web/src/lib/utils/navigation.tsindex 4dfd92ca78..a91c4a739f 100644--- a/web/src/lib/utils/navigation.ts+++ b/web/src/lib/utils/navigation.ts@@ -1,3 +1,12 @@+import { goto } from '$app/navigation';+export const isExternalUrl = (url: string): boolean => {return new URL(url, window.location.href).origin !== window.location.origin;};++export const clearQueryParam = async (queryParam: string, url: URL) => {+ if (url.searchParams.has(queryParam)) {+ url.searchParams.delete(queryParam);+ await goto(url);+ }+};diff --git a/web/src/routes/(user)/people/+page.svelte b/web/src/routes/(user)/people/+page.svelteindex c313650fa7..6172c76c3a 100644--- a/web/src/routes/(user)/people/+page.svelte+++ b/web/src/routes/(user)/people/+page.svelte@@ -40,6 +40,7 @@import { onMount } from 'svelte';import type { PageData } from './$types';import { locale } from '$lib/stores/preferences.store';+ import { clearQueryParam } from '$lib/utils/navigation';export let data: PageData;@@ -279,10 +280,7 @@const handleSearchPeople = async (force: boolean) => {if (searchName === '') {- if ($page.url.searchParams.has(QueryParameter.SEARCHED_PEOPLE)) {- $page.url.searchParams.delete(QueryParameter.SEARCHED_PEOPLE);- await goto($page.url);- }+ await clearQueryParam(QueryParameter.SEARCHED_PEOPLE, $page.url);return;}if (!force && people.length < maximumLengthSearchPeople && searchName.startsWith(searchWord)) {@@ -393,6 +391,11 @@handleError(error, 'Unable to save name');}};++ const onResetSearchBar = async () => {+ searchedPeople = [];+ await clearQueryParam(QueryParameter.SEARCHED_PEOPLE, $page.url);+ };</script><svelte:window bind:innerHeight use:shortcut={{ shortcut: { key: 'Escape' }, onShortcut: handleCloseClick }} />@@ -421,9 +424,7 @@bind:name={searchName}isSearching={isSearchingPeople}placeholder="Search people"- on:reset={() => {- searchedPeople = [];- }}+ on:reset={onResetSearchBar}on:search={({ detail }) => handleSearch(detail.force ?? false)}/></div>