feat(web): add keyboard shortcut to stack selected photos (#5983)

* feat(web): add keyboard shortcut to stack selected photos

* refactor(web): deduplicate logic to stack assets

* Fix linting errors

* fix(web): incorrect count of stacked photos

* chore: cleanup

---------

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
Guillermo 2024-04-02 09:04:52 -06:00 committed by GitHub
parent 7cc19b50fc
commit 28e8e539f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 53 additions and 43 deletions

View file

@ -18,6 +18,7 @@
import Scrollbar from '../shared-components/scrollbar/scrollbar.svelte';
import ShowShortcuts from '../shared-components/show-shortcuts.svelte';
import AssetDateGroup from './asset-date-group.svelte';
import { stackAssets } from '$lib/utils/asset-utils';
import DeleteAssetDialog from './delete-asset-dialog.svelte';
import { handlePromiseError } from '$lib/utils';
import { selectAllAssets } from '$lib/utils/asset-utils';
@ -85,6 +86,13 @@
handlePromiseError(trashOrDelete(true));
};
const onStackAssets = async () => {
await stackAssets(Array.from($selectedAssets), (ids) => {
assetStore.removeAssets(ids);
dispatch('escape');
});
};
$: shortcutList = (() => {
if ($isSearchEnabled || $showAssetViewer) {
return [];
@ -102,6 +110,7 @@
{ shortcut: { key: 'Delete' }, onShortcut: onDelete },
{ shortcut: { key: 'Delete', shift: true }, onShortcut: onForceDelete },
{ shortcut: { key: 'D', ctrl: true }, onShortcut: () => deselectAllAssets() },
{ shortcut: { key: 's' }, onShortcut: () => onStackAssets() },
);
}