diff options
author | delthas <delthas@dille.cc> | 2021-11-15 17:01:12 +0100 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtz.pm> | 2021-11-16 22:28:37 +0100 |
commit | 56fce9e433a78547e2d92ebef92cab62eaa1c1a7 (patch) | |
tree | 783f4f5a3ec0faaa3bebf28e6632fc056a80816b | |
parent | Authenticate on CAP NEW sasl (diff) |
Fix part-ing a channel with duplicate name in other networks
If there are multiple channels with the same name in several networks,
we should part from the one from the correct network.
-rw-r--r-- | app.go | 2 | ||||
-rw-r--r-- | ui/buffers.go | 22 | ||||
-rw-r--r-- | ui/ui.go | 4 |
3 files changed, 13 insertions, 15 deletions
@@ -673,7 +673,7 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) { Mergeable: true, }) case irc.SelfPartEvent: - app.win.RemoveBuffer(ev.Channel) + app.win.RemoveBuffer(netID, ev.Channel) delete(app.messageBounds, boundKey{netID, ev.Channel}) case irc.UserPartEvent: var body ui.StyledStringBuilder diff --git a/ui/buffers.go b/ui/buffers.go index 3e13302..9dc26c2 100644 --- a/ui/buffers.go +++ b/ui/buffers.go @@ -277,19 +277,17 @@ func (bs *BufferList) Add(netID, netName, title string) (i int, added bool) { return len(bs.list) - 1, true } -func (bs *BufferList) Remove(title string) (ok bool) { - lTitle := strings.ToLower(title) - for i, b := range bs.list { - if strings.ToLower(b.title) == lTitle { - ok = true - bs.list = append(bs.list[:i], bs.list[i+1:]...) - if len(bs.list) <= bs.current { - bs.current-- - } - return - } +func (bs *BufferList) Remove(netID, title string) bool { + idx := bs.idx(netID, title) + if idx < 0 { + return false + } + + bs.list = append(bs.list[:idx], bs.list[idx+1:]...) + if len(bs.list) <= bs.current { + bs.current-- } - return + return true } func (bs *BufferList) AddLine(netID, title string, notify NotifyType, line Line) { @@ -181,8 +181,8 @@ func (ui *UI) AddBuffer(netID, netName, title string) (i int, added bool) { return ui.bs.Add(netID, netName, title) } -func (ui *UI) RemoveBuffer(title string) { - _ = ui.bs.Remove(title) +func (ui *UI) RemoveBuffer(netID, title string) { + _ = ui.bs.Remove(netID, title) ui.memberOffset = 0 } |