summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorcitrons <citrons@mondecitronne.com>2025-06-01 19:19:04 -0500
committercitrons <citrons@mondecitronne.com>2025-06-01 19:19:04 -0500
commita69d4d6bd2e9c91a8c9925610b46922d58eda493 (patch)
tree5908fe8ab6d1116522771d60d5bb6e513817690a /client
parent335f57fbc8403b32b5e3d8ea1cb1b713cdacb5fc (diff)
rename channel
Diffstat (limited to 'client')
-rw-r--r--client/channel_window.go14
-rw-r--r--client/command.go9
-rw-r--r--client/help.go1
3 files changed, 24 insertions, 0 deletions
diff --git a/client/channel_window.go b/client/channel_window.go
index b4c9b9f..f9ed5a8 100644
--- a/client/channel_window.go
+++ b/client/channel_window.go
@@ -112,6 +112,20 @@ func (cw *channelWindow) leaveChannel() {
globalApp.windowCache.Evict(cw.location)
}
+func (cw *channelWindow) renameChannel(newName string) {
+ ch := proto.Object {
+ "channel", cw.location.id, map[string]string {"": newName},
+ }
+ globalApp.sendUpdate(ch, func(response proto.Command) {
+ if response.Kind == "fail" {
+ if len(response.Args) > 0 {
+ f := proto.Fail(response.Args[0])
+ globalApp.cmdWindow.err(f.Error())
+ }
+ }
+ })
+}
+
func (cw *channelWindow) loadMoreHistory() {
if cw.loadingHistory || cw.endOfHistory {
return
diff --git a/client/command.go b/client/command.go
index 101a5aa..3dc3d26 100644
--- a/client/command.go
+++ b/client/command.go
@@ -79,6 +79,15 @@ func (a *application) doCommand(command string, args []string, text string) {
win.(*channelWindow).leaveChannel()
}
a.currentWindow = cmdWindowLocation {}
+ case "rename":
+ if !argN(1) {
+ break
+ }
+ win := a.windowCache.Get(a.currentWindow)
+ switch win.(type) {
+ case *channelWindow:
+ win.(*channelWindow).renameChannel(args[0])
+ }
case "list":
if !argN(0) {
break
diff --git a/client/help.go b/client/help.go
index a6f1797..9465f20 100644
--- a/client/help.go
+++ b/client/help.go
@@ -16,6 +16,7 @@ var helpTexts = []helpText {
helpText {"join", "<name>", "join the channel with this name"},
helpText {"list", "", "list users in the currently shown channel"},
helpText {"leave", "", "leave the currently shown channel"},
+ helpText {"rename", "<name>", "rename the currently shown channel"},
helpText {"create", "<name>", "create a channel with this name"},
helpText {"quit", "", "exit the application"},
}