diff --git a/apps/client/src/widgets/launch_bar/GenericButtons.tsx b/apps/client/src/widgets/launch_bar/GenericButtons.tsx
index 56fe4daa7..4e09a835c 100644
--- a/apps/client/src/widgets/launch_bar/GenericButtons.tsx
+++ b/apps/client/src/widgets/launch_bar/GenericButtons.tsx
@@ -3,25 +3,23 @@ import FNote from "../../entities/fnote";
import link_context_menu from "../../menus/link_context_menu";
import { escapeHtml, isCtrlKey } from "../../services/utils";
import { useNoteLabel, useNoteProperty } from "../react/hooks";
-import { LaunchBarActionButton } from "./launch_bar_widgets";
+import { LaunchBarActionButton, useLauncherIconAndTitle } from "./launch_bar_widgets";
export function CommandButton({ launcherNote }: { launcherNote: FNote }) {
- const [ iconClass ] = useNoteLabel(launcherNote, "iconClass");
+ const { icon, title } = useLauncherIconAndTitle(launcherNote);
const [ command ] = useNoteLabel(launcherNote, "command");
- const title = useNoteProperty(launcherNote, "title");
- return iconClass && title && command && (
+ return command && (
)
}
export function NoteLauncher({ launcherNote, targetNoteId, hoistedNoteId }: { launcherNote: FNote, targetNoteId: string, hoistedNoteId?: string }) {
- const [ iconClass ] = useNoteLabel(launcherNote, "iconClass");
- const title = useNoteProperty(launcherNote, "title");
+ const { icon, title } = useLauncherIconAndTitle(launcherNote);
async function launch(evt: MouseEvent) {
if (evt.which === 3) {
@@ -38,9 +36,9 @@ export function NoteLauncher({ launcherNote, targetNoteId, hoistedNoteId }: { la
}
}
- return title && iconClass && (
+ return (
(null);
useEffect(() => {
@@ -27,10 +25,10 @@ export default function HistoryNavigationButton({ launcherNote, command }: Histo
}
}, []);
- return iconClass && title && (
+ return (
{
e.preventDefault();
diff --git a/apps/client/src/widgets/launch_bar/launch_bar_widgets.tsx b/apps/client/src/widgets/launch_bar/launch_bar_widgets.tsx
index 1ea64a852..5a72e0f54 100644
--- a/apps/client/src/widgets/launch_bar/launch_bar_widgets.tsx
+++ b/apps/client/src/widgets/launch_bar/launch_bar_widgets.tsx
@@ -1,5 +1,8 @@
+import FNote from "../../entities/fnote";
+import { escapeHtml } from "../../services/utils";
import ActionButton, { ActionButtonProps } from "../react/ActionButton";
import Dropdown, { DropdownProps } from "../react/Dropdown";
+import { useNoteLabel, useNoteProperty } from "../react/hooks";
import Icon from "../react/Icon";
export interface LaunchBarWidgetProps {
@@ -28,3 +31,16 @@ export function LaunchBarDropdownButton({ children, icon, ...props }: Pick{children}
)
}
+
+export function useLauncherIconAndTitle(note: FNote) {
+ const title = useNoteProperty(note, "title");
+
+ // React to changes.
+ useNoteLabel(note, "iconClass");
+ useNoteLabel(note, "workspaceIconClass");
+
+ return {
+ icon: note.getIcon(),
+ title: escapeHtml(title ?? "")
+ };
+}