fix: remove unread subscriptions on un-subscribe

This commit is contained in:
Sean Yesmunt 2018-11-01 18:36:24 -04:00
parent c4adce2524
commit 6e88160e04

View file

@ -41,13 +41,18 @@ export default handleActions(
action: DoChannelUnsubscribe
): SubscriptionState => {
const subscriptionToRemove: Subscription = action.data;
const newSubscriptions = state.subscriptions
.slice()
.filter(subscription => subscription.channelName !== subscriptionToRemove.channelName);
// Check if we need to remove it from the 'unread' state
const { unread } = state.unread;
if (unread[subscriptionToRemove.uri]) {
delete unread[subscriptionToRemove.uri];
}
return {
...state,
...unread,
subscriptions: newSubscriptions,
};
},