commit 2dd34ad
delthas
·
2021-10-30 14:09:44 +0000 UTC
parent 5c2fb81
Fix requesting CHATHISTORY of empty channels
Channels which have never received any message return no messages on the
initial chathistory, thus returning an empty bound with first == last ==
time.Time{}.
However this empty bound was stored in the channel bounds, and was used
as starting point for fetching history if Page Up was pressed. This in
turn caused senpai to send a CHATHISTORY BEFORE 01-01-0001 message,
which is invalid.
This fixes the issue by not storing an empty bound if the CHATHISTORY
request does not return any message.
1 files changed,
+8,
-1
M
app.go
M
app.go
+8,
-1
1@@ -62,6 +62,11 @@ func (b *bound) Update(line *ui.Line) {
2 }
3 }
4
5+// IsZero reports whether the bound is empty.
6+func (b *bound) IsZero() bool {
7+ return b.first.IsZero()
8+}
9+
10 type event struct {
11 src string // "*" if UI, netID otherwise
12 content interface{}
13@@ -775,7 +780,9 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
14 bounds.Update(&linesAfter[0])
15 bounds.Update(&linesAfter[len(linesAfter)-1])
16 }
17- app.messageBounds[ev.Target] = bounds
18+ if !bounds.IsZero() {
19+ app.messageBounds[ev.Target] = bounds
20+ }
21 case irc.BouncerNetworkEvent:
22 _, added := app.win.AddBuffer(ev.ID, ev.Name, "")
23 if added {