mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
* refactor(web): asset grid state * fix: multi-select across time buckets --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { AssetBucket, AssetGridState, BucketPosition, Viewport } from '$lib/models/asset-grid-state';
|
|
import type { AssetCountByTimeBucket } from '@api';
|
|
|
|
export interface AssetStore {
|
|
init: (viewport: Viewport, data: AssetCountByTimeBucket[], userId: string | undefined) => void;
|
|
|
|
// bucket
|
|
loadBucket: (bucket: string, position: BucketPosition) => Promise<void>;
|
|
updateBucket: (bucket: string, actualBucketHeight: number) => number;
|
|
cancelBucket: (bucket: AssetBucket) => void;
|
|
|
|
// asset
|
|
removeAsset: (assetId: string) => void;
|
|
updateAsset: (assetId: string, isFavorite: boolean) => void;
|
|
|
|
// asset navigation
|
|
getNextAssetId: (assetId: string) => Promise<string | null>;
|
|
getPreviousAssetId: (assetId: string) => Promise<string | null>;
|
|
|
|
// store
|
|
subscribe: (run: (value: AssetGridState) => void, invalidate?: (value?: AssetGridState) => void) => () => void;
|
|
}
|
|
|
|
export function createAssetStore(): AssetStore {
|
|
const store = new AssetGridState();
|
|
|
|
return {
|
|
init: store.init.bind(store),
|
|
loadBucket: store.loadBucket.bind(store),
|
|
updateBucket: store.updateBucket.bind(store),
|
|
cancelBucket: store.cancelBucket.bind(store),
|
|
removeAsset: store.removeAsset.bind(store),
|
|
updateAsset: store.updateAsset.bind(store),
|
|
getNextAssetId: store.getNextAssetId.bind(store),
|
|
getPreviousAssetId: store.getPreviousAssetId.bind(store),
|
|
subscribe: store.subscribe,
|
|
};
|
|
}
|