diff options
| author | citrons <citrons@mondecitronne.com> | 2025-06-04 12:12:13 -0500 |
|---|---|---|
| committer | citrons <citrons@mondecitronne.com> | 2025-06-07 16:02:18 -0500 |
| commit | b0fd9a1c7848343ef378b772eb76a0e99747260c (patch) | |
| tree | 05093ccc0bda8ba4f1286b738ab67a6b1bccfd61 /client/application.go | |
| parent | 035344054768562bee7db12e02e3bec1c8409210 (diff) | |
channel list
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": |
