mirror of https://github.com/immich-app/immich.git
feat(web): add ctrl+a / ctrl+d shortcuts to select / deselect all assets (#8105)
* feat(web): use ctrl+a / ctrl+d to select / deselect all assets * fix(web): use shortcutList for ctrl+a / ctrl+d * fix(web): remove useless get() * feat(web): asset interaction store can now select many assets at oncepull/8154/head
parent
b588a87d4a
commit
4de0b2f44e
@ -1,42 +1,24 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
||||||
import type { AssetInteractionStore } from '$lib/stores/asset-interaction.store';
|
import type { AssetInteractionStore } from '$lib/stores/asset-interaction.store';
|
||||||
import { BucketPosition, type AssetStore, isSelectAllCancelled } from '$lib/stores/assets.store';
|
import { type AssetStore, isSelectingAllAssets } from '$lib/stores/assets.store';
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
import { mdiSelectAll, mdiTimerSand } from '@mdi/js';
|
||||||
import { get } from 'svelte/store';
|
import { selectAllAssets } from '$lib/utils/asset-utils';
|
||||||
import { mdiTimerSand, mdiSelectAll } from '@mdi/js';
|
|
||||||
|
|
||||||
export let assetStore: AssetStore;
|
export let assetStore: AssetStore;
|
||||||
export let assetInteractionStore: AssetInteractionStore;
|
export let assetInteractionStore: AssetInteractionStore;
|
||||||
|
|
||||||
let selecting = false;
|
|
||||||
|
|
||||||
const handleSelectAll = async () => {
|
const handleSelectAll = async () => {
|
||||||
try {
|
await selectAllAssets(assetStore, assetInteractionStore);
|
||||||
$isSelectAllCancelled = false;
|
};
|
||||||
selecting = true;
|
|
||||||
|
|
||||||
const assetGridState = get(assetStore);
|
|
||||||
for (const bucket of assetGridState.buckets) {
|
|
||||||
if ($isSelectAllCancelled) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
await assetStore.loadBucket(bucket.bucketDate, BucketPosition.Unknown);
|
|
||||||
for (const asset of bucket.assets) {
|
|
||||||
assetInteractionStore.selectAsset(asset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
selecting = false;
|
const handleCancel = () => {
|
||||||
} catch (error) {
|
$isSelectingAllAssets = false;
|
||||||
handleError(error, 'Error selecting all assets');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if selecting}
|
{#if $isSelectingAllAssets}
|
||||||
<CircleIconButton title="Delete" icon={mdiTimerSand} />
|
<CircleIconButton title="Cancel" icon={mdiTimerSand} on:click={handleCancel} />
|
||||||
{/if}
|
{:else}
|
||||||
{#if !selecting}
|
|
||||||
<CircleIconButton title="Select all" icon={mdiSelectAll} on:click={handleSelectAll} />
|
<CircleIconButton title="Select all" icon={mdiSelectAll} on:click={handleSelectAll} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Loading…
Reference in New Issue