From c0fb9aa4ba35e659c2794b37bfe6a720bdef54b2 Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Fri, 13 Aug 2021 19:09:37 +0200 Subject: [PATCH] [MM-37840, MM-37841] do not mark channel as read when clearing push notifications (#5623) (#5624) * MM-37840 do not mark channel as read when clearing push notifications * MM-37841 prevent from setting the edit post screen buttons with every key press (cherry picked from commit a44a19d125cde228b109f4dd18e22762e2f370ae) Co-authored-by: Elias Nahum --- app/components/network_indicator/network.tsx | 4 +++- app/screens/edit_post/edit_post.js | 13 +++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/components/network_indicator/network.tsx b/app/components/network_indicator/network.tsx index 765bde39c..348a575a0 100644 --- a/app/components/network_indicator/network.tsx +++ b/app/components/network_indicator/network.tsx @@ -193,7 +193,9 @@ const NetworkIndicator = ({ useEffect(() => { if (channelId) { - clearNotificationTimeout.current = setTimeout(clearNotifications, 1500); + clearNotificationTimeout.current = setTimeout(() => { + PushNotifications.clearChannelNotifications(channelId); + }, 1500); } return () => { diff --git a/app/screens/edit_post/edit_post.js b/app/screens/edit_post/edit_post.js index 08dc18809..44fb2d989 100644 --- a/app/screens/edit_post/edit_post.js +++ b/app/screens/edit_post/edit_post.js @@ -68,6 +68,7 @@ export default class EditPost extends PureComponent { this.rightButton.color = props.theme.sidebarHeaderTextColor; this.rightButton.text = context.intl.formatMessage({id: 'edit_post.save', defaultMessage: 'Save'}); + this.rightButtonEnabled = true; setButtons(props.componentId, { leftButtons: [{...this.leftButton, icon: props.closeButton}], @@ -99,14 +100,18 @@ export default class EditPost extends PureComponent { emitCanEditPost = (enabled) => { const {componentId} = this.props; - setButtons(componentId, { - leftButtons: [{...this.leftButton, icon: this.props.closeButton}], - rightButtons: [{...this.rightButton, enabled}], - }); + if (this.rightButtonEnabled !== enabled) { + this.rightButtonEnabled = enabled; + setButtons(componentId, { + leftButtons: [{...this.leftButton, icon: this.props.closeButton}], + rightButtons: [{...this.rightButton, enabled}], + }); + } }; emitEditing = (loading) => { const {componentId} = this.props; + this.rightButtonEnabled = !loading; setButtons(componentId, { leftButtons: [{...this.leftButton, icon: this.props.closeButton}], rightButtons: [{...this.rightButton, enabled: !loading}],