fix(react/collections/geomap): "note not found" when deleting GPX

This commit is contained in:
Elian Doran
2025-09-13 15:34:32 +03:00
parent dc854cbd10
commit 5bb1432450
5 changed files with 23 additions and 13 deletions

View File

@@ -367,7 +367,7 @@ export function useNoteLabelInt(note: FNote | undefined | null, labelName: strin
]
}
export function useNoteBlob(note: FNote | null | undefined): [ FBlob | null | undefined ] {
export function useNoteBlob(note: FNote | null | undefined): FBlob | null | undefined {
const [ blob, setBlob ] = useState<FBlob | null>();
function refresh() {
@@ -376,14 +376,23 @@ export function useNoteBlob(note: FNote | null | undefined): [ FBlob | null | un
useEffect(refresh, [ note?.noteId ]);
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
if (note && loadResults.hasRevisionForNote(note.noteId)) {
if (!note) return;
// Check if the note was deleted.
if (loadResults.getEntityRow("notes", note.noteId)?.isDeleted) {
setBlob(null);
return;
}
// Check if a revision occurred.
if (loadResults.hasRevisionForNote(note.noteId)) {
refresh();
}
});
useDebugValue(note?.noteId);
return [ blob ] as const;
return blob;
}
export function useLegacyWidget<T extends BasicWidget>(widgetFactory: () => T, { noteContext, containerClassName, containerStyle }: {