From c011637c1e70025966a49a15ecd40873987691db Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 23 Oct 2018 10:55:43 -0700 Subject: [PATCH] Fixed Infinite rendering loop on messages screen --- app/views/messaging/Messaging.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/messaging/Messaging.js b/app/views/messaging/Messaging.js index 9c6884102..e24c65fb4 100644 --- a/app/views/messaging/Messaging.js +++ b/app/views/messaging/Messaging.js @@ -70,13 +70,14 @@ export class Messaging extends Component { } render() { + const { messages, nextTimestamp, unreadMessages } = this.props.messages + const { updateMessages } = this.props + const filteredData = checkData(messages) + // this will clear the notifications badge when the user is on this screen - if (this.props.navigation.isFocused()) { + if (this.props.navigation.isFocused() && unreadMessages) { this.props.setLatestTimeStamp(new Date().getTime()) } - const { messages, nextTimestamp } = this.props.messages - const { updateMessages } = this.props - const filteredData = checkData(messages) let isLoading = false if (this.props.myMessagesStatus) isLoading = true @@ -111,6 +112,7 @@ const mapStateToProps = (state, props) => ( messages: state.messages, myMessagesStatus: state.requestStatuses.GET_MESSAGES, myMessagesError: state.requestErrors.GET_MESSAGES, + unreadMessages: state.unreadMessages } )