1
0
mirror of https://github.com/immich-app/immich.git synced 2025-07-07 06:16:05 +02:00

fix(web): memory viewer (#12649)

refactor(web): memory viewer
This commit is contained in:
Jason Rasmussen
2024-09-13 12:27:10 -04:00
committed by GitHub
parent cdbc673a59
commit a373d50c31
4 changed files with 242 additions and 180 deletions

View File

@ -24,6 +24,8 @@
export let viewport: Viewport;
export let onIntersected: (() => void) | undefined = undefined;
export let showAssetName = false;
export let onPrevious: (() => Promise<AssetResponseDto | undefined>) | undefined = undefined;
export let onNext: (() => Promise<AssetResponseDto | undefined>) | undefined = undefined;
let { isViewing: isViewerOpen, asset: viewingAsset, setAsset } = assetViewingStore;
@ -50,8 +52,9 @@
const handleNext = async () => {
try {
if (currentViewAssetIndex < assets.length - 1) {
setAsset(assets[++currentViewAssetIndex]);
const asset = onNext ? await onNext() : assets[++currentViewAssetIndex];
if (asset) {
setAsset(asset);
await navigate({ targetRoute: 'current', assetId: $viewingAsset.id });
}
} catch (error) {
@ -61,8 +64,9 @@
const handlePrevious = async () => {
try {
if (currentViewAssetIndex > 0) {
setAsset(assets[--currentViewAssetIndex]);
const asset = onPrevious ? await onPrevious() : assets[--currentViewAssetIndex];
if (asset) {
setAsset(asset);
await navigate({ targetRoute: 'current', assetId: $viewingAsset.id });
}
} catch (error) {