mirror of
				https://github.com/KevinMidboe/immich.git
				synced 2025-10-29 17:40:28 +00:00 
			
		
		
		
	* Refactor asset grid stores * Iterate over buckets with for..of loop * Rebase on top of main branch changes
		
			
				
	
	
		
			32 lines
		
	
	
		
			769 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			32 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();
 |