From b0fd9a1c7848343ef378b772eb76a0e99747260c Mon Sep 17 00:00:00 2001 From: citrons Date: Wed, 4 Jun 2025 12:12:13 -0500 Subject: channel list --- client/application.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'client/application.go') 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": -- cgit v1.2.3