commit 56fce9e
delthas
·
2021-11-15 16:01:12 +0000 UTC
parent 1859f66
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.
3 files changed,
+13,
-15
M
app.go
+1,
-1
1@@ -673,7 +673,7 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
2 Mergeable: true,
3 })
4 case irc.SelfPartEvent:
5- app.win.RemoveBuffer(ev.Channel)
6+ app.win.RemoveBuffer(netID, ev.Channel)
7 delete(app.messageBounds, boundKey{netID, ev.Channel})
8 case irc.UserPartEvent:
9 var body ui.StyledStringBuilder
+10,
-12
1@@ -277,19 +277,17 @@ func (bs *BufferList) Add(netID, netName, title string) (i int, added bool) {
2 return len(bs.list) - 1, true
3 }
4
5-func (bs *BufferList) Remove(title string) (ok bool) {
6- lTitle := strings.ToLower(title)
7- for i, b := range bs.list {
8- if strings.ToLower(b.title) == lTitle {
9- ok = true
10- bs.list = append(bs.list[:i], bs.list[i+1:]...)
11- if len(bs.list) <= bs.current {
12- bs.current--
13- }
14- return
15- }
16+func (bs *BufferList) Remove(netID, title string) bool {
17+ idx := bs.idx(netID, title)
18+ if idx < 0 {
19+ return false
20+ }
21+
22+ bs.list = append(bs.list[:idx], bs.list[idx+1:]...)
23+ if len(bs.list) <= bs.current {
24+ bs.current--
25 }
26- return
27+ return true
28 }
29
30 func (bs *BufferList) AddLine(netID, title string, notify NotifyType, line Line) {
M
ui/ui.go
+2,
-2
1@@ -181,8 +181,8 @@ func (ui *UI) AddBuffer(netID, netName, title string) (i int, added bool) {
2 return ui.bs.Add(netID, netName, title)
3 }
4
5-func (ui *UI) RemoveBuffer(title string) {
6- _ = ui.bs.Remove(title)
7+func (ui *UI) RemoveBuffer(netID, title string) {
8+ _ = ui.bs.Remove(netID, title)
9 ui.memberOffset = 0
10 }
11