diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-07-22 15:56:13 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-07-22 15:56:13 +0300 |
| commit | 137d7cc9a77139fe7a267800419f0c85884f3e0f (patch) | |
| tree | e78e299c9b75fb9207d08ae42a6664f7281c7dcf /go-src | |
| parent | 6b91e76cfdd409e494fc2555af48037bbe286800 (diff) | |
| download | ctfc-137d7cc9a77139fe7a267800419f0c85884f3e0f.tar ctfc-137d7cc9a77139fe7a267800419f0c85884f3e0f.tar.gz ctfc-137d7cc9a77139fe7a267800419f0c85884f3e0f.zip | |
Improved chats code structure and implemented going to chat via name
Diffstat (limited to 'go-src')
| -rw-r--r-- | go-src/windows.go | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/go-src/windows.go b/go-src/windows.go index 70da48c..20dedca 100644 --- a/go-src/windows.go +++ b/go-src/windows.go @@ -112,26 +112,24 @@ func chatsWindow(values ...string) { if handled == nil { // If user input is number, navigate to chat of given number, else show error - chatI, err := strconv.Atoi(input) - if chatI >= 0 && chatI <= len(allChats) && err == nil { + if chatI, err := strconv.Atoi(input); chatI >= 0 && chatI <= len(allChats) && err == nil { defer chatWindow(strings.Split(allChats[utils.MaxInt(len(allChats)-pageSize*len(values[0]), 0)+chatI-1], " : ")[0]) - } else { - switch input { - case ">": - // If possible, increment to the next page (adds a dot to the end of the string) - if len(values[0]) < totalPages(len(allChats)) { - values[0] += "." - } - case "<": - // If possible, decrement to the previous page (removes a dot from the string) - if len(values[0]) > 1 { - utils.StrShortenRight(&values[0], 1) - } - default: - defer showError(invalidCommand, chatsWindow) + } else if input == ">" { + // If possible, increment to the next page (adds a dot to the end of the string) + if len(values[0]) < totalPages(len(allChats)) { + values[0] += "." } - defer chatsWindow(values...) + } else if input == "<" { + // If possible, decrement to the previous page (removes a dot from the string) + if len(values[0]) > 1 { + utils.StrShortenRight(&values[0], 1) + } + defer chatsWindow(values...) + } else if chatNameExists(input) { + defer chatWindow(input) + } else { + defer showError(invalidCommand, chatsWindow) } } else { defer handled() |
