mirror of
https://github.com/KevinMidboe/immich.git
synced 2026-02-10 18:29:22 +00:00
chore(web): generate API functions with a single argument (#2568)
This commit is contained in:
@@ -10,7 +10,7 @@ export const load = (async ({ params, locals: { api, user } }) => {
|
||||
const albumId = params['albumId'];
|
||||
|
||||
try {
|
||||
const { data: album } = await api.albumApi.getAlbumInfo(albumId);
|
||||
const { data: album } = await api.albumApi.getAlbumInfo({ id: albumId });
|
||||
return {
|
||||
album,
|
||||
meta: {
|
||||
|
||||
@@ -90,7 +90,7 @@ describe('Albums BLoC', () => {
|
||||
const newAlbum = await sut.createAlbum();
|
||||
|
||||
expect(apiMock.albumApi.createAlbum).toHaveBeenCalledTimes(1);
|
||||
expect(apiMock.albumApi.createAlbum).toHaveBeenCalledWith(payload);
|
||||
expect(apiMock.albumApi.createAlbum).toHaveBeenCalledWith({ createAlbumDto: payload });
|
||||
expect(newAlbum).toEqual(returnedAlbum);
|
||||
});
|
||||
|
||||
@@ -130,7 +130,7 @@ describe('Albums BLoC', () => {
|
||||
const updatedAlbums = get(sut.albums);
|
||||
|
||||
expect(apiMock.albumApi.deleteAlbum).toHaveBeenCalledTimes(1);
|
||||
expect(apiMock.albumApi.deleteAlbum).toHaveBeenCalledWith(albumToDeleteId);
|
||||
expect(apiMock.albumApi.deleteAlbum).toHaveBeenCalledWith({ id: albumToDeleteId });
|
||||
expect(updatedAlbums).toHaveLength(4);
|
||||
expect(updatedAlbums).not.toContain(albumToDelete);
|
||||
expect(get(sut.isShowContextMenu)).toBe(false);
|
||||
|
||||
@@ -40,7 +40,9 @@ export const useAlbums = (props: AlbumsProps) => {
|
||||
async function createAlbum(): Promise<AlbumResponseDto | undefined> {
|
||||
try {
|
||||
const { data: newAlbum } = await api.albumApi.createAlbum({
|
||||
albumName: 'Untitled'
|
||||
createAlbumDto: {
|
||||
albumName: 'Untitled'
|
||||
}
|
||||
});
|
||||
|
||||
return newAlbum;
|
||||
@@ -53,7 +55,7 @@ export const useAlbums = (props: AlbumsProps) => {
|
||||
}
|
||||
|
||||
async function deleteAlbum(album: AlbumResponseDto): Promise<void> {
|
||||
await api.albumApi.deleteAlbum(album.id);
|
||||
await api.albumApi.deleteAlbum({ id: album.id });
|
||||
}
|
||||
|
||||
async function showAlbumContextMenu(
|
||||
@@ -83,7 +85,7 @@ export const useAlbums = (props: AlbumsProps) => {
|
||||
)
|
||||
) {
|
||||
try {
|
||||
await api.albumApi.deleteAlbum(albumToDelete.id);
|
||||
await api.albumApi.deleteAlbum({ id: albumToDelete.id });
|
||||
const _albums = get(albums);
|
||||
albums.set(_albums.filter((a) => a.id !== albumToDelete.id));
|
||||
} catch {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
const { data: assets } = await api.assetApi.getAllAssets(undefined, undefined, true);
|
||||
const { data: assets } = await api.assetApi.getAllAssets({ isArchived: true });
|
||||
$archivedAsset = assets;
|
||||
} catch {
|
||||
handleError(Error, 'Unable to load archived assets');
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
const { data: assets } = await api.assetApi.getAllAssets(undefined, true, undefined);
|
||||
const { data: assets } = await api.assetApi.getAllAssets({ isFavorite: true });
|
||||
favorites = assets;
|
||||
} catch {
|
||||
handleError(Error, 'Unable to load favorites');
|
||||
|
||||
@@ -48,9 +48,11 @@
|
||||
const { fileCreatedAfter, fileCreatedBefore } = getFileCreatedDates();
|
||||
|
||||
const { data } = await api.assetApi.getMapMarkers(
|
||||
onlyFavorites || undefined,
|
||||
fileCreatedAfter,
|
||||
fileCreatedBefore,
|
||||
{
|
||||
isFavorite: onlyFavorites || undefined,
|
||||
fileCreatedAfter,
|
||||
fileCreatedBefore
|
||||
},
|
||||
{
|
||||
signal: abortController.signal
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export const load: PageServerLoad = async ({ params, parent, locals: { api } })
|
||||
throw redirect(302, AppRoute.AUTH_LOGIN);
|
||||
}
|
||||
|
||||
const { data: partner } = await api.userApi.getUserById(params['userId']);
|
||||
const { data: partner } = await api.userApi.getUserById({ userId: params['userId'] });
|
||||
|
||||
return {
|
||||
user,
|
||||
|
||||
@@ -7,8 +7,8 @@ export const load = (async ({ locals, parent, params }) => {
|
||||
throw redirect(302, '/auth/login');
|
||||
}
|
||||
|
||||
const { data: person } = await locals.api.personApi.getPerson(params.personId);
|
||||
const { data: assets } = await locals.api.personApi.getPersonAssets(params.personId);
|
||||
const { data: person } = await locals.api.personApi.getPerson({ id: params.personId });
|
||||
const { data: assets } = await locals.api.personApi.getPersonAssets({ id: params.personId });
|
||||
|
||||
return {
|
||||
user,
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
try {
|
||||
isEditName = false;
|
||||
data.person.name = name;
|
||||
await api.personApi.updatePerson(data.person.id, { name });
|
||||
await api.personApi.updatePerson({ id: data.person.id, personUpdateDto: { name } });
|
||||
} catch (error) {
|
||||
handleError(error, 'Unable to save name');
|
||||
}
|
||||
|
||||
@@ -9,24 +9,7 @@ export const load = (async ({ locals, parent, url }) => {
|
||||
|
||||
const term = url.searchParams.get('q') || url.searchParams.get('query') || undefined;
|
||||
|
||||
const { data: results } = await locals.api.searchApi.search(
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
{ params: url.searchParams }
|
||||
);
|
||||
const { data: results } = await locals.api.searchApi.search({}, { params: url.searchParams });
|
||||
|
||||
return {
|
||||
user,
|
||||
|
||||
@@ -7,7 +7,7 @@ export const load = (async ({ params, locals: { api } }) => {
|
||||
const { key } = params;
|
||||
|
||||
try {
|
||||
const { data: sharedLink } = await api.shareApi.getMySharedLink(key);
|
||||
const { data: sharedLink } = await api.shareApi.getMySharedLink({ key });
|
||||
|
||||
const assetCount = sharedLink.assets.length;
|
||||
const assetId = sharedLink.album?.albumThumbnailAssetId || sharedLink.assets[0]?.id;
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { PageServerLoad } from './$types';
|
||||
export const load = (async ({ params, locals: { api } }) => {
|
||||
try {
|
||||
const { key, assetId } = params;
|
||||
const { data: asset } = await api.assetApi.getAssetById(assetId, key);
|
||||
const { data: asset } = await api.assetApi.getAssetById({ assetId, key });
|
||||
|
||||
if (!asset) {
|
||||
return error(404, 'Asset not found');
|
||||
|
||||
@@ -8,8 +8,8 @@ export const load = (async ({ locals: { api, user } }) => {
|
||||
}
|
||||
|
||||
try {
|
||||
const { data: sharedAlbums } = await api.albumApi.getAllAlbums(true);
|
||||
const { data: partners } = await api.partnerApi.getPartners('shared-with');
|
||||
const { data: sharedAlbums } = await api.albumApi.getAllAlbums({ shared: true });
|
||||
const { data: partners } = await api.partnerApi.getPartners({ direction: 'shared-with' });
|
||||
|
||||
return {
|
||||
user,
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
const createSharedAlbum = async () => {
|
||||
try {
|
||||
const { data: newAlbum } = await api.albumApi.createAlbum({
|
||||
albumName: 'Untitled'
|
||||
createAlbumDto: {
|
||||
albumName: 'Untitled'
|
||||
}
|
||||
});
|
||||
|
||||
goto('/albums/' + newAlbum.id);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
const handleDeleteLink = async (linkId: string) => {
|
||||
if (window.confirm('Do you want to delete the shared link? ')) {
|
||||
try {
|
||||
await api.shareApi.removeSharedLink(linkId);
|
||||
await api.shareApi.removeSharedLink({ id: linkId });
|
||||
notificationController.show({
|
||||
message: 'Shared link deleted',
|
||||
type: NotificationType.Info
|
||||
@@ -47,7 +47,7 @@
|
||||
};
|
||||
|
||||
const handleEditLink = async (id: string) => {
|
||||
const { data } = await api.shareApi.getSharedLinkById(id);
|
||||
const { data } = await api.shareApi.getSharedLinkById({ id });
|
||||
editSharedLink = data;
|
||||
showEditForm = true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user