summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2022-08-10 13:06:54 +0200
committerdelthas <delthas@dille.cc>2022-08-10 13:06:54 +0200
commit0ba374bf2b7be92317777216f2dfcd607d4f9e8f (patch)
treef5644e7d276eeda8029bd68584d4a63d384eb638 /ui
parentDocument 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.go14
-rw-r--r--ui/ui.go5
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 == "" {
diff --git a/ui/ui.go b/ui/ui.go
index 4866969..0a380a7 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -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)
}