diff options
| author | raven <citrons@mondecitronne.com> | 2026-02-17 15:21:17 -0600 |
|---|---|---|
| committer | raven <citrons@mondecitronne.com> | 2026-02-17 15:22:10 -0600 |
| commit | 86df926a15da7c5447788b00a34995e0512bd286 (patch) | |
| tree | 13249c0cc6c323ad91ebfc32bffec65a915da23c /client/channel_list.go | |
| parent | 61ba037f8a70d6a842853b9f0f0b782873e0a763 (diff) | |
direct message list
Diffstat (limited to 'client/channel_list.go')
| -rw-r--r-- | client/channel_list.go | 46 |
1 files changed, 9 insertions, 37 deletions
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 { |
