summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraven <citrons@mondecitronne.com>2025-10-22 16:29:13 -0500
committerraven <citrons@mondecitronne.com>2026-02-09 13:14:00 -0600
commitac4034387f75b18b95f77842e54c212b17a4c6c5 (patch)
tree2be76a2da6efbd970515b8acb1083666842c05fa
parentff0f6ba724748dbe340187fdd831a4d4f7f0ae5e (diff)
support /leave with argument
-rw-r--r--client/application.go1
-rw-r--r--client/command.go25
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)