diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-07-09 16:43:41 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-07-09 16:43:41 +0300 |
| commit | 1490ddda1d20ef23a4e5ec908405869073abbf8d (patch) | |
| tree | e22d0cf2dc6d4f882f6d999b87f250b1b5770482 /go-src/windows.go | |
| parent | 4575fc829356ba4cd538094b987d69b0233648f7 (diff) | |
| download | ctfc-1490ddda1d20ef23a4e5ec908405869073abbf8d.tar ctfc-1490ddda1d20ef23a4e5ec908405869073abbf8d.tar.gz ctfc-1490ddda1d20ef23a4e5ec908405869073abbf8d.zip | |
Implemented number handling in chats page and showing all chats in chat page
Diffstat (limited to 'go-src/windows.go')
| -rw-r--r-- | go-src/windows.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/go-src/windows.go b/go-src/windows.go index 3bc621c..95478c6 100644 --- a/go-src/windows.go +++ b/go-src/windows.go @@ -5,6 +5,7 @@ import ( "os" "os/exec" "runtime" + "strconv" "strings" "gitlab.com/Syndamia/ctfc/go-src/ui" @@ -68,6 +69,8 @@ func chatsWindow(values ...string) { clearScreen() ui.NormalBox(true, "Direct Messages", "Account", "Logout") + allChats := getAllChats() + ui.NumberedFields(allChats...) ui.PageField(0, 0) ui.EmptyLine() @@ -83,7 +86,12 @@ func chatsWindow(values ...string) { inputAction{"H", chatsWindow, []string{"ShowHelp"}}, ) if !handled { - defer showError(invalidCommand, chatsWindow) + // if is number + if chatI, err := strconv.Atoi(input); chatI >= 0 && chatI <= len(allChats) && err == nil { + defer chatWindow(strings.Split(allChats[chatI-1], " : ")[0]) + } else { + defer showError(invalidCommand, chatsWindow) + } } } @@ -106,8 +114,13 @@ func createChatWindow(values ...string) { } func chatWindow(values ...string) { + clearScreen() + currChat := getChat(values[0]) fmt.Println(currChat) + + ui.InputField("Enter anything") + defer chatsWindow() } func logoutWindow(...string) { |
