mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
fix(react/collections/geomap): "note not found" when deleting GPX
This commit is contained in:
@@ -907,8 +907,8 @@ export default class FNote {
|
|||||||
return this.getBlob();
|
return this.getBlob();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBlob() {
|
getBlob() {
|
||||||
return await this.froca.getBlob("notes", this.noteId);
|
return this.froca.getBlob("notes", this.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ function NoteGpxTrack({ note }: { note: FNote }) {
|
|||||||
const blob = useNoteBlob(note);
|
const blob = useNoteBlob(note);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!blob) return;
|
||||||
server.get<string | Uint8Array>(`notes/${note.noteId}/open`, undefined, true).then(xmlResponse => {
|
server.get<string | Uint8Array>(`notes/${note.noteId}/open`, undefined, true).then(xmlResponse => {
|
||||||
if (xmlResponse instanceof Uint8Array) {
|
if (xmlResponse instanceof Uint8Array) {
|
||||||
setXmlString(new TextDecoder().decode(xmlResponse));
|
setXmlString(new TextDecoder().decode(xmlResponse));
|
||||||
|
|||||||
@@ -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>();
|
const [ blob, setBlob ] = useState<FBlob | null>();
|
||||||
|
|
||||||
function refresh() {
|
function refresh() {
|
||||||
@@ -376,14 +376,23 @@ export function useNoteBlob(note: FNote | null | undefined): [ FBlob | null | un
|
|||||||
|
|
||||||
useEffect(refresh, [ note?.noteId ]);
|
useEffect(refresh, [ note?.noteId ]);
|
||||||
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
|
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();
|
refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
useDebugValue(note?.noteId);
|
useDebugValue(note?.noteId);
|
||||||
|
|
||||||
return [ blob ] as const;
|
return blob;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useLegacyWidget<T extends BasicWidget>(widgetFactory: () => T, { noteContext, containerClassName, containerStyle }: {
|
export function useLegacyWidget<T extends BasicWidget>(widgetFactory: () => T, { noteContext, containerClassName, containerStyle }: {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import FNote from "../../entities/fnote";
|
|||||||
export default function FilePropertiesTab({ note }: { note?: FNote | null }) {
|
export default function FilePropertiesTab({ note }: { note?: FNote | null }) {
|
||||||
const [ originalFileName ] = useNoteLabel(note, "originalFileName");
|
const [ originalFileName ] = useNoteLabel(note, "originalFileName");
|
||||||
const canAccessProtectedNote = !note?.isProtected || protected_session_holder.isProtectedSessionAvailable();
|
const canAccessProtectedNote = !note?.isProtected || protected_session_holder.isProtectedSessionAvailable();
|
||||||
const [ blob ] = useNoteBlob(note);
|
const blob = useNoteBlob(note);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="file-properties-widget">
|
<div className="file-properties-widget">
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import toast from "../../services/toast";
|
|||||||
|
|
||||||
export default function ImagePropertiesTab({ note, ntxId }: TabContext) {
|
export default function ImagePropertiesTab({ note, ntxId }: TabContext) {
|
||||||
const [ originalFileName ] = useNoteLabel(note, "originalFileName");
|
const [ originalFileName ] = useNoteLabel(note, "originalFileName");
|
||||||
const [ blob ] = useNoteBlob(note);
|
const blob = useNoteBlob(note);
|
||||||
|
|
||||||
const parentComponent = useContext(ParentComponent);
|
const parentComponent = useContext(ParentComponent);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user