mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
* Refactor asset grid stores * Iterate over buckets with for..of loop * Rebase on top of main branch changes
31 lines
769 B
TypeScript
31 lines
769 B
TypeScript
import { writable } from 'svelte/store';
|
|
import { api, type AssetResponseDto } from '@api';
|
|
|
|
function createAssetViewingStore() {
|
|
const viewingAssetStoreState = writable<AssetResponseDto>();
|
|
const viewState = writable<boolean>(false);
|
|
|
|
const setAssetId = async (id: string) => {
|
|
const { data } = await api.assetApi.getAssetById({ id });
|
|
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();
|