update notifications map on unread activity count increase

This commit is contained in:
noumantahir 2022-04-30 06:15:57 +05:00
parent b4153f0ff1
commit d715967bdd

View File

@ -181,14 +181,25 @@ class NotificationContainer extends Component {
}; };
UNSAFE_componentWillReceiveProps(nextProps) { UNSAFE_componentWillReceiveProps(nextProps) {
const { selectedFilter } = this.state; const { selectedFilter, notificationsMap } = this.state;
const { currentAccount } = this.props; const { currentAccount } = this.props;
if ( if (currentAccount && nextProps.currentAccount) {
currentAccount && if (nextProps.currentAccount.name !== currentAccount.name) {
nextProps.currentAccount && this.setState(
nextProps.currentAccount.name !== currentAccount.name {
) { endOfNotification: false,
this.setState({ endOfNotification: false }, () => this._getActivities(selectedFilter)); 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);
});
}
} }
} }