mirror of
https://github.com/immich-app/immich.git
synced 2026-03-01 01:59:06 +03:00
feat: redesign asset-viewer previous/next and hide when nav not possible (#24903)
This commit is contained in:
@@ -508,11 +508,13 @@ export const delay = async (ms: number) => {
|
||||
};
|
||||
|
||||
export const getNextAsset = (assets: AssetResponseDto[], currentAsset: AssetResponseDto | undefined) => {
|
||||
return currentAsset && assets[assets.indexOf(currentAsset) + 1];
|
||||
const index = currentAsset ? assets.findIndex((a) => a.id === currentAsset.id) : -1;
|
||||
return index >= 0 ? assets[index + 1] : undefined;
|
||||
};
|
||||
|
||||
export const getPreviousAsset = (assets: AssetResponseDto[], currentAsset: AssetResponseDto | undefined) => {
|
||||
return currentAsset && assets[assets.indexOf(currentAsset) - 1];
|
||||
const index = currentAsset ? assets.findIndex((a) => a.id === currentAsset.id) : -1;
|
||||
return index >= 0 ? assets[index - 1] : undefined;
|
||||
};
|
||||
|
||||
export const canCopyImageToClipboard = (): boolean => {
|
||||
@@ -547,3 +549,12 @@ export const copyImageToClipboard = async (source: HTMLImageElement) => {
|
||||
// do not await, so the Safari clipboard write happens in the context of the user gesture
|
||||
await navigator.clipboard.write([new ClipboardItem({ ['image/png']: imgToBlob(source) })]);
|
||||
};
|
||||
|
||||
export const navigateToAsset = async (targetAsset: AssetResponseDto | undefined | null) => {
|
||||
if (!targetAsset) {
|
||||
return false;
|
||||
}
|
||||
|
||||
await navigate({ targetRoute: 'current', assetId: targetAsset.id });
|
||||
return true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user