Show notifications and highlights in room list. Fixes #8

This commit is contained in:
Tulir Asokan
2018-03-26 17:22:47 +03:00
parent 6095638fbb
commit b31d968814
7 changed files with 110 additions and 42 deletions

View File

@ -32,6 +32,16 @@ type Room struct {
PrevBatch string
// The MXID of the user whose session this room was created for.
SessionUserID string
// The number of unread messages that were notified about.
UnreadMessages int
// Whether or not any of the unread messages were highlights.
Highlighted bool
// Whether or not the room contains any new messages.
// This can be true even when UnreadMessages is zero if there's
// a notificationless message like bot notices.
HasNewMessages bool
// MXID -> Member cache calculated from membership events.
memberCache map[string]*Member
// The first non-SessionUserID member in the room. Calculated at
@ -65,6 +75,13 @@ func (room *Room) UnlockHistory() {
}
}
// MarkRead clears the new message statuses on this room.
func (room *Room) MarkRead() {
room.UnreadMessages = 0
room.Highlighted = false
room.HasNewMessages = false
}
// UpdateState updates the room's current state with the given Event. This will clobber events based
// on the type/state_key combination.
func (room *Room) UpdateState(event *gomatrix.Event) {