feat(tab_navigation): display note icon in history navigation

This commit is contained in:
Elian Doran 2025-12-09 15:02:52 +02:00
parent 5c8132088f
commit 24806a810c
No known key found for this signature in database

View File

@ -1,5 +1,5 @@
import type { WebContents } from "electron"; import type { WebContents } from "electron";
import { useCallback, useMemo } from "preact/hooks"; import { useMemo } from "preact/hooks";
import FNote from "../../entities/fnote"; import FNote from "../../entities/fnote";
import contextMenu, { MenuCommandItem } from "../../menus/context_menu"; import contextMenu, { MenuCommandItem } from "../../menus/context_menu";
@ -7,6 +7,7 @@ import link from "../../services/link";
import tree from "../../services/tree"; import tree from "../../services/tree";
import { dynamicRequire } from "../../services/utils"; import { dynamicRequire } from "../../services/utils";
import { LaunchBarActionButton, useLauncherIconAndTitle } from "./launch_bar_widgets"; import { LaunchBarActionButton, useLauncherIconAndTitle } from "./launch_bar_widgets";
import froca from "../../services/froca";
interface HistoryNavigationProps { interface HistoryNavigationProps {
launcherNote: FNote; launcherNote: FNote;
@ -43,20 +44,19 @@ export function handleHistoryContextMenu(webContents: WebContents) {
const activeIndex = webContents.navigationHistory.getActiveIndex(); const activeIndex = webContents.navigationHistory.getActiveIndex();
for (const idx in history) { for (const idx in history) {
const { notePath } = link.parseNavigationStateFromUrl(history[idx].url); const { noteId, notePath } = link.parseNavigationStateFromUrl(history[idx].url);
if (!notePath) continue; if (!noteId || !notePath) continue;
const title = await tree.getNotePathTitle(notePath); const title = await tree.getNotePathTitle(notePath);
const index = parseInt(idx, 10); const index = parseInt(idx, 10);
const note = froca.getNoteFromCache(noteId);
items.push({ items.push({
title, title,
command: idx, command: idx,
checked: index === activeIndex, checked: index === activeIndex,
enabled: index !== activeIndex, enabled: index !== activeIndex,
uiIcon: index !== activeIndex && index < activeIndex uiIcon: note?.getIcon()
? "bx bx-left-arrow-alt"
: "bx bx-right-arrow-alt"
}); });
} }