Skip to content

Commit

Permalink
fix(web): Reset asset selection when refreshing and changing folder (#…
Browse files Browse the repository at this point in the history
…15178)

* fix(web): Reset asset selection when refreshing and changing folder

* fix: refactor
  • Loading branch information
arnolicious authored Jan 8, 2025
1 parent bab0437 commit cc473c4
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { goto, invalidateAll } from '$app/navigation';
import { afterNavigate, goto, invalidateAll } from '$app/navigation';
import { page } from '$app/stores';
import UserPageLayout, { headerId } from '$lib/components/layouts/user-page-layout.svelte';
import GalleryViewer from '$lib/components/shared-components/gallery-viewer/gallery-viewer.svelte';
Expand Down Expand Up @@ -46,8 +46,6 @@
let currentPath = $derived($page.url.searchParams.get(QueryParameter.PATH) || '');
let currentTreeItems = $derived(currentPath ? data.currentFolders : Object.keys(tree));
$inspect(data).with(console.log);
const assetInteraction = new AssetInteraction();
onMount(async () => {
Expand All @@ -66,9 +64,15 @@
return url.href;
};
afterNavigate(() => {
// Clear the asset selection when we navigate (like going to another folder)
cancelMultiselect(assetInteraction);
});
const navigateToView = (path: string) => goto(getLink(path));
const triggerAssetUpdate = async () => {
cancelMultiselect(assetInteraction);
await foldersStore.refreshAssetsByPath(data.path);
await invalidateAll();
};
Expand All @@ -91,8 +95,8 @@
<CreateSharedLink />
<CircleIconButton title={$t('select_all')} icon={mdiSelectAll} onclick={handleSelectAll} />
<ButtonContextMenu icon={mdiPlus} title={$t('add_to')}>
<AddToAlbum />
<AddToAlbum shared />
<AddToAlbum onAddToAlbum={() => cancelMultiselect(assetInteraction)} />
<AddToAlbum onAddToAlbum={() => cancelMultiselect(assetInteraction)} shared />
</ButtonContextMenu>
<FavoriteAction removeFavorite={assetInteraction.isAllFavorite} onFavorite={triggerAssetUpdate} />

Expand Down

0 comments on commit cc473c4

Please sign in to comment.