refactor(web) open api client (#7103)
* refactor: person api * refactor: shared link and others
This commit is contained in:
@@ -26,9 +26,8 @@
|
||||
import { preventRaceConditionSearchBar } from '$lib/stores/search.store';
|
||||
import { shouldIgnoreShortcut } from '$lib/utils/shortcut';
|
||||
import { mdiArrowLeft, mdiDotsVertical, mdiImageOffOutline, mdiPlus, mdiSelectAll } from '@mdi/js';
|
||||
import type { AssetResponseDto, SearchResponseDto } from '@immich/sdk';
|
||||
import { search, type AssetResponseDto, type SearchResponseDto } from '@immich/sdk';
|
||||
import { authenticate } from '$lib/utils/auth';
|
||||
import { api } from '@api';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
@@ -120,20 +119,20 @@
|
||||
await authenticate();
|
||||
let results: SearchResponseDto | null = null;
|
||||
$page.url.searchParams.set('page', curPage.toString());
|
||||
const res = await api.searchApi.search({}, { params: $page.url.searchParams });
|
||||
const res = await search({ ...$page.url.searchParams });
|
||||
if (searchResultAssets) {
|
||||
searchResultAssets.push(...res.data.assets.items);
|
||||
searchResultAssets.push(...res.assets.items);
|
||||
} else {
|
||||
searchResultAssets = res.data.assets.items;
|
||||
searchResultAssets = res.assets.items;
|
||||
}
|
||||
|
||||
const assets = {
|
||||
...res.data.assets,
|
||||
...res.assets,
|
||||
items: searchResultAssets,
|
||||
};
|
||||
results = {
|
||||
assets,
|
||||
albums: res.data.albums,
|
||||
albums: res.albums,
|
||||
};
|
||||
|
||||
data.results = results;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { authenticate } from '$lib/utils/auth';
|
||||
import { type AssetResponseDto, type SearchResponseDto, api } from '@api';
|
||||
import { search, type AssetResponseDto, type SearchResponseDto } from '@immich/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
import { QueryParameter } from '$lib/constants';
|
||||
|
||||
@@ -10,17 +10,17 @@ export const load = (async (data) => {
|
||||
url.searchParams.get(QueryParameter.SEARCH_TERM) || url.searchParams.get(QueryParameter.QUERY) || undefined;
|
||||
let results: SearchResponseDto | null = null;
|
||||
if (term) {
|
||||
const res = await api.searchApi.search({}, { params: data.url.searchParams });
|
||||
const response = await search({ ...data.url.searchParams });
|
||||
let items: AssetResponseDto[] = (data as unknown as { results: SearchResponseDto }).results?.assets.items;
|
||||
if (items) {
|
||||
items.push(...res.data.assets.items);
|
||||
items.push(...response.assets.items);
|
||||
} else {
|
||||
items = res.data.assets.items;
|
||||
items = response.assets.items;
|
||||
}
|
||||
const assets = { ...res.data.assets, items };
|
||||
const assets = { ...response.assets, items };
|
||||
results = {
|
||||
assets,
|
||||
albums: res.data.albums,
|
||||
albums: response.albums,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user