fix(ribbon): not visible when coming from view source on same note

This commit is contained in:
Elian Doran 2025-10-01 19:40:03 +03:00
parent ae0bb78b1c
commit efcd54be50
No known key found for this signature in database
2 changed files with 4 additions and 1 deletions

View File

@ -36,7 +36,7 @@ async function getLinkIcon(noteId: string, viewMode: ViewMode | undefined) {
}
// TODO: Remove `string` once all the view modes have been mapped.
type ViewMode = "default" | "source" | "attachments" | "contextual-help" | string;
export type ViewMode = "default" | "source" | "attachments" | "contextual-help" | string;
export interface ViewScope {
/**

View File

@ -19,6 +19,7 @@ import Mark from "mark.js";
import { DragData } from "../note_tree";
import Component from "../../components/component";
import toast, { ToastOptions } from "../../services/toast";
import { ViewMode } from "../../services/link";
export function useTriliumEvent<T extends EventNames>(eventName: T, handler: (data: EventData<T>) => void) {
const parentComponent = useContext(ParentComponent);
@ -196,6 +197,7 @@ export function useNoteContext() {
const [ noteContext, setNoteContext ] = useState<NoteContext>();
const [ notePath, setNotePath ] = useState<string | null | undefined>();
const [ note, setNote ] = useState<FNote | null | undefined>();
const [ , setViewMode ] = useState<ViewMode>();
const [ refreshCounter, setRefreshCounter ] = useState(0);
useEffect(() => {
@ -205,6 +207,7 @@ export function useNoteContext() {
useTriliumEvents([ "setNoteContext", "activeContextChanged", "noteSwitchedAndActivated", "noteSwitched" ], ({ noteContext }) => {
setNoteContext(noteContext);
setNotePath(noteContext.notePath);
setViewMode(noteContext.viewScope?.viewMode);
});
useTriliumEvent("frocaReloaded", () => {
setNote(noteContext?.note);