diff options
Diffstat (limited to 'client/application.go')
| -rw-r--r-- | client/application.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/client/application.go b/client/application.go index 35f38c8..2d16591 100644 --- a/client/application.go +++ b/client/application.go @@ -18,6 +18,7 @@ type application struct { windowCache window.WindowCache currentWindow window.Location windowHist []window.Location + channelList channelList cmdWindow cmdWindow prompts []window.Prompt } @@ -121,6 +122,7 @@ func (a *application) auth(name string, authCallback func(success bool)) { a.authenticated = true a.uid = me.Id a.cache.Watch(a.uid) + a.onAuth() if authCallback != nil { authCallback(true) } @@ -138,6 +140,14 @@ func (a *application) auth(name string, authCallback func(success bool)) { }), callback) } +func (a *application) onAuth() { + a.Request(proto.NewCmd("channels", ""), func(response proto.Command) { + if response.Kind == "channels" { + a.channelList.setChannels(response.Args) + } + }) +} + func (a *application) sendUpdate(o proto.Object, cb func(proto.Command)) { a.Request(proto.NewCmd("update", o.Id, o), cb) } @@ -170,6 +180,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}) case "fail": if len(response.Args) > 0 { @@ -188,6 +199,7 @@ func (a *application) createChannel(name string) { 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}) } case "fail": |
