summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/channel_list.go19
-rw-r--r--client/command.go18
2 files changed, 30 insertions, 7 deletions
diff --git a/client/channel_list.go b/client/channel_list.go
index 25d093f..bc89dba 100644
--- a/client/channel_list.go
+++ b/client/channel_list.go
@@ -2,6 +2,7 @@ package main
import (
"citrons.xyz/talk/proto"
+ "citrons.xyz/talk/proto/validate"
"citrons.xyz/talk/tui"
"sort"
)
@@ -38,6 +39,24 @@ func (cl *channelList) setChannels(cs []proto.Object) {
sort.Sort(cl)
}
+func (cl *channelList) contains(location channelLocation) bool {
+ for i := 0; i < len(*cl); i++ {
+ if (*cl)[i].location == location {
+ return true
+ }
+ }
+ return false
+}
+
+func (cl *channelList) findName(name string) channelLocation {
+ for i := 0; i < len(*cl); i++ {
+ if validate.Fold((*cl)[i].name) == validate.Fold(name) {
+ return (*cl)[i].location
+ }
+ }
+ return channelLocation {}
+}
+
func (cl *channelList) remove(location channelLocation) {
for i := len(*cl) - 1; i >= 0; i-- {
if (*cl)[i].location != location {
diff --git a/client/command.go b/client/command.go
index cb6ad10..59b3a8a 100644
--- a/client/command.go
+++ b/client/command.go
@@ -105,6 +105,11 @@ func (a *application) doCommand(command string, args []string, text string) {
a.setNick(text)
return
case "join":
+ cl := a.channelList.findName(text)
+ if cl.id != "" {
+ a.goTo(cl)
+ break
+ }
if a.authenticated {
a.join(text)
}
@@ -121,13 +126,12 @@ func (a *application) doCommand(command string, args []string, text string) {
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})
- }
- })
+ cl := a.channelList.findName(text)
+ if cl.id == "" {
+ a.cmdWindow.err("you are not in that channel")
+ } else {
+ leave(cl)
+ }
}
return
case "rename":