commit 24a84fa

Hubert Hirtz  ·  2021-11-29 08:32:51 +0000 UTC
parent 0681de6
Fetch history for queries
2 files changed,  +7, -2
M app.go
M app.go
+6, -2
 1@@ -721,7 +721,11 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
 2 	case irc.MessageEvent:
 3 		buffer, line, notification := app.formatMessage(s, ev)
 4 		if buffer != "" && !s.IsChannel(buffer) {
 5-			app.win.AddBuffer(netID, "", buffer)
 6+			if _, added := app.win.AddBuffer(netID, "", buffer); added {
 7+				s.NewHistoryRequest(buffer).
 8+					WithLimit(200).
 9+					Before(msg.TimeOrNow())
10+			}
11 		}
12 		app.win.AddLine(netID, buffer, notification, line)
13 		if notification == ui.NotifyHighlight {
14@@ -733,7 +737,7 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
15 		}
16 		bounds := app.messageBounds[boundKey{netID, ev.Target}]
17 		bounds.Update(&line)
18-		app.messageBounds[boundKey{netID, ev.Target}] = bounds
19+		app.messageBounds[boundKey{netID, buffer}] = bounds
20 	case irc.HistoryTargetsEvent:
21 		for target, last := range ev.Targets {
22 			if s.IsChannel(target) {
+1, -0
1@@ -426,6 +426,7 @@ func commandDoQuery(app *App, args []string) (err error) {
2 		return fmt.Errorf("cannot query a channel, use JOIN instead")
3 	}
4 	i, _ := app.win.AddBuffer(netID, "", target)
5+	s.NewHistoryRequest(target).WithLimit(200).Before(time.Now())
6 	app.win.JumpBufferIndex(i)
7 	return nil
8 }