From b0bfa94ac803df5904d292035499b23a72f06e65 Mon Sep 17 00:00:00 2001 From: ahammouda Date: Sun, 2 Oct 2022 10:41:14 -0400 Subject: [PATCH] removed redudant use of markup --- src/editor/widgets/comment/CommentWidget.jsx | 28 +++++--------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/editor/widgets/comment/CommentWidget.jsx b/src/editor/widgets/comment/CommentWidget.jsx index 228dde9..fc6d266 100644 --- a/src/editor/widgets/comment/CommentWidget.jsx +++ b/src/editor/widgets/comment/CommentWidget.jsx @@ -87,6 +87,12 @@ const CommentWidget = props => { const onChangeReplyPurpose = purpose => props.onUpdateBody(draftReply, { ...draftReply, purpose: purpose.value }); + // Pre-condition: will be true if the annotation exists, and Annotorious is not in read-only mode + const isReadable = (!props.readOnly && props.annotation); + + // Extra condtion to: reply field exists if there is no comment yet, or disableReply is false. + const hasReply = comments.length === 0 || !props.disableReply; + return ( <> { comments.map((body, idx) => @@ -100,28 +106,8 @@ const CommentWidget = props => { onDelete={props.onRemoveBody} onSaveAndClose={props.onSaveAndClose} /> )} - { comments.length === 0 && !props.readOnly && props.disableReply && props.annotation && -
- props.onSaveAndClose()} - /> - { props.purposeSelector && draftReply.value.length > 0 && - props.onSaveAndClose()} - /> - } -
- } - { !props.readOnly && !props.disableReply && props.annotation && + { isReadable && hasReply &&