GalleryViewer

This commit is contained in:
Min Idzelis
2025-04-20 02:51:32 +00:00
parent 3b9490e28d
commit c1e699ebaf
12 changed files with 168 additions and 154 deletions

View File

@@ -1,17 +1,15 @@
import type { AssetResponseDto } from '@immich/sdk';
export class SlideshowHistory {
private history: AssetResponseDto[] = [];
private history: { id: string }[] = [];
private index = 0;
constructor(private onChange: (asset: AssetResponseDto) => void) {}
constructor(private onChange: (asset: { id: string }) => void) {}
reset() {
this.history = [];
this.index = 0;
}
queue(asset: AssetResponseDto) {
queue(asset: { id: string }) {
this.history.push(asset);
// If we were at the end of the slideshow history, move the index to the new end

View File

@@ -37,8 +37,16 @@ export function getThumbnailSize(assetCount: number, viewWidth: number): number
return 300;
}
export const getAltTextForTimelineAsset = () => {
// TODO: implement this in a performant way
return '';
};
export const getAltText = derived(t, ($t) => {
return (asset: AssetResponseDto) => {
return (asset: AssetResponseDto | null | undefined) => {
if (!asset) {
return '';
}
if (asset.exifInfo?.description) {
return asset.exifInfo.description;
}

View File

@@ -1,4 +1,3 @@
import type { BaseInteractionAsset } from '$lib/stores/asset-interaction.svelte';
import type { AssetBucket, TimelineAsset } from '$lib/stores/assets-store.svelte';
import { locale } from '$lib/stores/preferences.store';
import { getAssetRatio } from '$lib/utils/asset-utils';
@@ -108,7 +107,7 @@ export const getDateLocaleString = (date: DateTime, opts?: LocaleOptions): strin
export const formatDateGroupTitle = memoize(formatGroupTitle);
export const toTimelineAsset = (unknownAsset: BaseInteractionAsset): TimelineAsset => {
export const toTimelineAsset = (unknownAsset: AssetResponseDto | TimelineAsset): TimelineAsset => {
if (isTimelineAsset(unknownAsset)) {
return unknownAsset;
}
@@ -132,5 +131,5 @@ export const toTimelineAsset = (unknownAsset: BaseInteractionAsset): TimelineAss
livePhotoVideoId: assetResponse.livePhotoVideoId || null,
};
};
export const isTimelineAsset = (arg: BaseInteractionAsset): arg is TimelineAsset =>
export const isTimelineAsset = (arg: AssetResponseDto | TimelineAsset): arg is TimelineAsset =>
(arg as TimelineAsset).ratio !== undefined;