From d715967bdd4f951145bfec0f53a109017b5f6a07 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Sat, 30 Apr 2022 06:15:57 +0500 Subject: [PATCH] update notifications map on unread activity count increase --- .../container/notificationContainer.js | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/screens/notification/container/notificationContainer.js b/src/screens/notification/container/notificationContainer.js index f849121c0..c85278269 100644 --- a/src/screens/notification/container/notificationContainer.js +++ b/src/screens/notification/container/notificationContainer.js @@ -181,14 +181,25 @@ class NotificationContainer extends Component { }; UNSAFE_componentWillReceiveProps(nextProps) { - const { selectedFilter } = this.state; + const { selectedFilter, notificationsMap } = this.state; const { currentAccount } = this.props; - if ( - currentAccount && - nextProps.currentAccount && - nextProps.currentAccount.name !== currentAccount.name - ) { - this.setState({ endOfNotification: false }, () => this._getActivities(selectedFilter)); + if (currentAccount && nextProps.currentAccount) { + if (nextProps.currentAccount.name !== currentAccount.name) { + this.setState( + { + endOfNotification: false, + notificationsMap: new Map(), + }, + () => this._getActivities(selectedFilter), + ); + } else if ( + nextProps.currentAccount.unread_activity_count > currentAccount.unread_activity_count + ) { + notificationsMap.forEach((value, key) => { + console.log('fetching new activities for ', key); + this._getActivities(key, false, true); + }); + } } }