summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/application.go28
1 files changed, 27 insertions, 1 deletions
diff --git a/client/application.go b/client/application.go
index 388272f..338faeb 100644
--- a/client/application.go
+++ b/client/application.go
@@ -47,7 +47,6 @@ func (a *application) OnConnect() {
a.connected = true
a.reconnecting = false
a.cache = object.NewCache(a)
- a.windowCache = window.NewCache()
a.cmdWindow.info("connected to %s", a.Client.Address)
}
@@ -56,6 +55,7 @@ func (a *application) OnDisconnect(err error) {
a.authenticated = false
a.uid = ""
a.prompts = nil
+ a.windowCache = window.NewCache()
if !a.reconnecting {
a.cmdWindow.err(
"disconnected from %s: %s\nreconnecting...", a.Client.Address, err,
@@ -150,7 +150,27 @@ func (a *application) auth(name string, authCallback func(success bool)) {
func (a *application) onAuth() {
a.Request(proto.NewCmd("channels", ""), func(response proto.Command) {
if response.Kind == "channels" {
+ previousChannels := make(channelList, len(a.channelList))
+ copy(previousChannels, a.channelList)
+
a.channelList.setChannels(response.Args)
+
+ u := a.cache.Get(a.uid)
+ if u.Fields["anonymous"] == "yes" {
+ for _, c := range previousChannels {
+ cb := func(response proto.Command) {
+ if response.Kind == "ok" {
+ a.channelList = append(a.channelList, c)
+ }
+ w := a.windowCache.Get(c.location)
+ switch w.(type) {
+ case *channelWindow:
+ w.(*channelWindow).endOfHistory = false
+ }
+ }
+ a.Request(proto.NewCmd("join", c.location.id), cb)
+ }
+ }
}
})
}
@@ -189,6 +209,12 @@ func (a *application) join(channelName string) {
case "ok":
a.channelList.add(channelName, channelLocation {id: ch.Id})
a.goTo(channelLocation {id: ch.Id})
+
+ w := a.windowCache.Get(channelLocation {id: ch.Id})
+ switch w.(type) {
+ case *channelWindow:
+ w.(*channelWindow).endOfHistory = false
+ }
case "fail":
if len(response.Args) > 0 {
f := proto.Fail(response.Args[0])