Skip to content

Commit

Permalink
comments: fix child comment success alert shown again when hiding and
Browse files Browse the repository at this point in the history
then showing replies.

fixes #1523
  • Loading branch information
goapunk authored and hom3mad3 committed Aug 7, 2024
1 parent 2fa6661 commit b4065f1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
17 changes: 8 additions & 9 deletions adhocracy4/comments_async/static/comments_async/comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,18 @@ export default class Comment extends React.Component {
this.state = {
edit: false,
showChildComments: false,
displayNotification: this.props.displayNotification,
shorten: true,
anchored: false,
showModStatement: true,
moderatorFeedback: this.props.moderatorFeedback
}

setTimeout(
function () {
this.setState({ displayNotification: false })
}
.bind(this),
2000
)
if (this.props.displayNotification) {
setTimeout(
() => {
props.hideNotification(this.props.index, this.props.parentIndex)
}, 2000)
}
}

componentDidMount () {
Expand Down Expand Up @@ -311,7 +309,7 @@ export default class Comment extends React.Component {

return (
<li>
{this.state.displayNotification &&
{this.props.displayNotification &&
<div className="alert alert--success a4-comments__success-notification"><i className="fas fa-check" /> {translated.successMessage}</div>}
<div className={(this.props.is_users_own_comment ? 'a4-comments__comment a4-comments__comment-owner' : 'a4-comments__comment')}>
<a className="a4-comments__anchor" id={'comment_' + this.props.id} href={'./?comment=' + this.props.id}>{'Comment ' + this.props.id}</a>
Expand Down Expand Up @@ -436,6 +434,7 @@ export default class Comment extends React.Component {
orgTermsUrl={this.props.orgTermsUrl}
setCommentError={this.props.setCommentError}
setCommentEditError={this.props.setCommentEditError}
hideNotification={this.props.hideNotification}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ export const CommentBox = (props) => {
setEditError(parentIndex, index, undefined)
}

function handleHideNotification (index, parentIndex) {
updateStateComment(parentIndex, index, { displayNotification: false })
}

function handleToggleFilters (e) {
e.preventDefault()
setShowFilters(!showFilters)
Expand Down Expand Up @@ -459,6 +463,7 @@ export const CommentBox = (props) => {
agreedTermsOfUse={agreedTermsOfUse}
orgTermsUrl={orgTermsUrl}
setCommentError={setMainError}
hideNotification={handleHideNotification}
/>
</div>
<div>
Expand Down Expand Up @@ -512,6 +517,7 @@ export const CommentBox = (props) => {
orgTermsUrl={orgTermsUrl}
setCommentError={setMainError}
setCommentEditError={setEditError}
hideNotification={handleHideNotification}
/>
<div className={loading ? 'u-spinner__container' : 'd-none'}>
<i className="fa fa-spinner fa-pulse" aria-hidden="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const CommentList = (props) => {
orgTermsUrl={props.orgTermsUrl}
setCommentError={props.setCommentError}
setCommentEditError={props.setCommentEditError}
hideNotification={props.hideNotification}
>{comment.comment}
</Comment>
)
Expand Down
4 changes: 4 additions & 0 deletions changelog/1523.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Fixed

- fix child comment success alert shown again after hiding and then showing the
replies again. (#1532)

0 comments on commit b4065f1

Please sign in to comment.