mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
fix: inherits memo visibility for default comment visibility (#4728)
This commit is contained in:
@@ -40,6 +40,8 @@ export interface Props {
|
|||||||
memoName?: string;
|
memoName?: string;
|
||||||
// The name of the parent memo if the memo is a comment.
|
// The name of the parent memo if the memo is a comment.
|
||||||
parentMemoName?: string;
|
parentMemoName?: string;
|
||||||
|
// The visibility of the parent memo for preset when commenting
|
||||||
|
parentMemoVisibility?: Visibility;
|
||||||
autoFocus?: boolean;
|
autoFocus?: boolean;
|
||||||
onConfirm?: (memoName: string) => void;
|
onConfirm?: (memoName: string) => void;
|
||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
@@ -57,12 +59,12 @@ interface State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const MemoEditor = observer((props: Props) => {
|
const MemoEditor = observer((props: Props) => {
|
||||||
const { className, cacheKey, memoName, parentMemoName, autoFocus, onConfirm, onCancel } = props;
|
const { className, cacheKey, memoName, parentMemoName, parentMemoVisibility, autoFocus, onConfirm, onCancel } = props;
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
const currentUser = useCurrentUser();
|
const currentUser = useCurrentUser();
|
||||||
const [state, setState] = useState<State>({
|
const [state, setState] = useState<State>({
|
||||||
memoVisibility: Visibility.PRIVATE,
|
memoVisibility: parentMemoVisibility ?? Visibility.PRIVATE,
|
||||||
resourceList: [],
|
resourceList: [],
|
||||||
relationList: [],
|
relationList: [],
|
||||||
location: undefined,
|
location: undefined,
|
||||||
@@ -96,7 +98,7 @@ const MemoEditor = observer((props: Props) => {
|
|||||||
}, [autoFocus]);
|
}, [autoFocus]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let visibility = userSetting.memoVisibility;
|
let visibility = parentMemoVisibility ?? userSetting.memoVisibility;
|
||||||
if (workspaceMemoRelatedSetting.disallowPublicVisibility && visibility === "PUBLIC") {
|
if (workspaceMemoRelatedSetting.disallowPublicVisibility && visibility === "PUBLIC") {
|
||||||
visibility = "PRIVATE";
|
visibility = "PRIVATE";
|
||||||
}
|
}
|
||||||
@@ -104,7 +106,7 @@ const MemoEditor = observer((props: Props) => {
|
|||||||
...prevState,
|
...prevState,
|
||||||
memoVisibility: convertVisibilityFromString(visibility),
|
memoVisibility: convertVisibilityFromString(visibility),
|
||||||
}));
|
}));
|
||||||
}, [userSetting.memoVisibility, workspaceMemoRelatedSetting.disallowPublicVisibility]);
|
}, [parentMemoVisibility, userSetting.memoVisibility, workspaceMemoRelatedSetting.disallowPublicVisibility]);
|
||||||
|
|
||||||
useAsyncEffect(async () => {
|
useAsyncEffect(async () => {
|
||||||
if (!memoName) {
|
if (!memoName) {
|
||||||
|
@@ -160,6 +160,7 @@ const MemoDetail = observer(() => {
|
|||||||
cacheKey={`${memo.name}-${memo.updateTime}-comment`}
|
cacheKey={`${memo.name}-${memo.updateTime}-comment`}
|
||||||
placeholder={t("editor.add-your-comment-here")}
|
placeholder={t("editor.add-your-comment-here")}
|
||||||
parentMemoName={memo.name}
|
parentMemoName={memo.name}
|
||||||
|
parentMemoVisibility={memo.visibility}
|
||||||
autoFocus
|
autoFocus
|
||||||
onConfirm={handleCommentCreated}
|
onConfirm={handleCommentCreated}
|
||||||
onCancel={() => setShowCommentEditor(false)}
|
onCancel={() => setShowCommentEditor(false)}
|
||||||
|
Reference in New Issue
Block a user