diff --git a/app/lib/methods/subscriptions/rooms.ts b/app/lib/methods/subscriptions/rooms.ts index 082adc466..efa8df02c 100644 --- a/app/lib/methods/subscriptions/rooms.ts +++ b/app/lib/methods/subscriptions/rooms.ts @@ -182,6 +182,11 @@ const createOrUpdateSubscription = async (subscription: ISubscription, room: ISe s.bannerClosed = false; } } + if (sub.hideUnreadStatus) { + if (sub.hideUnreadStatus !== subscription.hideUnreadStatus) { + s.hideUnreadStatus = !!subscription.hideUnreadStatus; + } + } }); batch.push(update); } catch (e) { diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index 31558efec..8c719365c 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -867,11 +867,13 @@ class RoomView extends React.Component { .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); } }); };