1
0
forked from Cutlery/immich
immich-quadlet/web/src/lib/stores/asset-viewing.store.ts
Jason Rasmussen d8631a00bb
refactor(web) open api client (#7103)
* refactor: person api

* refactor: shared link and others
2024-02-14 08:09:49 -05:00

34 lines
843 B
TypeScript

import { getKey } from '$lib/utils';
import { type AssetResponseDto } from '@api';
import { getAssetInfo } from '@immich/sdk';
import { writable } from 'svelte/store';
function createAssetViewingStore() {
const viewingAssetStoreState = writable<AssetResponseDto>();
const viewState = writable<boolean>(false);
const setAssetId = async (id: string) => {
const data = await getAssetInfo({ id, key: getKey() });
viewingAssetStoreState.set(data);
viewState.set(true);
};
const showAssetViewer = (show: boolean) => {
viewState.set(show);
};
return {
asset: {
subscribe: viewingAssetStoreState.subscribe,
},
isViewing: {
subscribe: viewState.subscribe,
set: viewState.set,
},
setAssetId,
showAssetViewer,
};
}
export const assetViewingStore = createAssetViewingStore();