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 <>
+
>;
}