diff options
author | Tulir Asokan <tulir@maunium.net> | 2019-04-05 23:44:17 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2019-04-05 23:44:17 +0300 |
commit | 7ad2103f8f2c9b7e3d12554634a68db973a05b36 (patch) | |
tree | e08c3eb377411bf6954ef24ff9205202f07e7296 /matrix/rooms | |
parent | 535fbbb4f7703845bb25484f6eb67b1389f2dd61 (diff) |
Move history storage to matrix package. Fixes #90
Diffstat (limited to 'matrix/rooms')
-rw-r--r-- | matrix/rooms/room.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/matrix/rooms/room.go b/matrix/rooms/room.go index 16d4a9e..47f5602 100644 --- a/matrix/rooms/room.go +++ b/matrix/rooms/room.go @@ -57,6 +57,7 @@ type UnreadMessage struct { Highlight bool } + // Room represents a single Matrix room. type Room struct { *mautrix.Room @@ -74,6 +75,7 @@ type Room struct { UnreadMessages []UnreadMessage unreadCountCache *int highlightCache *bool + lastMarkedRead string // Whether or not this room is marked as a direct chat. IsDirect bool @@ -142,7 +144,11 @@ func (room *Room) Save(path string) error { } // MarkRead clears the new message statuses on this room. -func (room *Room) MarkRead(eventID string) { +func (room *Room) MarkRead(eventID string) bool { + if room.lastMarkedRead == eventID { + return false + } + room.lastMarkedRead = eventID readToIndex := -1 for index, unreadMessage := range room.UnreadMessages { if unreadMessage.EventID == eventID { @@ -154,6 +160,7 @@ func (room *Room) MarkRead(eventID string) { room.highlightCache = nil room.unreadCountCache = nil } + return true } func (room *Room) UnreadCount() int { |