summaryrefslogtreecommitdiff
path: root/app.go
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2021-10-30 16:09:44 +0200
committerHubert Hirtz <hubert@hirtz.pm>2021-10-31 09:02:40 +0100
commit2dd34ad757ddd55ee467f885f13e2f55af0f0950 (patch)
tree68afdf4c87d405e6faf2fcf2be8fb0443a8d615d /app.go
parentMake vertical channel list scrollable (diff)
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.
Diffstat (limited to 'app.go')
-rw-r--r--app.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/app.go b/app.go
index bb552e8..a6f91d3 100644
--- a/app.go
+++ b/app.go
@@ -62,6 +62,11 @@ func (b *bound) Update(line *ui.Line) {
}
}
+// IsZero reports whether the bound is empty.
+func (b *bound) IsZero() bool {
+ return b.first.IsZero()
+}
+
type event struct {
src string // "*" if UI, netID otherwise
content interface{}
@@ -775,7 +780,9 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
bounds.Update(&linesAfter[0])
bounds.Update(&linesAfter[len(linesAfter)-1])
}
- app.messageBounds[ev.Target] = bounds
+ if !bounds.IsZero() {
+ app.messageBounds[ev.Target] = bounds
+ }
case irc.BouncerNetworkEvent:
_, added := app.win.AddBuffer(ev.ID, ev.Name, "")
if added {