|
11 | 11 | import { AppRoute } from '$lib/constants'; |
12 | 12 | import DuplicatesInformationModal from '$lib/modals/DuplicatesInformationModal.svelte'; |
13 | 13 | import ShortcutsModal from '$lib/modals/ShortcutsModal.svelte'; |
| 14 | + import { assetViewingStore } from '$lib/stores/asset-viewing.store'; |
14 | 15 | import { locale } from '$lib/stores/preferences.store'; |
15 | 16 | import { featureFlags } from '$lib/stores/server-config.store'; |
16 | 17 | import { stackAssets } from '$lib/utils/asset-utils'; |
|
60 | 61 | }; |
61 | 62 |
|
62 | 63 | let duplicates = $state(data.duplicates); |
| 64 | + const { isViewing: showAssetViewer } = assetViewingStore; |
63 | 65 |
|
64 | 66 | const correctDuplicatesIndex = (index: number) => { |
65 | 67 | return Math.max(0, Math.min(index, duplicates.length - 1)); |
|
189 | 191 | const handlePrevious = async () => { |
190 | 192 | await correctDuplicatesIndexAndGo(Math.max(duplicatesIndex - 1, 0)); |
191 | 193 | }; |
| 194 | + const handlePreviousShortcut = async () => { |
| 195 | + if ($showAssetViewer) { |
| 196 | + return; |
| 197 | + } |
| 198 | + await handlePrevious(); |
| 199 | + }; |
192 | 200 | const handleNext = async () => { |
193 | 201 | await correctDuplicatesIndexAndGo(Math.min(duplicatesIndex + 1, duplicates.length - 1)); |
194 | 202 | }; |
| 203 | + const handleNextShortcut = async () => { |
| 204 | + if ($showAssetViewer) { |
| 205 | + return; |
| 206 | + } |
| 207 | + await handleNext(); |
| 208 | + }; |
195 | 209 | const handleLast = async () => { |
196 | 210 | await correctDuplicatesIndexAndGo(duplicates.length - 1); |
197 | 211 | }; |
|
203 | 217 |
|
204 | 218 | <svelte:document |
205 | 219 | 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 }, |
208 | 222 | ]} |
209 | 223 | /> |
210 | 224 |
|
|
0 commit comments