diff options
author | delthas <delthas@dille.cc> | 2022-08-10 13:06:54 +0200 |
---|---|---|
committer | delthas <delthas@dille.cc> | 2022-08-10 13:06:54 +0200 |
commit | 0ba374bf2b7be92317777216f2dfcd607d4f9e8f (patch) | |
tree | f5644e7d276eeda8029bd68584d4a63d384eb638 /ui | |
parent | Document selecting with shift (diff) |
Add support for soju.im/bouncer-networks-notify
This enables dynamic discovery of new and deleted networks.
Fixes: https://todo.sr.ht/~taiite/senpai/71
Diffstat (limited to 'ui')
-rw-r--r-- | ui/buffers.go | 14 | ||||
-rw-r--r-- | ui/ui.go | 5 |
2 files changed, 19 insertions, 0 deletions
diff --git a/ui/buffers.go b/ui/buffers.go index 915a1c8..b13465f 100644 --- a/ui/buffers.go +++ b/ui/buffers.go @@ -342,6 +342,20 @@ func (bs *BufferList) Remove(netID, title string) bool { return true } +func (bs *BufferList) RemoveNetwork(netID string) { + for idx := 0; idx < len(bs.list); idx++ { + b := &bs.list[idx] + if b.netID != netID { + continue + } + bs.list = append(bs.list[:idx], bs.list[idx+1:]...) + if len(bs.list) <= bs.current { + bs.current-- + } + idx-- + } +} + func (bs *BufferList) mergeLine(former *Line, addition Line) (keepLine bool) { bs.doMergeLine(former, addition) if former.Body.string == "" { @@ -260,6 +260,11 @@ func (ui *UI) RemoveBuffer(netID, title string) { ui.memberOffset = 0 } +func (ui *UI) RemoveNetworkBuffers(netID string) { + ui.bs.RemoveNetwork(netID) + ui.memberOffset = 0 +} + func (ui *UI) AddLine(netID, buffer string, notify NotifyType, line Line) { ui.bs.AddLine(netID, buffer, notify, line) } |