summaryrefslogtreecommitdiff
path: root/client/application.go
diff options
context:
space:
mode:
Diffstat (limited to 'client/application.go')
-rw-r--r--client/application.go16
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 ""