summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2022-04-15 14:55:18 +0200
committerdelthas <delthas@dille.cc>2022-04-15 14:55:18 +0200
commitc86a2fae090aeb59620efb7996c4c6739601d63f (patch)
treea4ab3687a749ea6a077702d337b7b7601275da4f /ui
parentImplement SEARCH (diff)
Only send READ for messages received from a channel
i.e. don't enter an infinite loop when printing disconnection errors :-)
Diffstat (limited to 'ui')
-rw-r--r--ui/buffers.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/ui/buffers.go b/ui/buffers.go
index 5ed3414..69d1aa0 100644
--- a/ui/buffers.go
+++ b/ui/buffers.go
@@ -34,6 +34,7 @@ type Line struct {
Body StyledString
HeadColor tcell.Color
Highlight bool
+ Readable bool
Mergeable bool
Data interface{}
@@ -420,9 +421,15 @@ func (bs *BufferList) SetRead(netID, title string, timestamp time.Time) {
if b == nil {
return
}
- if len(b.lines) > 0 && !b.lines[len(b.lines)-1].At.After(timestamp) {
- b.highlights = 0
- b.unread = false
+ for i := len(b.lines) - 1; i >= 0; i-- {
+ line := &b.lines[i]
+ if line.Readable {
+ if line.At.After(timestamp) {
+ b.highlights = 0
+ b.unread = false
+ }
+ break
+ }
}
if b.read.Before(timestamp) {
b.read = timestamp
@@ -435,7 +442,7 @@ func (bs *BufferList) UpdateRead() (netID, title string, timestamp time.Time) {
y := 0
for i := len(b.lines) - 1; 0 <= i; i-- {
line = &b.lines[i]
- if y >= b.scrollAmt {
+ if y >= b.scrollAmt && line.Readable {
break
}
y += len(line.NewLines(bs.tlInnerWidth)) + 1