mirror of
https://github.com/zadam/trilium.git
synced 2025-12-02 05:24:23 +01:00
fix(backlinks): not refreshed after inserting a new link
This commit is contained in:
parent
98241fb54b
commit
5a0beec6cb
@ -18,6 +18,7 @@ import froca from "../services/froca";
|
|||||||
import NoteLink from "./react/NoteLink";
|
import NoteLink from "./react/NoteLink";
|
||||||
import RawHtml from "./react/RawHtml";
|
import RawHtml from "./react/RawHtml";
|
||||||
import { ViewTypeOptions } from "./collections/interface";
|
import { ViewTypeOptions } from "./collections/interface";
|
||||||
|
import attributes from "../services/attributes";
|
||||||
|
|
||||||
export interface FloatingButtonContext {
|
export interface FloatingButtonContext {
|
||||||
parentComponent: Component;
|
parentComponent: Component;
|
||||||
@ -310,13 +311,24 @@ function Backlinks({ note, isDefaultViewMode }: FloatingButtonContext) {
|
|||||||
let [ popupOpen, setPopupOpen ] = useState(false);
|
let [ popupOpen, setPopupOpen ] = useState(false);
|
||||||
const backlinksContainerRef = useRef<HTMLDivElement>(null);
|
const backlinksContainerRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
function refresh() {
|
||||||
if (!isDefaultViewMode) return;
|
if (!isDefaultViewMode) return;
|
||||||
|
|
||||||
server.get<BacklinkCountResponse>(`note-map/${note.noteId}/backlink-count`).then(resp => {
|
server.get<BacklinkCountResponse>(`note-map/${note.noteId}/backlink-count`).then(resp => {
|
||||||
setBacklinkCount(resp.count);
|
setBacklinkCount(resp.count);
|
||||||
});
|
});
|
||||||
}, [ note ]);
|
}
|
||||||
|
|
||||||
|
useEffect(() => refresh(), [ note ]);
|
||||||
|
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
|
||||||
|
loadResults.getAttributeRows().some(attr =>
|
||||||
|
attr.type === "relation" &&
|
||||||
|
attr.name === "internalLink" &&
|
||||||
|
attributes.isAffecting(attr, note))
|
||||||
|
{
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Determine the max height of the container.
|
// Determine the max height of the container.
|
||||||
const { windowHeight } = useWindowSize();
|
const { windowHeight } = useWindowSize();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user