From 86df926a15da7c5447788b00a34995e0512bd286 Mon Sep 17 00:00:00 2001 From: raven Date: Tue, 17 Feb 2026 15:21:17 -0600 Subject: direct message list --- client/channel_list.go | 46 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) (limited to 'client/channel_list.go') diff --git a/client/channel_list.go b/client/channel_list.go index b8bf962..2c7c51c 100644 --- a/client/channel_list.go +++ b/client/channel_list.go @@ -91,27 +91,17 @@ func (cl *channelList) remove(location channelLocation) { } func (cl *channelList) traverse(direction int) int { - if len(*cl) == 0 { - return 0 - } - - var i int - for i = 0; i < len(*cl); i++ { + next := 0 + for i := 0; i < len(*cl); i++ { if (*cl)[i].location == globalApp.currentWindow { + next = i + direction break } } - if i == len(*cl) { - i = 0 - } else { - i += direction - i %= len(*cl) - if i < 0 { - i = len(*cl) + i - } + if next >= 0 && next < len(*cl) { + globalApp.goTo((*cl)[next].location) } - globalApp.goTo((*cl)[i].location) - return i + return next } func (cl *channelList) add(name string, location channelLocation) { @@ -120,7 +110,8 @@ func (cl *channelList) add(name string, location channelLocation) { *cl = append([]channelListEntry {entry}, *cl...) } -func (cl *channelList) show(scroll *tui.ScrollState) { +func (cl *channelList) show( + scroll *tui.ScrollState, menu func(channelLocation)) { mouse := tui.Push("channel list", tui.Box { Width: 12, Height: tui.Fill, Overflow: true, Scroll: scroll, }) @@ -158,26 +149,7 @@ func (cl *channelList) show(scroll *tui.ScrollState) { } } } - - switch { - case tui.MenuOption("list"): - w := globalApp.windowCache.Open(entry.location) - switch w.(type) { - case *channelWindow: - w.(*channelWindow).userList(func(msg userListMsg) { - globalApp.cmdWindow.Buffer().Add(msg) - }) - } - case tui.MenuOption("leave"): - w := globalApp.windowCache.Open(entry.location) - switch w.(type) { - case *channelWindow: - defer w.(*channelWindow).leaveChannel() - } - if entry.location == globalApp.currentWindow { - globalApp.goTo(cmdWindowLocation {}) - } - } + menu(entry.location) ch := globalApp.cache.Get(entry.location.id) if ch != nil { -- cgit v1.2.3