1
0
mirror of https://github.com/immich-app/immich.git synced 2025-01-12 15:32:36 +02:00

fix(web): cancel select all (#6047)

* fix: cancel select all

* rename var
This commit is contained in:
martin 2024-01-01 17:18:22 +01:00 committed by GitHub
parent 0ed89e61ec
commit 9de557916b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<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 } from '$lib/stores/assets.store'; import { BucketPosition, type AssetStore, isSelectAllCancelled } from '$lib/stores/assets.store';
import { handleError } from '$lib/utils/handle-error'; import { handleError } from '$lib/utils/handle-error';
import { get } from 'svelte/store'; import { get } from 'svelte/store';
import { mdiTimerSand, mdiSelectAll } from '@mdi/js'; import { mdiTimerSand, mdiSelectAll } from '@mdi/js';
@ -13,10 +13,14 @@
const handleSelectAll = async () => { const handleSelectAll = async () => {
try { try {
$isSelectAllCancelled = false;
selecting = true; selecting = true;
const assetGridState = get(assetStore); const assetGridState = get(assetStore);
for (const bucket of assetGridState.buckets) { for (const bucket of assetGridState.buckets) {
if ($isSelectAllCancelled) {
break;
}
await assetStore.loadBucket(bucket.bucketDate, BucketPosition.Unknown); await assetStore.loadBucket(bucket.bucketDate, BucketPosition.Unknown);
for (const asset of bucket.assets) { for (const asset of bucket.assets) {
assetInteractionStore.selectAsset(asset); assetInteractionStore.selectAsset(asset);

View File

@ -5,6 +5,7 @@
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte'; import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
import { fly } from 'svelte/transition'; import { fly } from 'svelte/transition';
import { mdiClose } from '@mdi/js'; import { mdiClose } from '@mdi/js';
import { isSelectAllCancelled } from '$lib/stores/assets.store';
export let showBackButton = true; export let showBackButton = true;
export let backIcon = mdiClose; export let backIcon = mdiClose;
@ -29,6 +30,11 @@
} }
}; };
const handleClose = () => {
$isSelectAllCancelled = true;
dispatch('close');
};
onMount(() => { onMount(() => {
if (browser) { if (browser) {
document.addEventListener('scroll', onScroll); document.addEventListener('scroll', onScroll);
@ -52,7 +58,7 @@
<div class="flex place-items-center gap-6 justify-self-start dark:text-immich-dark-fg"> <div class="flex place-items-center gap-6 justify-self-start dark:text-immich-dark-fg">
{#if showBackButton} {#if showBackButton}
<CircleIconButton <CircleIconButton
on:click={() => dispatch('close')} on:click={handleClose}
icon={backIcon} icon={backIcon}
backgroundColor={'transparent'} backgroundColor={'transparent'}
hoverColor={'#e2e7e9'} hoverColor={'#e2e7e9'}

View File

@ -438,3 +438,5 @@ export class AssetStore {
this.store$.update(() => this); this.store$.update(() => this);
} }
} }
export const isSelectAllCancelled = writable(false);