diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/application.go | 1 | ||||
| -rw-r--r-- | client/command.go | 25 |
2 files changed, 18 insertions, 8 deletions
diff --git a/client/application.go b/client/application.go index 640abd6..ad5f2c6 100644 --- a/client/application.go +++ b/client/application.go @@ -376,7 +376,6 @@ 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 { diff --git a/client/command.go b/client/command.go index 64f8cd8..bb7a491 100644 --- a/client/command.go +++ b/client/command.go @@ -2,6 +2,7 @@ package main import ( "citrons.xyz/talk/proto" + "citrons.xyz/talk/client/window" ) func isCommand(text string) (bool, string) { @@ -109,15 +110,25 @@ func (a *application) doCommand(command string, args []string, text string) { } return case "leave": - if !argN(0) { - break + leave := func(w window.Location) { + win := a.windowCache.Open(w) + switch win.(type) { + case *channelWindow: + win.(*channelWindow).leaveChannel() + } } - win := a.windowCache.Get(a.currentWindow) - switch win.(type) { - case *channelWindow: - win.(*channelWindow).leaveChannel() + if text == "" { + leave(a.currentWindow) + a.currentWindow = cmdWindowLocation {} + } else { + a.lookup(text, "channel", func(ch *proto.Object, err *proto.Fail) { + if err != nil { + a.cmdWindow.fail(proto.Object(*err)) + } else if ch.Id != "" { + leave(channelLocation {id: ch.Id}) + } + }) } - a.currentWindow = cmdWindowLocation {} return case "rename": win := a.windowCache.Get(a.currentWindow) |
