refactor(web): use new open api client (#7097)

* refactor(web): use new open api client

* refactor: remove activity api

* refactor: trash, oauth, and partner apis

* refactor: job api

* refactor: face, library, system config

* refactor: user api

* refactor: album api
This commit is contained in:
Jason Rasmussen 2024-02-13 17:07:37 -05:00 committed by GitHub
parent 9b4a770b9d
commit 8fd94211c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 593 additions and 850 deletions

View file

@ -1,34 +1,33 @@
import { notificationController, NotificationType } from '$lib/components/shared-components/notification/notification';
import { downloadManager } from '$lib/stores/download';
import { api } from '@api';
import {
api,
type BulkIdResponseDto,
addAssetsToAlbum as addAssets,
type AssetResponseDto,
type DownloadResponseDto,
type AssetTypeEnum,
type BulkIdResponseDto,
type DownloadInfoDto,
AssetTypeEnum,
type DownloadResponseDto,
type UserResponseDto,
} from '@api';
import { handleError } from './handle-error';
} from '@immich/sdk';
import { DateTime } from 'luxon';
import { handleError } from './handle-error';
export const addAssetsToAlbum = async (albumId: string, assetIds: Array<string>): Promise<BulkIdResponseDto[]> =>
api.albumApi
.addAssetsToAlbum({
id: albumId,
bulkIdsDto: { ids: assetIds },
key: api.getKey(),
})
.then(({ data: results }) => {
const count = results.filter(({ success }) => success).length;
notificationController.show({
type: NotificationType.Info,
message: `Added ${count} asset${count === 1 ? '' : 's'}`,
});
return results;
addAssets({
id: albumId,
bulkIdsDto: { ids: assetIds },
key: api.getKey(),
}).then((results) => {
const count = results.filter(({ success }) => success).length;
notificationController.show({
type: NotificationType.Info,
message: `Added ${count} asset${count === 1 ? '' : 's'}`,
});
return results;
});
export const downloadBlob = (data: Blob, filename: string) => {
const url = URL.createObjectURL(data);

View file

@ -1,10 +1,10 @@
import { api } from '@api';
import { redirect } from '@sveltejs/kit';
import { AppRoute } from '../constants';
import { get } from 'svelte/store';
import { serverInfo } from '$lib/stores/server-info.store';
import { browser } from '$app/environment';
import { serverInfo } from '$lib/stores/server-info.store';
import { user } from '$lib/stores/user.store';
import { getMyUserInfo, getServerInfo } from '@immich/sdk';
import { redirect } from '@sveltejs/kit';
import { get } from 'svelte/store';
import { AppRoute } from '../constants';
export interface AuthOptions {
admin?: true;
@ -15,8 +15,7 @@ export const loadUser = async () => {
try {
let loaded = get(user);
if (!loaded && hasAuthCookie()) {
const { data } = await api.userApi.getMyUserInfo();
loaded = data;
loaded = await getMyUserInfo();
user.set(loaded);
}
return loaded;
@ -59,7 +58,7 @@ export const authenticate = async (options?: AuthOptions) => {
export const requestServerInfo = async () => {
if (get(user)) {
const { data } = await api.serverInfoApi.getServerInfo();
const data = await getServerInfo();
serverInfo.set(data);
}
};

View file

@ -1,8 +1,9 @@
import { UploadState } from '$lib/models/upload-asset';
import { uploadAssetsStore } from '$lib/stores/upload';
import { addAssetsToAlbum } from '$lib/utils/asset-utils';
import { api, type AssetFileUploadResponseDto } from '@api';
import { UploadState } from '$lib/models/upload-asset';
import { ExecutorQueue } from '$lib/utils/executor-queue';
import { api, type AssetFileUploadResponseDto } from '@api';
import { getSupportedMediaTypes } from '@immich/sdk';
import { getServerErrorMessage, handleError } from './handle-error';
let _extensions: string[];
@ -11,8 +12,8 @@ export const uploadExecutionQueue = new ExecutorQueue({ concurrency: 2 });
const getExtensions = async () => {
if (!_extensions) {
const { data } = await api.serverInfoApi.getSupportedMediaTypes();
_extensions = [...data.image, ...data.video];
const { image, video } = await getSupportedMediaTypes();
_extensions = [...image, ...video];
}
return _extensions;
};