Skip to content

Commit d9d8beb

Browse files
authored
fix(web): Duplicate arrow shortcuts go to next/previous duplicate when viewing assets (#21200)
- get assetviewer state and don't handle next/previous duplicate if isViewing
1 parent 38a8a67 commit d9d8beb

File tree

1 file changed

+16
-2
lines changed
  • web/src/routes/(user)/utilities/duplicates/[[photos=photos]]/[[assetId=id]]

1 file changed

+16
-2
lines changed

web/src/routes/(user)/utilities/duplicates/[[photos=photos]]/[[assetId=id]]/+page.svelte

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import { AppRoute } from '$lib/constants';
1212
import DuplicatesInformationModal from '$lib/modals/DuplicatesInformationModal.svelte';
1313
import ShortcutsModal from '$lib/modals/ShortcutsModal.svelte';
14+
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
1415
import { locale } from '$lib/stores/preferences.store';
1516
import { featureFlags } from '$lib/stores/server-config.store';
1617
import { stackAssets } from '$lib/utils/asset-utils';
@@ -60,6 +61,7 @@
6061
};
6162
6263
let duplicates = $state(data.duplicates);
64+
const { isViewing: showAssetViewer } = assetViewingStore;
6365
6466
const correctDuplicatesIndex = (index: number) => {
6567
return Math.max(0, Math.min(index, duplicates.length - 1));
@@ -189,9 +191,21 @@
189191
const handlePrevious = async () => {
190192
await correctDuplicatesIndexAndGo(Math.max(duplicatesIndex - 1, 0));
191193
};
194+
const handlePreviousShortcut = async () => {
195+
if ($showAssetViewer) {
196+
return;
197+
}
198+
await handlePrevious();
199+
};
192200
const handleNext = async () => {
193201
await correctDuplicatesIndexAndGo(Math.min(duplicatesIndex + 1, duplicates.length - 1));
194202
};
203+
const handleNextShortcut = async () => {
204+
if ($showAssetViewer) {
205+
return;
206+
}
207+
await handleNext();
208+
};
195209
const handleLast = async () => {
196210
await correctDuplicatesIndexAndGo(duplicates.length - 1);
197211
};
@@ -203,8 +217,8 @@
203217

204218
<svelte:document
205219
use:shortcuts={[
206-
{ shortcut: { key: 'ArrowLeft' }, onShortcut: handlePrevious },
207-
{ shortcut: { key: 'ArrowRight' }, onShortcut: handleNext },
220+
{ shortcut: { key: 'ArrowLeft' }, onShortcut: handlePreviousShortcut },
221+
{ shortcut: { key: 'ArrowRight' }, onShortcut: handleNextShortcut },
208222
]}
209223
/>
210224

0 commit comments

Comments
 (0)