mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-04 03:27:09 -05:00 
			
		
		
		
	fix(web): Reset asset selection when refreshing and changing folder (#15178)
* fix(web): Reset asset selection when refreshing and changing folder * fix: refactor
This commit is contained in:
		
							parent
							
								
									bab04378dc
								
							
						
					
					
						commit
						cc473c42b5
					
				@ -1,5 +1,5 @@
 | 
				
			|||||||
<script lang="ts">
 | 
					<script lang="ts">
 | 
				
			||||||
  import { goto, invalidateAll } from '$app/navigation';
 | 
					  import { afterNavigate, goto, invalidateAll } from '$app/navigation';
 | 
				
			||||||
  import { page } from '$app/stores';
 | 
					  import { page } from '$app/stores';
 | 
				
			||||||
  import UserPageLayout, { headerId } from '$lib/components/layouts/user-page-layout.svelte';
 | 
					  import UserPageLayout, { headerId } from '$lib/components/layouts/user-page-layout.svelte';
 | 
				
			||||||
  import GalleryViewer from '$lib/components/shared-components/gallery-viewer/gallery-viewer.svelte';
 | 
					  import GalleryViewer from '$lib/components/shared-components/gallery-viewer/gallery-viewer.svelte';
 | 
				
			||||||
@ -46,8 +46,6 @@
 | 
				
			|||||||
  let currentPath = $derived($page.url.searchParams.get(QueryParameter.PATH) || '');
 | 
					  let currentPath = $derived($page.url.searchParams.get(QueryParameter.PATH) || '');
 | 
				
			||||||
  let currentTreeItems = $derived(currentPath ? data.currentFolders : Object.keys(tree));
 | 
					  let currentTreeItems = $derived(currentPath ? data.currentFolders : Object.keys(tree));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  $inspect(data).with(console.log);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const assetInteraction = new AssetInteraction();
 | 
					  const assetInteraction = new AssetInteraction();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  onMount(async () => {
 | 
					  onMount(async () => {
 | 
				
			||||||
@ -66,9 +64,15 @@
 | 
				
			|||||||
    return url.href;
 | 
					    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 navigateToView = (path: string) => goto(getLink(path));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const triggerAssetUpdate = async () => {
 | 
					  const triggerAssetUpdate = async () => {
 | 
				
			||||||
 | 
					    cancelMultiselect(assetInteraction);
 | 
				
			||||||
    await foldersStore.refreshAssetsByPath(data.path);
 | 
					    await foldersStore.refreshAssetsByPath(data.path);
 | 
				
			||||||
    await invalidateAll();
 | 
					    await invalidateAll();
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
@ -91,8 +95,8 @@
 | 
				
			|||||||
      <CreateSharedLink />
 | 
					      <CreateSharedLink />
 | 
				
			||||||
      <CircleIconButton title={$t('select_all')} icon={mdiSelectAll} onclick={handleSelectAll} />
 | 
					      <CircleIconButton title={$t('select_all')} icon={mdiSelectAll} onclick={handleSelectAll} />
 | 
				
			||||||
      <ButtonContextMenu icon={mdiPlus} title={$t('add_to')}>
 | 
					      <ButtonContextMenu icon={mdiPlus} title={$t('add_to')}>
 | 
				
			||||||
        <AddToAlbum />
 | 
					        <AddToAlbum onAddToAlbum={() => cancelMultiselect(assetInteraction)} />
 | 
				
			||||||
        <AddToAlbum shared />
 | 
					        <AddToAlbum onAddToAlbum={() => cancelMultiselect(assetInteraction)} shared />
 | 
				
			||||||
      </ButtonContextMenu>
 | 
					      </ButtonContextMenu>
 | 
				
			||||||
      <FavoriteAction removeFavorite={assetInteraction.isAllFavorite} onFavorite={triggerAssetUpdate} />
 | 
					      <FavoriteAction removeFavorite={assetInteraction.isAllFavorite} onFavorite={triggerAssetUpdate} />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user