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:
Sergey Kondrikov
2023-08-01 04:27:56 +03:00
committed by GitHub
parent 13051c1e5a
commit 5f9dfa9493
15 changed files with 330 additions and 265 deletions

View 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();