mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
refactor(web): asset grid stores (#3464)
* Refactor asset grid stores * Iterate over buckets with for..of loop * Rebase on top of main branch changes
This commit is contained in:
31
web/src/lib/stores/asset-viewing.store.ts
Normal file
31
web/src/lib/stores/asset-viewing.store.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user