From 855e61c53c8a401c6f0be84a63808cb94cb19903 Mon Sep 17 00:00:00 2001 From: citrons Date: Sat, 7 Jun 2025 14:57:04 -0500 Subject: channel list scrolling --- client/application.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'client/application.go') 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 "" -- cgit v1.2.3