From 73136f20b5d3498c8386c967d0cf2ddd52e151f7 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Wed, 28 Apr 2021 12:18:29 +0300 Subject: [PATCH] remove deleted comments from ui without refresh --- src/js/components/PublicMessage.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/js/components/PublicMessage.js b/src/js/components/PublicMessage.js index 8bb731dd..13c73d10 100644 --- a/src/js/components/PublicMessage.js +++ b/src/js/components/PublicMessage.js @@ -50,11 +50,16 @@ class PublicMessage extends Message { this.setState(s); }); State.public.user(key).get('replies').get(this.props.hash).map().on((hash,time,b,e) => { - if (!hash || this.replies[hash]) return; - this.replies[hash] = {hash, time}; + const k = key + time; + if (hash && this.replies[k]) return; + if (hash) { + this.replies[k] = {hash, time}; + } else { + delete this.replies[k]; + } this.eventListeners[key+'replies'] = e; const sortedReplies = Object.values(this.replies).sort((a,b) => a.time > b.time ? 1 : -1); - this.setState({replies: Object.keys(this.replies).length, sortedReplies }); + this.setState({replyCount: Object.keys(this.replies).length, sortedReplies }); }); }); if (msg.torrentId && Session.settings.local.enableWebtorrent) { @@ -191,7 +196,7 @@ class PublicMessage extends Message { ${replyIcon} this.toggleReplies()}> - ${this.state.replies || ''} + ${this.state.replyCount || ''} this.likeBtnClicked(e)}> ${this.state.liked ? heartFull : heartEmpty}