mirror of
https://github.com/immich-app/immich.git
synced 2025-06-03 05:34:32 -04:00
* feat(web): lighter timeline buckets * GalleryViewer * weird ssr * Remove generics from AssetInteraction * ensure keys on getAssetInfo, alt-text * empty - trigger ci * re-add alt-text * test fix * update tests * tests * missing import * feat(server): lighter buckets * fix: flappy e2e test * lint * revert settings * unneeded cast * fix after merge * Adapt web client to consume new server response format * test * missing import * lint * Use nulls, make-sql * openapi battle * date->string * tests * tests * lint/tests * lint * test * push aggregation to query * openapi * stack as tuple * openapi * update references to description * update alt text tests * update sql * update sql * update timeline tests * linting, fix expected response * string tuple * fix spec * fix * silly generator * rename patch * minimize sorting * review * lint * lint * sql * test * avoid abbreviations * review comment - type safety in test * merge conflicts * lint * lint/abbreviations * remove unncessary code * review comments * sql * re-add package-lock * use booleans, fix visibility in openapi spec, less cursed controller * update sql * no need to use sql template * array access actually doesn't seem to matter * remove redundant code * re-add sql decorator * unused type * remove null assertions * bad merge * Fix test * shave * extra clean shave * use decorator for content type * redundant types * redundant comment * update comment * unnecessary res --------- Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com> Co-authored-by: Alex <alex.tran1502@gmail.com>
77 lines
2.4 KiB
TypeScript
77 lines
2.4 KiB
TypeScript
import type { TimelineAsset } from '$lib/stores/assets-store.svelte';
|
|
import { user } from '$lib/stores/user.store';
|
|
import { AssetVisibility, type UserAdminResponseDto } from '@immich/sdk';
|
|
import { SvelteSet } from 'svelte/reactivity';
|
|
import { fromStore } from 'svelte/store';
|
|
|
|
export class AssetInteraction {
|
|
selectedAssets = $state<TimelineAsset[]>([]);
|
|
hasSelectedAsset(assetId: string) {
|
|
return this.selectedAssets.some((asset) => asset.id === assetId);
|
|
}
|
|
selectedGroup = new SvelteSet<string>();
|
|
assetSelectionCandidates = $state<TimelineAsset[]>([]);
|
|
hasSelectionCandidate(assetId: string) {
|
|
return this.assetSelectionCandidates.some((asset) => asset.id === assetId);
|
|
}
|
|
assetSelectionStart = $state<TimelineAsset | null>(null);
|
|
selectionActive = $derived(this.selectedAssets.length > 0);
|
|
|
|
private user = fromStore<UserAdminResponseDto | undefined>(user);
|
|
private userId = $derived(this.user.current?.id);
|
|
|
|
isAllTrashed = $derived(this.selectedAssets.every((asset) => asset.isTrashed));
|
|
isAllArchived = $derived(this.selectedAssets.every((asset) => asset.visibility === AssetVisibility.Archive));
|
|
isAllFavorite = $derived(this.selectedAssets.every((asset) => asset.isFavorite));
|
|
isAllUserOwned = $derived(this.selectedAssets.every((asset) => asset.ownerId === this.userId));
|
|
|
|
selectAsset(asset: TimelineAsset) {
|
|
if (!this.hasSelectedAsset(asset.id)) {
|
|
this.selectedAssets.push(asset);
|
|
}
|
|
}
|
|
|
|
selectAssets(assets: TimelineAsset[]) {
|
|
for (const asset of assets) {
|
|
this.selectAsset(asset);
|
|
}
|
|
}
|
|
|
|
removeAssetFromMultiselectGroup(assetId: string) {
|
|
const index = this.selectedAssets.findIndex((a) => a.id == assetId);
|
|
if (index !== -1) {
|
|
this.selectedAssets.splice(index, 1);
|
|
}
|
|
}
|
|
|
|
addGroupToMultiselectGroup(group: string) {
|
|
this.selectedGroup.add(group);
|
|
}
|
|
|
|
removeGroupFromMultiselectGroup(group: string) {
|
|
this.selectedGroup.delete(group);
|
|
}
|
|
|
|
setAssetSelectionStart(asset: TimelineAsset | null) {
|
|
this.assetSelectionStart = asset;
|
|
}
|
|
|
|
setAssetSelectionCandidates(assets: TimelineAsset[]) {
|
|
this.assetSelectionCandidates = assets;
|
|
}
|
|
|
|
clearAssetSelectionCandidates() {
|
|
this.assetSelectionCandidates = [];
|
|
}
|
|
|
|
clearMultiselect() {
|
|
// Multi-selection
|
|
this.selectedAssets = [];
|
|
this.selectedGroup.clear();
|
|
|
|
// Range selection
|
|
this.assetSelectionCandidates = [];
|
|
this.assetSelectionStart = null;
|
|
}
|
|
}
|