diff options
| author | citrons <citrons@mondecitronne.com> | 2025-06-07 14:57:04 -0500 |
|---|---|---|
| committer | citrons <citrons@mondecitronne.com> | 2025-06-07 16:02:18 -0500 |
| commit | 855e61c53c8a401c6f0be84a63808cb94cb19903 (patch) | |
| tree | 5f03c5357cf6aa75db05376cf6a42cc67d1e33c8 /client/application.go | |
| parent | 553ebc26cda61b567418205f7ee60be122b3c84f (diff) | |
channel list scrolling
Diffstat (limited to 'client/application.go')
| -rw-r--r-- | client/application.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/client/application.go b/client/application.go index b1fbf5b..f77e0e1 100644 --- a/client/application.go +++ b/client/application.go @@ -4,6 +4,7 @@ import ( "citrons.xyz/talk/client/client" "citrons.xyz/talk/client/object" "citrons.xyz/talk/client/window" + "citrons.xyz/talk/tui" "citrons.xyz/talk/proto" ) @@ -19,6 +20,7 @@ type application struct { currentWindow window.Location windowHist []window.Location channelList channelList + channelScroll tui.ScrollState redraw bool cmdWindow cmdWindow prompts []window.Prompt @@ -209,9 +211,7 @@ func (a *application) join(channelName string) { a.Request(proto.NewCmd("join", ch.Id), func(response proto.Command) { switch response.Kind { case "ok": - a.channelList.add(channelName, channelLocation {id: ch.Id}) - a.goTo(channelLocation {id: ch.Id}) - + a.newChannel(*ch) w := a.windowCache.Get(channelLocation {id: ch.Id}) switch w.(type) { case *channelWindow: @@ -233,9 +233,7 @@ func (a *application) createChannel(name string) { switch response.Kind { case "create": if len(response.Args) > 0 { - ch := response.Args[0] - a.channelList.add(ch.Fields[""], channelLocation {id: ch.Id}) - a.goTo(channelLocation {id: ch.Id}) + a.newChannel(response.Args[0]) } case "fail": if len(response.Args) > 0 { @@ -246,6 +244,12 @@ func (a *application) createChannel(name string) { }) } +func (a *application) newChannel(ch proto.Object) { + a.channelList.add(ch.Fields[""], channelLocation {id: ch.Id}) + a.channelScroll.Set(0) + a.goTo(channelLocation {id: ch.Id}) +} + func (a *application) getNick() string { if !a.authenticated { return "" |
