fix(server): autocomplete shows empty name for hoisted note

This commit is contained in:
Elian Doran 2025-12-16 12:53:51 +02:00
parent c9025f2304
commit 34343ce356
No known key found for this signature in database

View File

@ -1,21 +1,20 @@
"use strict";
import beccaService from "../../becca/becca_service.js";
import searchService from "../../services/search/services/search.js";
import log from "../../services/log.js";
import utils from "../../services/utils.js";
import cls from "../../services/cls.js";
import becca from "../../becca/becca.js";
import type { Request } from "express"; import type { Request } from "express";
import becca from "../../becca/becca.js";
import beccaService from "../../becca/becca_service.js";
import ValidationError from "../../errors/validation_error.js"; import ValidationError from "../../errors/validation_error.js";
import cls from "../../services/cls.js";
import log from "../../services/log.js";
import searchService from "../../services/search/services/search.js";
import sql from "../../services/sql.js"; import sql from "../../services/sql.js";
import utils from "../../services/utils.js";
function getAutocomplete(req: Request) { function getAutocomplete(req: Request) {
if (typeof req.query.query !== "string") { if (typeof req.query.query !== "string") {
throw new ValidationError("Invalid query data type."); throw new ValidationError("Invalid query data type.");
} }
const query = (req.query.query || "").trim(); const query = (req.query.query || "").trim();
const fastSearch = String(req.query.fastSearch).toLowerCase() === "false" ? false : true; const fastSearch = String(req.query.fastSearch).toLowerCase() !== "false";
const activeNoteId = req.query.activeNoteId || "none"; const activeNoteId = req.query.activeNoteId || "none";
@ -75,7 +74,7 @@ function getRecentNotes(activeNoteId: string) {
notePath: rn.notePath, notePath: rn.notePath,
noteTitle: title, noteTitle: title,
notePathTitle, notePathTitle,
highlightedNotePathTitle: utils.escapeHtml(notePathTitle), highlightedNotePathTitle: utils.escapeHtml(notePathTitle || title),
icon: icon ?? "bx bx-note" icon: icon ?? "bx bx-note"
}; };
}); });