Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): broken links to places search #7208

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import SearchHistoryBox from './search-history-box.svelte';
import SearchFilterBox from './search-filter-box.svelte';
import type { MetadataSearchDto, SmartSearchDto } from '@immich/sdk';
import { getMetadataSearchQuery } from '$lib/utils/metadata-search';
export let value = '';
export let grayTheme: boolean;

Expand All @@ -24,15 +25,13 @@
$: showClearIcon = value.length > 0;

const onSearch = (payload: SmartSearchDto | MetadataSearchDto) => {
const parameters = new URLSearchParams({
query: JSON.stringify(payload),
});
const params = getMetadataSearchQuery(payload);

showHistory = false;
showFilter = false;
$isSearchEnabled = false;
$searchQuery = payload;
goto(`${AppRoute.SEARCH}?${parameters}`, { invalidateAll: true });
goto(`${AppRoute.SEARCH}?${params}`, { invalidateAll: true });
};

const clearSearchTerm = (searchTerm: string) => {
Expand Down
9 changes: 9 additions & 0 deletions web/src/lib/utils/metadata-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { QueryParameter } from '$lib/constants';
import type { MetadataSearchDto } from '@immich/sdk';

export function getMetadataSearchQuery(metadata: MetadataSearchDto) {
const searchParams = new URLSearchParams({
[QueryParameter.QUERY]: JSON.stringify(metadata),
});
return searchParams.toString();
}
3 changes: 2 additions & 1 deletion web/src/routes/(user)/explore/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { getPeopleThumbnailUrl } from '$lib/utils';
import type { SearchExploreResponseDto } from '@immich/sdk';
import type { PageData } from './$types';
import { getMetadataSearchQuery } from '$lib/utils/metadata-search';

export let data: PageData;

Expand Down Expand Up @@ -83,7 +84,7 @@
</div>
<div class="flex flex-row flex-wrap gap-4">
{#each places as item (item.data.id)}
<a class="relative" href="{AppRoute.SEARCH}?q={item.value}" draggable="false">
<a class="relative" href="{AppRoute.SEARCH}?{getMetadataSearchQuery({ city: item.value })}" draggable="false">
<div
class="flex w-[calc((100vw-(72px+5rem))/2)] max-w-[156px] justify-center overflow-hidden rounded-xl brightness-75 filter"
>
Expand Down
3 changes: 2 additions & 1 deletion web/src/routes/(user)/places/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import type { SearchExploreResponseDto } from '@immich/sdk';
import { mdiMapMarkerOff } from '@mdi/js';
import type { PageData } from './$types';
import { getMetadataSearchQuery } from '$lib/utils/metadata-search';

export let data: PageData;

Expand All @@ -27,7 +28,7 @@
{#if hasPlaces}
<div class="flex flex-row flex-wrap gap-4">
{#each places as item (item.data.id)}
<a class="relative" href="{AppRoute.SEARCH}?q={item.value}" draggable="false">
<a class="relative" href="{AppRoute.SEARCH}?{getMetadataSearchQuery({ city: item.value })}" draggable="false">
<div
class="flex w-[calc((100vw-(72px+5rem))/2)] max-w-[156px] justify-center overflow-hidden rounded-xl brightness-75 filter"
>
Expand Down
Loading