commit 0e73077
Hubert Hirtz
·
2021-11-07 12:36:47 +0000 UTC
parent 9a595ff
Don't merge message bounds from multiple networks Otherwise it breaks infinite scrolling.
1 files changed,
+14,
-9
M
app.go
M
app.go
+14,
-9
1@@ -72,6 +72,11 @@ type event struct {
2 content interface{}
3 }
4
5+type boundKey struct {
6+ netID string
7+ target string
8+}
9+
10 type App struct {
11 win *ui.UI
12 sessions map[string]*irc.Session
13@@ -83,7 +88,7 @@ type App struct {
14
15 lastQuery string
16 lastQueryNet string
17- messageBounds map[string]bound
18+ messageBounds map[boundKey]bound
19 lastNetID string
20 lastBuffer string
21 }
22@@ -93,7 +98,7 @@ func NewApp(cfg Config) (app *App, err error) {
23 sessions: map[string]*irc.Session{},
24 events: make(chan event, eventChanSize),
25 cfg: cfg,
26- messageBounds: map[string]bound{},
27+ messageBounds: map[boundKey]bound{},
28 }
29
30 if cfg.Highlights != nil {
31@@ -522,7 +527,7 @@ func (app *App) requestHistory() {
32 }
33 if app.win.IsAtTop() && buffer != "" {
34 t := time.Now()
35- if bound, ok := app.messageBounds[buffer]; ok {
36+ if bound, ok := app.messageBounds[boundKey{netID, buffer}]; ok {
37 t = bound.first
38 }
39 s.NewHistoryRequest(buffer).
40@@ -622,7 +627,7 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
41 }
42 case irc.SelfJoinEvent:
43 i, added := app.win.AddBuffer(netID, "", ev.Channel)
44- bounds, ok := app.messageBounds[ev.Channel]
45+ bounds, ok := app.messageBounds[boundKey{netID, ev.Channel}]
46 if added || !ok {
47 s.NewHistoryRequest(ev.Channel).
48 WithLimit(200).
49@@ -661,7 +666,7 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
50 })
51 case irc.SelfPartEvent:
52 app.win.RemoveBuffer(ev.Channel)
53- delete(app.messageBounds, ev.Channel)
54+ delete(app.messageBounds, boundKey{netID, ev.Channel})
55 case irc.UserPartEvent:
56 var body ui.StyledStringBuilder
57 body.Grow(len(ev.User) + 1)
58@@ -743,13 +748,13 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
59 app.lastQuery = msg.Prefix.Name
60 app.lastQueryNet = netID
61 }
62- bounds := app.messageBounds[ev.Target]
63+ bounds := app.messageBounds[boundKey{netID, ev.Target}]
64 bounds.Update(&line)
65- app.messageBounds[ev.Target] = bounds
66+ app.messageBounds[boundKey{netID, ev.Target}] = bounds
67 case irc.HistoryEvent:
68 var linesBefore []ui.Line
69 var linesAfter []ui.Line
70- bounds, hasBounds := app.messageBounds[ev.Target]
71+ bounds, hasBounds := app.messageBounds[boundKey{netID, ev.Target}]
72 for _, m := range ev.Messages {
73 switch ev := m.(type) {
74 case irc.MessageEvent:
75@@ -776,7 +781,7 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
76 bounds.Update(&linesAfter[len(linesAfter)-1])
77 }
78 if !bounds.IsZero() {
79- app.messageBounds[ev.Target] = bounds
80+ app.messageBounds[boundKey{netID, ev.Target}] = bounds
81 }
82 case irc.BouncerNetworkEvent:
83 _, added := app.win.AddBuffer(ev.ID, ev.Name, "")