diff --git a/src/public/app/widgets/floating_buttons/zpetne_odkazy.js b/src/public/app/widgets/floating_buttons/zpetne_odkazy.ts similarity index 82% rename from src/public/app/widgets/floating_buttons/zpetne_odkazy.js rename to src/public/app/widgets/floating_buttons/zpetne_odkazy.ts index 5f4bcf3b3..8f19b37d3 100644 --- a/src/public/app/widgets/floating_buttons/zpetne_odkazy.js +++ b/src/public/app/widgets/floating_buttons/zpetne_odkazy.ts @@ -7,6 +7,7 @@ import NoteContextAwareWidget from "../note_context_aware_widget.js"; import linkService from "../../services/link.js"; import server from "../../services/server.js"; import froca from "../../services/froca.js"; +import type FNote from "../../entities/fnote.js"; const TPL = `
+ `; +// TODO: Deduplicate with server +interface Backlink { + noteId: string; + relationName?: string; + excerpts?: string[]; +} + export default class BacklinksWidget extends NoteContextAwareWidget { + + private $count!: JQuery").text(`${t("zpetne_odkazy.relation")}: ${backlink.relationName}`)); } else { - $item.append(...backlink.excerpts); + $item.append(...backlink.excerpts ?? []); } this.$items.append($item); diff --git a/src/routes/api/note_map.ts b/src/routes/api/note_map.ts index b08c03d1f..684227009 100644 --- a/src/routes/api/note_map.ts +++ b/src/routes/api/note_map.ts @@ -6,6 +6,12 @@ import type BNote from "../../becca/entities/bnote.js"; import type BAttribute from "../../becca/entities/battribute.js"; import type { Request } from "express"; +interface Backlink { + noteId: string; + relationName?: string; + excerpts?: string[]; +} + function buildDescendantCountMap(noteIdsToCount: string[]) { if (!Array.isArray(noteIdsToCount)) { throw new Error("noteIdsToCount: type error"); @@ -325,7 +331,7 @@ function findExcerpts(sourceNote: BNote, referencedNoteId: string) { return excerpts; } -function getFilteredBacklinks(note: BNote) { +function getFilteredBacklinks(note: BNote): BAttribute[] { return ( note .getTargetRelations() @@ -344,7 +350,7 @@ function getBacklinkCount(req: Request) { }; } -function getBacklinks(req: Request) { +function getBacklinks(req: Request): Backlink[] { const { noteId } = req.params; const note = becca.getNoteOrThrow(noteId);