fix: fix unread count on Header and roomListView (#5588)
* chore: add hideUnreadStatus to unreadsCount logic * fix: sets the value of unreadStatus when it does not come from the backend
This commit is contained in:
parent
94807ef05b
commit
645b188df8
|
@ -182,6 +182,11 @@ const createOrUpdateSubscription = async (subscription: ISubscription, room: ISe
|
||||||
s.bannerClosed = false;
|
s.bannerClosed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (sub.hideUnreadStatus) {
|
||||||
|
if (sub.hideUnreadStatus !== subscription.hideUnreadStatus) {
|
||||||
|
s.hideUnreadStatus = !!subscription.hideUnreadStatus;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
batch.push(update);
|
batch.push(update);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -867,11 +867,13 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
||||||
.query(Q.where('archived', false), Q.where('open', true), Q.where('rid', Q.notEq(this.rid)))
|
.query(Q.where('archived', false), Q.where('open', true), Q.where('rid', Q.notEq(this.rid)))
|
||||||
.observeWithColumns(['unread']);
|
.observeWithColumns(['unread']);
|
||||||
|
|
||||||
this.queryUnreads = observable.subscribe(data => {
|
this.queryUnreads = observable.subscribe(rooms => {
|
||||||
const { unreadsCount } = this.state;
|
const unreadsCount = rooms.reduce(
|
||||||
const newUnreadsCount = data.filter(s => s.unread > 0).reduce((a, b) => a + (b.unread || 0), 0);
|
(unreadCount, room) => (room.unread > 0 && !room.hideUnreadStatus ? unreadCount + room.unread : unreadCount),
|
||||||
if (unreadsCount !== newUnreadsCount) {
|
0
|
||||||
this.setState({ unreadsCount: newUnreadsCount }, () => this.setHeader());
|
);
|
||||||
|
if (this.state.unreadsCount !== unreadsCount) {
|
||||||
|
this.setState({ unreadsCount }, this.setHeader);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue