revert evictFromCache, add back delay + marks invalidation
Remove evictFromCache entirely - the cache-manipulation approach was brittle and broke both archive (photos not removed) and tags (colors/ratings showing empty). Replace with: 200ms delay before invalidation to let PhotoPrism's indexer process the change, plus invalidateQueries(['marks']) so tag caches (colors, ratings, notes) refresh alongside the photo timeline.
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
import { useQueryClient } from '@tanstack/svelte-query';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { batchArchive } from '$lib/services/photoprism';
|
||||
import { evictFromCache } from '$lib/services/bulk';
|
||||
import { startBulk, doneBulk, failBulk } from '$lib/stores/bulkAction.svelte';
|
||||
import PhotoGrid from '$lib/components/timeline/PhotoGrid.svelte';
|
||||
import { type ReviewGroup } from '$lib/services/adapters/review';
|
||||
@@ -36,11 +35,11 @@
|
||||
startBulk(`Archiving…`, uids);
|
||||
try {
|
||||
await batchArchive(uids);
|
||||
evictFromCache(uids);
|
||||
doneBulk(`Archived ${uids.length}`, uids);
|
||||
toast.success(`Archived ${uids.length}`, { id: tid });
|
||||
void qc.invalidateQueries({ queryKey: ['review-groups'] });
|
||||
void qc.invalidateQueries({ queryKey: ['photos'] });
|
||||
void qc.invalidateQueries({ queryKey: ['marks'] });
|
||||
} catch (err) {
|
||||
failBulk(uids);
|
||||
toast.error(err instanceof Error ? err.message : 'Archive all failed', { id: tid });
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
} from '$lib/services/photoprism';
|
||||
import { batchEdit } from '$lib/services/batch';
|
||||
import { acceptDateAndKeep, cachedPhoto } from '$lib/services/photoActions';
|
||||
import { evictFromCache } from '$lib/services/bulk';
|
||||
import { suggestDateFromPath } from '$lib/utils/suggestDateFromPath';
|
||||
import { photoNameAndDir } from '$lib/types/photoprism';
|
||||
import {
|
||||
@@ -130,6 +129,7 @@
|
||||
const result = await fn();
|
||||
if (bulk) {
|
||||
doneBulk(bulk.doneLabel, bulk.ids);
|
||||
await delay(200);
|
||||
}
|
||||
return result;
|
||||
} catch (e) {
|
||||
@@ -138,6 +138,8 @@
|
||||
} finally {
|
||||
busy = false;
|
||||
void qc.invalidateQueries({ queryKey: ['photos'] });
|
||||
void qc.invalidateQueries({ queryKey: ['marks'] });
|
||||
void qc.invalidateQueries({ queryKey: ['review-groups'] });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +154,6 @@
|
||||
setDetail(p?.FileName ?? completedId);
|
||||
}
|
||||
});
|
||||
evictFromCache(ids);
|
||||
if (errors.length) {
|
||||
toast.error(`Kept ${updated.length}; ${errors.length} failed`, { id: tid });
|
||||
} else {
|
||||
@@ -180,7 +181,6 @@
|
||||
await withBusy(async () => {
|
||||
try {
|
||||
await batchArchive(ids);
|
||||
evictFromCache(ids);
|
||||
pushUndo(`Archived ${ids.length}`, async () => {
|
||||
await batchRestore(ids);
|
||||
void qc.invalidateQueries({ queryKey: ['photos'] });
|
||||
@@ -206,7 +206,6 @@
|
||||
await withBusy(async () => {
|
||||
try {
|
||||
await batchDelete(ids);
|
||||
evictFromCache(ids);
|
||||
focusAfter(ids);
|
||||
clearSelection();
|
||||
toast.success(`Deleted ${ids.length}`, { id: tid });
|
||||
@@ -223,7 +222,6 @@
|
||||
await withBusy(async () => {
|
||||
try {
|
||||
await batchRestore(ids);
|
||||
evictFromCache(ids);
|
||||
pushUndo(`Restored ${ids.length}`, async () => {
|
||||
await batchArchive(ids);
|
||||
void qc.invalidateQueries({ queryKey: ['photos'] });
|
||||
|
||||
Reference in New Issue
Block a user