commit f1ca0dc

Hugo Osvaldo Barrera  ·  2023-07-02 22:55:16 +0000 UTC
parent 32bf7bf
Highlight channels with unread messages at startup

When processing history messages, if any of them are newer than the
channel's "last seen" timestamp, properly highlight the corresponding
channel.

Fixes: https://todo.sr.ht/~taiite/senpai/112
1 files changed,  +10, -0
+10, -0
 1@@ -428,6 +428,7 @@ func (bs *BufferList) AddLines(netID, title string, before, after []Line) {
 2 	if b == nil {
 3 		return
 4 	}
 5+	updateRead := b != bs.cur() && !b.read.IsZero()
 6 
 7 	lines := make([]Line, 0, len(before)+len(b.lines)+len(after))
 8 	for _, buf := range []*[]Line{&before, &b.lines, &after} {
 9@@ -446,6 +447,15 @@ func (bs *BufferList) AddLines(netID, title string, before, after []Line) {
10 				}
11 				lines = append(lines, line)
12 			}
13+
14+			if updateRead && line.At.After(b.read) {
15+				if line.Notify != NotifyNone {
16+					b.unread = true
17+				}
18+				if line.Notify == NotifyHighlight {
19+					b.highlights++
20+				}
21+			}
22 		}
23 	}
24 	b.lines = lines