Skip to content

Build your personal knowledge base with Trilium Notes

feat(tray): show a list of bookmarks

Elian Dorancd0c79e3d263
diff --git a/src/services/tray.ts b/src/services/tray.ts
index 992d67053b..9378d85939 100644
--- a/src/services/tray.ts
+++ b/src/services/tray.ts
@@ -6,6 +6,7 @@ import { fileURLToPath } from "url";
import type { KeyboardActionNames } from "./keyboard_actions_interface.js";
import date_notes from "./date_notes.js";
import type BNote from "../becca/entities/bnote.js";
+import becca from "../becca/becca.js";
let tray: Tray;
// `mainWindow.isVisible` doesn't work with `mainWindow.show` and `mainWindow.hide` - it returns `false` when the window
@@ -64,6 +65,26 @@ function updateTrayMenu() {
mainWindow?.webContents.send("openInSameTab", note.noteId);
}
+ function buildBookmarksMenu() {
+ const parentNote = becca.getNoteOrThrow("_lbBookmarks");
+ const menuItems: Electron.MenuItemConstructorOptions[] = [];
+
+ for (const bookmarkNote of parentNote?.children) {
+ if (bookmarkNote.isLabelTruthy("bookmarkFolder")) {
+ // Ignore bookmark folders for now.
+ continue;
+ }
+
+ menuItems.push({
+ label: bookmarkNote.title,
+ type: "normal",
+ click: () => openInSameTab(bookmarkNote)
+ });
+ }
+
+ return menuItems;
+ }
+
const contextMenu = Menu.buildFromTemplate([
{
label: "New Note",
@@ -75,6 +96,11 @@ function updateTrayMenu() {
type: "normal",
click: () => openInSameTab(date_notes.getTodayNote())
},
+ {
+ label: "Bookmarks",
+ type: "submenu",
+ submenu: buildBookmarksMenu()
+ },
{ type: "separator" },
{
label: isVisible ? "Hide" : "Show",