refactor(web) open api client (#7103)
* refactor: person api * refactor: shared link and others
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
import Thumbnail from '$lib/components/assets/thumbnail/thumbnail.svelte';
|
||||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||
import { AppRoute } from '$lib/constants';
|
||||
import { type SearchExploreResponseDto, api } from '@api';
|
||||
import { getPeopleThumbnailUrl } from '$lib/utils';
|
||||
import type { SearchExploreResponseDto } from '@immich/sdk';
|
||||
import type { PageData } from './$types';
|
||||
|
||||
export let data: PageData;
|
||||
@@ -58,7 +59,7 @@
|
||||
<ImageThumbnail
|
||||
circle
|
||||
shadow
|
||||
url={api.getPeopleThumbnailUrl(person.id)}
|
||||
url={getPeopleThumbnailUrl(person.id)}
|
||||
altText={person.name}
|
||||
widthStyle="100%"
|
||||
/>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { authenticate } from '$lib/utils/auth';
|
||||
import { api } from '@api';
|
||||
import { getAllPeople, getExploreData } from '@immich/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load = (async () => {
|
||||
await authenticate();
|
||||
const { data: items } = await api.searchApi.getExploreData();
|
||||
const { data: response } = await api.personApi.getAllPeople({ withHidden: false });
|
||||
const [items, response] = await Promise.all([getExploreData(), getAllPeople({ withHidden: false })]);
|
||||
|
||||
return {
|
||||
items,
|
||||
response,
|
||||
|
||||
@@ -3,18 +3,19 @@
|
||||
import AssetViewer from '$lib/components/asset-viewer/asset-viewer.svelte';
|
||||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||
import MapSettingsModal from '$lib/components/map-page/map-settings-modal.svelte';
|
||||
import Map from '$lib/components/shared-components/map/map.svelte';
|
||||
import Portal from '$lib/components/shared-components/portal/portal.svelte';
|
||||
import { AppRoute } from '$lib/constants';
|
||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||
import type { MapSettings } from '$lib/stores/preferences.store';
|
||||
import { mapSettings } from '$lib/stores/preferences.store';
|
||||
import { featureFlags } from '$lib/stores/server-config.store';
|
||||
import { type MapMarkerResponseDto, api } from '@api';
|
||||
import { type MapMarkerResponseDto } from '@api';
|
||||
import { getMapMarkers } from '@immich/sdk';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import { DateTime, Duration } from 'luxon';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import type { PageData } from './$types';
|
||||
import Map from '$lib/components/shared-components/map/map.svelte';
|
||||
import type { MapSettings } from '$lib/stores/preferences.store';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
@@ -49,7 +50,7 @@
|
||||
const { includeArchived, onlyFavorites } = $mapSettings;
|
||||
const { fileCreatedAfter, fileCreatedBefore } = getFileCreatedDates();
|
||||
|
||||
const { data } = await api.assetApi.getMapMarkers(
|
||||
return await getMapMarkers(
|
||||
{
|
||||
isArchived: includeArchived && undefined,
|
||||
isFavorite: onlyFavorites || undefined,
|
||||
@@ -60,7 +61,6 @@
|
||||
signal: abortController.signal,
|
||||
},
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
function getFileCreatedDates() {
|
||||
|
||||
@@ -1,36 +1,38 @@
|
||||
<script lang="ts">
|
||||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||
import type { PageData } from './$types';
|
||||
import PeopleCard from '$lib/components/faces-page/people-card.svelte';
|
||||
import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte';
|
||||
import Button from '$lib/components/elements/buttons/button.svelte';
|
||||
import { api, type PeopleUpdateItem, type PersonResponseDto } from '@api';
|
||||
import { browser } from '$app/environment';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import ImageThumbnail from '$lib/components/assets/thumbnail/image-thumbnail.svelte';
|
||||
import Button from '$lib/components/elements/buttons/button.svelte';
|
||||
import IconButton from '$lib/components/elements/buttons/icon-button.svelte';
|
||||
import Icon from '$lib/components/elements/icon.svelte';
|
||||
import MergeSuggestionModal from '$lib/components/faces-page/merge-suggestion-modal.svelte';
|
||||
import PeopleCard from '$lib/components/faces-page/people-card.svelte';
|
||||
import SearchBar from '$lib/components/faces-page/search-bar.svelte';
|
||||
import SetBirthDateModal from '$lib/components/faces-page/set-birth-date-modal.svelte';
|
||||
import ShowHide from '$lib/components/faces-page/show-hide.svelte';
|
||||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||
import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte';
|
||||
import {
|
||||
notificationController,
|
||||
NotificationType,
|
||||
} from '$lib/components/shared-components/notification/notification';
|
||||
import {
|
||||
ActionQueryParameterValue,
|
||||
AppRoute,
|
||||
QueryParameter,
|
||||
maximumLengthSearchPeople,
|
||||
QueryParameter,
|
||||
timeBeforeShowLoadingSpinner,
|
||||
} from '$lib/constants';
|
||||
import { getPeopleThumbnailUrl } from '$lib/utils';
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
import {
|
||||
NotificationType,
|
||||
notificationController,
|
||||
} from '$lib/components/shared-components/notification/notification';
|
||||
import ShowHide from '$lib/components/faces-page/show-hide.svelte';
|
||||
import IconButton from '$lib/components/elements/buttons/icon-button.svelte';
|
||||
import ImageThumbnail from '$lib/components/assets/thumbnail/image-thumbnail.svelte';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import { browser } from '$app/environment';
|
||||
import MergeSuggestionModal from '$lib/components/faces-page/merge-suggestion-modal.svelte';
|
||||
import SetBirthDateModal from '$lib/components/faces-page/set-birth-date-modal.svelte';
|
||||
import { shouldIgnoreShortcut } from '$lib/utils/shortcut';
|
||||
import { mdiAccountOff, mdiEyeOutline } from '@mdi/js';
|
||||
import Icon from '$lib/components/elements/icon.svelte';
|
||||
import { searchNameLocal } from '$lib/utils/person';
|
||||
import SearchBar from '$lib/components/faces-page/search-bar.svelte';
|
||||
import { page } from '$app/stores';
|
||||
import { shouldIgnoreShortcut } from '$lib/utils/shortcut';
|
||||
import { type PeopleUpdateItem, type PersonResponseDto } from '@api';
|
||||
import { getPerson, mergePerson, searchPerson, updatePeople, updatePerson } from '@immich/sdk';
|
||||
import { mdiAccountOff, mdiEyeOutline } from '@mdi/js';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import type { PageData } from './$types';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
@@ -75,7 +77,7 @@
|
||||
const getSearchedPeople = $page.url.searchParams.get(QueryParameter.SEARCHED_PEOPLE);
|
||||
if (getSearchedPeople) {
|
||||
searchName = getSearchedPeople;
|
||||
searchPeople(true);
|
||||
handleSearchPeople(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -100,7 +102,7 @@
|
||||
const handleSearch = (force: boolean) => {
|
||||
$page.url.searchParams.set(QueryParameter.SEARCHED_PEOPLE, searchName);
|
||||
goto($page.url);
|
||||
searchPeople(force);
|
||||
handleSearchPeople(force);
|
||||
};
|
||||
|
||||
const handleCloseClick = () => {
|
||||
@@ -150,7 +152,7 @@
|
||||
}
|
||||
|
||||
if (changed.length > 0) {
|
||||
const { data: results } = await api.personApi.updatePeople({
|
||||
const results = await updatePeople({
|
||||
peopleUpdateDto: { people: changed },
|
||||
});
|
||||
const count = results.filter(({ success }) => success).length;
|
||||
@@ -187,12 +189,12 @@
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await api.personApi.mergePerson({
|
||||
await mergePerson({
|
||||
id: personToBeMergedIn.id,
|
||||
mergePersonDto: { ids: [personToMerge.id] },
|
||||
});
|
||||
|
||||
const { data: mergedPerson } = await api.personApi.getPerson({ id: personToBeMergedIn.id });
|
||||
const mergedPerson = await getPerson({ id: personToBeMergedIn.id });
|
||||
|
||||
countVisiblePeople--;
|
||||
people = people.filter((person: PersonResponseDto) => person.id !== personToMerge.id);
|
||||
@@ -213,7 +215,7 @@
|
||||
*
|
||||
*/
|
||||
try {
|
||||
await api.personApi.updatePerson({ id: personToBeMergedIn.id, personUpdateDto: { name: personName } });
|
||||
await updatePerson({ id: personToBeMergedIn.id, personUpdateDto: { name: personName } });
|
||||
|
||||
for (const person of people) {
|
||||
if (person.id === personToBeMergedIn.id) {
|
||||
@@ -248,7 +250,7 @@
|
||||
|
||||
const handleHidePerson = async (detail: PersonResponseDto) => {
|
||||
try {
|
||||
const { data: updatedPerson } = await api.personApi.updatePerson({
|
||||
const updatedPerson = await updatePerson({
|
||||
id: detail.id,
|
||||
personUpdateDto: { isHidden: true },
|
||||
});
|
||||
@@ -281,7 +283,7 @@
|
||||
);
|
||||
};
|
||||
|
||||
const searchPeople = async (force: boolean) => {
|
||||
const handleSearchPeople = async (force: boolean) => {
|
||||
if (searchName === '') {
|
||||
if ($page.url.searchParams.has(QueryParameter.SEARCHED_PEOPLE)) {
|
||||
$page.url.searchParams.delete(QueryParameter.SEARCHED_PEOPLE);
|
||||
@@ -295,9 +297,7 @@
|
||||
|
||||
const timeout = setTimeout(() => (isSearchingPeople = true), timeBeforeShowLoadingSpinner);
|
||||
try {
|
||||
const { data } = await api.searchApi.searchPerson({ name: searchName, withHidden: false });
|
||||
|
||||
searchedPeople = data;
|
||||
searchedPeople = await searchPerson({ name: searchName, withHidden: false });
|
||||
searchWord = searchName;
|
||||
} catch (error) {
|
||||
handleError(error, "Can't search people");
|
||||
@@ -318,7 +318,7 @@
|
||||
changeName();
|
||||
return;
|
||||
}
|
||||
const { data } = await api.searchApi.searchPerson({ name: personName, withHidden: true });
|
||||
const data = await searchPerson({ name: personName, withHidden: true });
|
||||
|
||||
// We check if another person has the same name as the name entered by the user
|
||||
|
||||
@@ -353,7 +353,7 @@
|
||||
}
|
||||
|
||||
try {
|
||||
const { data: updatedPerson } = await api.personApi.updatePerson({
|
||||
const updatedPerson = await updatePerson({
|
||||
id: edittingPerson.id,
|
||||
personUpdateDto: { birthDate: value.length > 0 ? value : null },
|
||||
});
|
||||
@@ -381,7 +381,7 @@
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { data: updatedPerson } = await api.personApi.updatePerson({
|
||||
const updatedPerson = await updatePerson({
|
||||
id: edittingPerson.id,
|
||||
personUpdateDto: { name: personName },
|
||||
});
|
||||
@@ -529,7 +529,7 @@
|
||||
preload={searchName !== '' || index < 20}
|
||||
bind:hidden={person.isHidden}
|
||||
shadow
|
||||
url={api.getPeopleThumbnailUrl(person.id)}
|
||||
url={getPeopleThumbnailUrl(person.id)}
|
||||
altText={person.name}
|
||||
widthStyle="100%"
|
||||
bind:eyeColor={eyeColorMap[person.id]}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { authenticate } from '$lib/utils/auth';
|
||||
import { api } from '@api';
|
||||
import { getAllPeople } from '@immich/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load = (async () => {
|
||||
await authenticate();
|
||||
|
||||
const { data: people } = await api.personApi.getAllPeople({ withHidden: true });
|
||||
const people = await getAllPeople({ withHidden: true });
|
||||
return {
|
||||
people,
|
||||
meta: {
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
import ImageThumbnail from '$lib/components/assets/thumbnail/image-thumbnail.svelte';
|
||||
import EditNameInput from '$lib/components/faces-page/edit-name-input.svelte';
|
||||
import MergeFaceSelector from '$lib/components/faces-page/merge-face-selector.svelte';
|
||||
import UnMergeFaceSelector from '$lib/components/faces-page/unmerge-face-selector.svelte';
|
||||
import MergeSuggestionModal from '$lib/components/faces-page/merge-suggestion-modal.svelte';
|
||||
import SetBirthDateModal from '$lib/components/faces-page/set-birth-date-modal.svelte';
|
||||
import UnMergeFaceSelector from '$lib/components/faces-page/unmerge-face-selector.svelte';
|
||||
import AddToAlbum from '$lib/components/photos-page/actions/add-to-album.svelte';
|
||||
import ArchiveAction from '$lib/components/photos-page/actions/archive-action.svelte';
|
||||
import ChangeDate from '$lib/components/photos-page/actions/change-date-action.svelte';
|
||||
@@ -21,24 +21,32 @@
|
||||
import AssetSelectControlBar from '$lib/components/photos-page/asset-select-control-bar.svelte';
|
||||
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
|
||||
import ControlAppBar from '$lib/components/shared-components/control-app-bar.svelte';
|
||||
import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
|
||||
import {
|
||||
NotificationType,
|
||||
notificationController,
|
||||
} from '$lib/components/shared-components/notification/notification';
|
||||
import { AppRoute, QueryParameter, maximumLengthSearchPeople, timeBeforeShowLoadingSpinner } from '$lib/constants';
|
||||
import { createAssetInteractionStore } from '$lib/stores/asset-interaction.store';
|
||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||
import { AssetStore } from '$lib/stores/assets.store';
|
||||
import { websocketStore } from '$lib/stores/websocket';
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
import { type AssetResponseDto, type PersonResponseDto, api } from '@api';
|
||||
import { onMount } from 'svelte';
|
||||
import type { PageData } from './$types';
|
||||
import { clickOutside } from '$lib/utils/click-outside';
|
||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||
import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
|
||||
import { mdiPlus, mdiDotsVertical, mdiArrowLeft } from '@mdi/js';
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
import { isExternalUrl } from '$lib/utils/navigation';
|
||||
import { searchNameLocal } from '$lib/utils/person';
|
||||
import {
|
||||
getPersonStatistics,
|
||||
mergePerson,
|
||||
searchPerson,
|
||||
updatePerson,
|
||||
type AssetResponseDto,
|
||||
type PersonResponseDto,
|
||||
} from '@immich/sdk';
|
||||
import { mdiArrowLeft, mdiDotsVertical, mdiPlus } from '@mdi/js';
|
||||
import { onMount } from 'svelte';
|
||||
import type { PageData } from './$types';
|
||||
import { getPeopleThumbnailUrl } from '$lib/utils';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
@@ -74,7 +82,7 @@
|
||||
let refreshAssetGrid = false;
|
||||
|
||||
let personName = '';
|
||||
$: thumbnailData = api.getPeopleThumbnailUrl(data.person.id);
|
||||
$: thumbnailData = getPeopleThumbnailUrl(data.person.id);
|
||||
|
||||
let name: string = data.person.name;
|
||||
let suggestedPeople: PersonResponseDto[] = [];
|
||||
@@ -97,8 +105,7 @@
|
||||
}
|
||||
const timeout = setTimeout(() => (isSearchingPeople = true), timeBeforeShowLoadingSpinner);
|
||||
try {
|
||||
const { data } = await api.searchApi.searchPerson({ name });
|
||||
people = data;
|
||||
people = await searchPerson({ name });
|
||||
searchWord = name;
|
||||
} catch (error) {
|
||||
people = [];
|
||||
@@ -113,7 +120,7 @@
|
||||
$: isAllArchive = [...$selectedAssets].every((asset) => asset.isArchived);
|
||||
$: isAllFavorite = [...$selectedAssets].every((asset) => asset.isFavorite);
|
||||
$: $onPersonThumbnail === data.person.id &&
|
||||
(thumbnailData = api.getPeopleThumbnailUrl(data.person.id) + `?now=${Date.now()}`);
|
||||
(thumbnailData = getPeopleThumbnailUrl(data.person.id) + `?now=${Date.now()}`);
|
||||
|
||||
$: {
|
||||
if (people) {
|
||||
@@ -215,7 +222,7 @@
|
||||
|
||||
const toggleHidePerson = async () => {
|
||||
try {
|
||||
await api.personApi.updatePerson({
|
||||
await updatePerson({
|
||||
id: data.person.id,
|
||||
personUpdateDto: { isHidden: !data.person.isHidden },
|
||||
});
|
||||
@@ -232,8 +239,8 @@
|
||||
};
|
||||
|
||||
const handleMerge = async (person: PersonResponseDto) => {
|
||||
const { data: statistics } = await api.personApi.getPersonStatistics({ id: person.id });
|
||||
numberOfAssets = statistics.assets;
|
||||
const { assets } = await getPersonStatistics({ id: person.id });
|
||||
numberOfAssets = assets;
|
||||
handleGoBack();
|
||||
|
||||
data.person = person;
|
||||
@@ -246,7 +253,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
await api.personApi.updatePerson({ id: data.person.id, personUpdateDto: { featureFaceAssetId: asset.id } });
|
||||
await updatePerson({ id: data.person.id, personUpdateDto: { featureFaceAssetId: asset.id } });
|
||||
|
||||
notificationController.show({ message: 'Feature photo updated', type: NotificationType.Info });
|
||||
assetInteractionStore.clearMultiselect();
|
||||
@@ -256,10 +263,8 @@
|
||||
|
||||
const updateAssetCount = async () => {
|
||||
try {
|
||||
const { data: statistics } = await api.personApi.getPersonStatistics({
|
||||
id: data.person.id,
|
||||
});
|
||||
numberOfAssets = statistics.assets;
|
||||
const { assets } = await getPersonStatistics({ id: data.person.id });
|
||||
numberOfAssets = assets;
|
||||
} catch (error) {
|
||||
handleError(error, "Can't update the asset count");
|
||||
}
|
||||
@@ -270,7 +275,7 @@
|
||||
viewMode = ViewMode.VIEW_ASSETS;
|
||||
isEditingName = false;
|
||||
try {
|
||||
await api.personApi.mergePerson({
|
||||
await mergePerson({
|
||||
id: personToBeMergedIn.id,
|
||||
mergePersonDto: { ids: [personToMerge.id] },
|
||||
});
|
||||
@@ -305,10 +310,7 @@
|
||||
try {
|
||||
isEditingName = false;
|
||||
|
||||
await api.personApi.updatePerson({
|
||||
id: data.person.id,
|
||||
personUpdateDto: { name: personName },
|
||||
});
|
||||
await updatePerson({ id: data.person.id, personUpdateDto: { name: personName } });
|
||||
|
||||
notificationController.show({
|
||||
message: 'Change name successfully',
|
||||
@@ -340,16 +342,16 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await api.searchApi.searchPerson({ name: personName, withHidden: true });
|
||||
const result = await searchPerson({ name: personName, withHidden: true });
|
||||
|
||||
const existingPerson = result.data.find(
|
||||
const existingPerson = result.find(
|
||||
(person: PersonResponseDto) =>
|
||||
person.name.toLowerCase() === personName.toLowerCase() && person.id !== data.person.id && person.name,
|
||||
);
|
||||
if (existingPerson) {
|
||||
personMerge2 = existingPerson;
|
||||
personMerge1 = data.person;
|
||||
potentialMergePeople = result.data
|
||||
potentialMergePeople = result
|
||||
.filter(
|
||||
(person: PersonResponseDto) =>
|
||||
personMerge2.name.toLowerCase() === person.name.toLowerCase() &&
|
||||
@@ -369,7 +371,7 @@
|
||||
viewMode = ViewMode.VIEW_ASSETS;
|
||||
data.person.birthDate = birthDate;
|
||||
|
||||
const { data: updatedPerson } = await api.personApi.updatePerson({
|
||||
const updatedPerson = await updatePerson({
|
||||
id: data.person.id,
|
||||
personUpdateDto: { birthDate: birthDate.length > 0 ? birthDate : null },
|
||||
});
|
||||
@@ -557,7 +559,7 @@
|
||||
<ImageThumbnail
|
||||
circle
|
||||
shadow
|
||||
url={api.getPeopleThumbnailUrl(person.id)}
|
||||
url={getPeopleThumbnailUrl(person.id)}
|
||||
altText={person.name}
|
||||
widthStyle="2rem"
|
||||
heightStyle="2rem"
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { authenticate } from '$lib/utils/auth';
|
||||
import { api } from '@api';
|
||||
import { getPerson, getPersonStatistics } from '@immich/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load = (async ({ params }) => {
|
||||
await authenticate();
|
||||
|
||||
const { data: person } = await api.personApi.getPerson({ id: params.personId });
|
||||
const { data: statistics } = await api.personApi.getPersonStatistics({ id: params.personId });
|
||||
const [person, statistics] = await Promise.all([
|
||||
getPerson({ id: params.personId }),
|
||||
getPersonStatistics({ id: params.personId }),
|
||||
]);
|
||||
|
||||
return {
|
||||
person,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { authenticate } from '$lib/utils/auth';
|
||||
import { api } from '@api';
|
||||
import { getExploreData } from '@immich/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load = (async () => {
|
||||
await authenticate();
|
||||
const { data: items } = await api.searchApi.getExploreData();
|
||||
const items = await getExploreData();
|
||||
|
||||
return {
|
||||
items,
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
<script lang="ts">
|
||||
import AlbumViewer from '$lib/components/album-page/album-viewer.svelte';
|
||||
import Button from '$lib/components/elements/buttons/button.svelte';
|
||||
import IndividualSharedViewer from '$lib/components/share-page/individual-shared-viewer.svelte';
|
||||
import ControlAppBar from '$lib/components/shared-components/control-app-bar.svelte';
|
||||
import ImmichLogo from '$lib/components/shared-components/immich-logo.svelte';
|
||||
import ThemeButton from '$lib/components/shared-components/theme-button.svelte';
|
||||
import Button from '$lib/components/elements/buttons/button.svelte';
|
||||
import { api, SharedLinkType } from '@api';
|
||||
import type { PageData } from './$types';
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
import { user } from '$lib/stores/user.store';
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
import { SharedLinkType } from '@api';
|
||||
import { getMySharedLink } from '@immich/sdk';
|
||||
import type { PageData } from './$types';
|
||||
|
||||
export let data: PageData;
|
||||
let { sharedLink, passwordRequired, sharedLinkKey: key, meta } = data;
|
||||
@@ -18,9 +19,8 @@
|
||||
|
||||
const handlePasswordSubmit = async () => {
|
||||
try {
|
||||
const result = await api.sharedLinkApi.getMySharedLink({ password, key });
|
||||
sharedLink = await getMySharedLink({ password, key });
|
||||
passwordRequired = false;
|
||||
sharedLink = result.data;
|
||||
isOwned = $user ? $user.id === sharedLink.userId : false;
|
||||
title = (sharedLink.album ? sharedLink.album.albumName : 'Public Share') + ' - Immich';
|
||||
description = sharedLink.description || `${sharedLink.assets.length} shared photos & videos.`;
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import { getAssetThumbnailUrl } from '$lib/utils';
|
||||
import { authenticate } from '$lib/utils/auth';
|
||||
import { api, ThumbnailFormat } from '@api';
|
||||
import { ThumbnailFormat } from '@api';
|
||||
import { getMySharedLink } from '@immich/sdk';
|
||||
import { error as throwError } from '@sveltejs/kit';
|
||||
import type { AxiosError } from 'axios';
|
||||
import type { PageLoad } from './$types';
|
||||
import { error as throwError } from '@sveltejs/kit';
|
||||
|
||||
export const load = (async ({ params }) => {
|
||||
const { key } = params;
|
||||
await authenticate({ public: true });
|
||||
|
||||
try {
|
||||
const { data: sharedLink } = await api.sharedLinkApi.getMySharedLink({ key });
|
||||
|
||||
const sharedLink = await getMySharedLink({ key });
|
||||
const assetCount = sharedLink.assets.length;
|
||||
const assetId = sharedLink.album?.albumThumbnailAssetId || sharedLink.assets[0]?.id;
|
||||
|
||||
@@ -19,9 +20,7 @@ export const load = (async ({ params }) => {
|
||||
meta: {
|
||||
title: sharedLink.album ? sharedLink.album.albumName : 'Public Share',
|
||||
description: sharedLink.description || `${assetCount} shared photos & videos.`,
|
||||
imageUrl: assetId
|
||||
? api.getAssetThumbnailUrl(assetId, ThumbnailFormat.Webp, sharedLink.key)
|
||||
: '/feature-panel.png',
|
||||
imageUrl: assetId ? getAssetThumbnailUrl(assetId, ThumbnailFormat.Webp) : '/feature-panel.png',
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { api } from '@api';
|
||||
import { getAssetInfo } from '@immich/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load = (async ({ params }) => {
|
||||
const { key, assetId } = params;
|
||||
const { data: asset } = await api.assetApi.getAssetInfo({ id: assetId, key });
|
||||
const asset = await getAssetInfo({ id: assetId, key });
|
||||
|
||||
return {
|
||||
asset,
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
<script lang="ts">
|
||||
import ControlAppBar from '$lib/components/shared-components/control-app-bar.svelte';
|
||||
import { api, copyToClipboard, makeSharedLinkUrl, type SharedLinkResponseDto } from '@api';
|
||||
import { goto } from '$app/navigation';
|
||||
import SharedLinkCard from '$lib/components/sharedlinks-page/shared-link-card.svelte';
|
||||
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
||||
import ControlAppBar from '$lib/components/shared-components/control-app-bar.svelte';
|
||||
import CreateSharedLinkModal from '$lib/components/shared-components/create-share-link-modal/create-shared-link-modal.svelte';
|
||||
import {
|
||||
notificationController,
|
||||
NotificationType,
|
||||
} from '$lib/components/shared-components/notification/notification';
|
||||
import { onMount } from 'svelte';
|
||||
import CreateSharedLinkModal from '$lib/components/shared-components/create-share-link-modal/create-shared-link-modal.svelte';
|
||||
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
import SharedLinkCard from '$lib/components/sharedlinks-page/shared-link-card.svelte';
|
||||
import { AppRoute } from '$lib/constants';
|
||||
import { mdiArrowLeft } from '@mdi/js';
|
||||
import { serverConfig } from '$lib/stores/server-config.store';
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
import { copyToClipboard, makeSharedLinkUrl, type SharedLinkResponseDto } from '@api';
|
||||
import { getAllSharedLinks, removeSharedLink } from '@immich/sdk';
|
||||
import { mdiArrowLeft } from '@mdi/js';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let sharedLinks: SharedLinkResponseDto[] = [];
|
||||
let editSharedLink: SharedLinkResponseDto | null = null;
|
||||
@@ -21,8 +22,7 @@
|
||||
let deleteLinkId: string | null = null;
|
||||
|
||||
const refresh = async () => {
|
||||
const { data } = await api.sharedLinkApi.getAllSharedLinks();
|
||||
sharedLinks = data;
|
||||
sharedLinks = await getAllSharedLinks();
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
@@ -35,7 +35,7 @@
|
||||
}
|
||||
|
||||
try {
|
||||
await api.sharedLinkApi.removeSharedLink({ id: deleteLinkId });
|
||||
await removeSharedLink({ id: deleteLinkId });
|
||||
notificationController.show({ message: 'Deleted shared link', type: NotificationType.Info });
|
||||
deleteLinkId = null;
|
||||
await refresh();
|
||||
|
||||
Reference in New Issue
Block a user