From a69d4d6bd2e9c91a8c9925610b46922d58eda493 Mon Sep 17 00:00:00 2001 From: citrons Date: Sun, 1 Jun 2025 19:19:04 -0500 Subject: rename channel --- client/channel_window.go | 14 ++++++++++++++ client/command.go | 9 +++++++++ client/help.go | 1 + 3 files changed, 24 insertions(+) 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", "", "join the channel with this name"}, helpText {"list", "", "list users in the currently shown channel"}, helpText {"leave", "", "leave the currently shown channel"}, + helpText {"rename", "", "rename the currently shown channel"}, helpText {"create", "", "create a channel with this name"}, helpText {"quit", "", "exit the application"}, } -- cgit v1.2.3