From b36a0bd10b5d03caf6b052a173dcb809854db79e Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 10 Dec 2025 18:40:56 +0200 Subject: [PATCH] feat(note_actions): integrate shared switch into new layout --- .../src/widgets/ribbon/BasicPropertiesTab.tsx | 34 +++++++++++-------- .../client/src/widgets/ribbon/NoteActions.tsx | 4 ++- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx b/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx index dc14284f3..f1f51b222 100644 --- a/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx +++ b/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx @@ -32,7 +32,7 @@ export default function BasicPropertiesTab({ note }: TabContext) { {!isNewLayout && } - + {!isNewLayout && } @@ -251,12 +251,29 @@ function TemplateSwitch({ note }: { note?: FNote | null }) { } function SharedSwitch({ note }: { note?: FNote | null }) { + const [ isShared, switchShareState ] = useShareState(note); + + return ( +
+ +
+ ); +} + +export function useShareState(note: FNote | null | undefined) { const [ isShared, setIsShared ] = useState(false); const refreshState = useCallback(() => { setIsShared(!!note?.hasAncestor("_share")); }, [ note ]); - useEffect(() => refreshState(), [ note ]); + useEffect(() => refreshState(), [ refreshState ]); useTriliumEvent("entitiesReloaded", ({ loadResults }) => { if (note && loadResults.getBranchRows().find((b) => b.noteId === note.noteId)) { refreshState(); @@ -281,18 +298,7 @@ function SharedSwitch({ note }: { note?: FNote | null }) { sync.syncNow(true); }, [ note ]); - return ( -
- -
- ) + return [ isShared, switchShareState ] as const; } function NoteLanguageSwitch({ note }: { note?: FNote | null }) { diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsx index ee5c949d7..8cf1ffbeb 100644 --- a/apps/client/src/widgets/ribbon/NoteActions.tsx +++ b/apps/client/src/widgets/ribbon/NoteActions.tsx @@ -17,7 +17,7 @@ import { FormDropdownDivider, FormDropdownSubmenu, FormListItem, FormListTogglea import { useIsNoteReadOnly, useNoteContext, useNoteLabel, useNoteProperty, useTriliumOption } from "../react/hooks"; import { ParentComponent } from "../react/react_utils"; import { isExperimentalFeatureEnabled } from "../../services/experimental_features"; -import { useNoteBookmarkState } from "./BasicPropertiesTab"; +import { useNoteBookmarkState, useShareState } from "./BasicPropertiesTab"; const isNewLayout = isExperimentalFeatureEnabled("new-layout"); @@ -118,9 +118,11 @@ function NoteContextMenu({ note, noteContext }: { note: FNote, noteContext?: Not function NoteBasicProperties({ note }: { note: FNote }) { const [ isBookmarked, setIsBookmarked ] = useNoteBookmarkState(note); + const [ isShared, switchShareState ] = useShareState(note); return <> + ; }