web/statestore: clear unread counts when clearing state

This commit is contained in:
Tulir Asokan 2025-01-02 11:07:04 +02:00
parent c3899d0b50
commit 021236592f
2 changed files with 5 additions and 0 deletions

View file

@ -537,6 +537,7 @@ export class StateStore {
this.rooms.clear() this.rooms.clear()
this.inviteRooms.clear() this.inviteRooms.clear()
this.spaceEdges.clear() this.spaceEdges.clear()
this.pseudoSpaces.forEach(space => space.clearUnreads())
this.roomList.emit([]) this.roomList.emit([])
this.topLevelSpaces.emit([]) this.topLevelSpaces.emit([])
this.accountData.clear() this.accountData.clear()

View file

@ -40,6 +40,10 @@ export abstract class Space implements RoomListFilter {
abstract id: string abstract id: string
abstract include(room: RoomListEntry): boolean abstract include(room: RoomListEntry): boolean
clearUnreads() {
this.counts.emit(emptyUnreadCounts)
}
applyUnreads(newCounts?: SpaceUnreadCounts | null, oldCounts?: SpaceUnreadCounts | null) { applyUnreads(newCounts?: SpaceUnreadCounts | null, oldCounts?: SpaceUnreadCounts | null) {
const mergedCounts: SpaceUnreadCounts = { const mergedCounts: SpaceUnreadCounts = {
unread_messages: this.counts.current.unread_messages unread_messages: this.counts.current.unread_messages