chore: add hideUnreadStatus to unreadsCount logic

This commit is contained in:
GleidsonDaniel 2024-02-21 13:15:40 -03:00
parent 116c217675
commit d6240fba25
1 changed files with 7 additions and 5 deletions

View File

@ -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)))
.observeWithColumns(['unread']);
this.queryUnreads = observable.subscribe(data => {
const { unreadsCount } = this.state;
const newUnreadsCount = data.filter(s => s.unread > 0).reduce((a, b) => a + (b.unread || 0), 0);
if (unreadsCount !== newUnreadsCount) {
this.setState({ unreadsCount: newUnreadsCount }, () => this.setHeader());
this.queryUnreads = observable.subscribe(rooms => {
const unreadsCount = rooms.reduce(
(unreadCount, room) => (room.unread > 0 && !room.hideUnreadStatus ? unreadCount + room.unread : unreadCount),
0
);
if (this.state.unreadsCount !== unreadsCount) {
this.setState({ unreadsCount }, this.setHeader);
}
});
};