|
@@ -22,13 +22,14 @@ type Props = {
|
|
|
isReadOnly : boolean,
|
|
isReadOnly : boolean,
|
|
|
titleAlign?: 'center' | 'left' | 'right',
|
|
titleAlign?: 'center' | 'left' | 'right',
|
|
|
highlightKeywords?:string[],
|
|
highlightKeywords?:string[],
|
|
|
|
|
+ hideIfEmpty?: boolean,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
const PageComment:FC<Props> = memo((props:Props):JSX.Element => {
|
|
const PageComment:FC<Props> = memo((props:Props):JSX.Element => {
|
|
|
|
|
|
|
|
const {
|
|
const {
|
|
|
- appContainer, pageId, highlightKeywords, isReadOnly, titleAlign,
|
|
|
|
|
|
|
+ appContainer, pageId, highlightKeywords, isReadOnly, titleAlign, hideIfEmpty,
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
const { data: comments, mutate } = useSWRxPageComment(pageId);
|
|
const { data: comments, mutate } = useSWRxPageComment(pageId);
|
|
@@ -55,8 +56,6 @@ const PageComment:FC<Props> = memo((props:Props):JSX.Element => {
|
|
|
return highlightedComment;
|
|
return highlightedComment;
|
|
|
}, [highlightKeywords]);
|
|
}, [highlightKeywords]);
|
|
|
|
|
|
|
|
- useEffect(() => { mutate() }, [pageId, mutate]);
|
|
|
|
|
-
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
if (comments != null) {
|
|
if (comments != null) {
|
|
@@ -137,6 +136,10 @@ const PageComment:FC<Props> = memo((props:Props):JSX.Element => {
|
|
|
|
|
|
|
|
if (commentsFromOldest == null || commentsExceptReply == null) return <></>;
|
|
if (commentsFromOldest == null || commentsExceptReply == null) return <></>;
|
|
|
|
|
|
|
|
|
|
+ if (hideIfEmpty && comments?.length === 0) {
|
|
|
|
|
+ return <></>;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
let commentTitleClasses = 'border-bottom py-3 mb-3';
|
|
let commentTitleClasses = 'border-bottom py-3 mb-3';
|
|
|
commentTitleClasses = titleAlign != null ? `${commentTitleClasses} text-${titleAlign}` : `${commentTitleClasses} text-center`;
|
|
commentTitleClasses = titleAlign != null ? `${commentTitleClasses} text-${titleAlign}` : `${commentTitleClasses} text-center`;
|
|
|
|
|
|