fix(ui): propagate photo tag edits to grid and viewer
Add a shared photo-updates signal the panel publishes on rename or tag add/remove; the album grid and viewer subscribe and patch the changed photo into their lists, so the 360 badge and panorama mode update without a reload.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { goto } from '$app/navigation';
|
||||
import { tick } from 'svelte';
|
||||
import { tick, untrack } from 'svelte';
|
||||
import { api, photosApi } from '$lib/api';
|
||||
import PhotoGrid from '$lib/components/PhotoGrid.svelte';
|
||||
import ConfirmDialog from '$lib/components/ConfirmDialog.svelte';
|
||||
@@ -12,6 +12,7 @@
|
||||
import { albums } from '$lib/stores/albums.svelte';
|
||||
import { density } from '$lib/stores/density.svelte';
|
||||
import { selection } from '$lib/stores/selection.svelte';
|
||||
import { photoUpdates } from '$lib/stores/photo-updates.svelte';
|
||||
import { viewerReturn } from '$lib/stores/viewer-return';
|
||||
import { transfer } from '$lib/stores/transfer.svelte';
|
||||
import { contextMenu, type ContextMenuItem } from '$lib/stores/context-menu.svelte';
|
||||
@@ -80,6 +81,18 @@
|
||||
});
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
// Patch a photo edited in the panel (e.g. tags) into the grid list so
|
||||
// derived UI like the 360 badge updates without a reload. Read the list
|
||||
// untracked so writing it cannot re-trigger this effect.
|
||||
const updated = photoUpdates.latest;
|
||||
if (!updated) return;
|
||||
const list = untrack(() => photos);
|
||||
if (list.some((p) => p.id === updated.id)) {
|
||||
photos = list.map((p) => (p.id === updated.id ? updated : p));
|
||||
}
|
||||
});
|
||||
|
||||
let client: SSEClient | null = null;
|
||||
|
||||
$effect(() => {
|
||||
|
||||
Reference in New Issue
Block a user