1
0
mirror of https://github.com/Rudi9719/kbtui.git synced 2026-03-22 15:37:23 +00:00

2 Commits

Author SHA1 Message Date
97e055dd61 Sort conversationSlice 2020-01-28 12:43:19 -05:00
9b6bd7442b Merge pull request #55 from Rudi9719/dev
Dev to Master
2020-01-08 09:46:36 -05:00
2 changed files with 7 additions and 39 deletions

View File

@ -1,25 +0,0 @@
// +build !rm_basic_commands allcommands devcmd
package main
import (
"fmt"
)
func init() {
command := Command{
Cmd: []string{"dev"},
Description: "- Switch to dev channels",
Help: "",
Exec: cmdDev,
}
RegisterCommand(command)
}
func cmdDev(cmd []string) {
dev = !dev
printInfo(fmt.Sprintf("You have toggled the dev flag to %+v", dev))
clearView("Chat")
}

21
main.go
View File

@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os"
"sort"
"strings"
"time"
@ -42,11 +43,6 @@ func main() {
defer g.Close()
g.SetManagerFunc(layout)
RunCommand("config", "load")
if dev {
channel.TopicType = "dev"
} else {
channel.TopicType = "chat"
}
go populateList()
go updateChatWindow()
if len(os.Args) > 1 {
@ -386,11 +382,6 @@ func populateChat() {
if channel.Name == testChan.Name {
channel = testChan
channel.TopicName = "general"
if dev {
channel.TopicType = "dev"
} else {
channel.TopicType = "chat"
}
}
}
chat = k.NewChat(channel)
@ -434,13 +425,16 @@ func populateList() {
log.Printf("%+v", err)
} else {
clearView("List")
conversationSlice := testVar.Result.Conversations
sort.SliceStable(conversationSlice, func(i, j int) bool {
return conversationSlice[i].ActiveAt > conversationSlice[j].ActiveAt
})
var textBase = config.Colors.Channels.Basic.stylize("")
var recentPMs = textBase.append(config.Colors.Channels.Header.stylize("---[PMs]---\n"))
var recentPMsCount = 0
var recentChannels = textBase.append(config.Colors.Channels.Header.stylize("---[Teams]---\n"))
var recentChannelsCount = 0
for _, s := range testVar.Result.Conversations {
for _, s := range conversationSlice {
channels = append(channels, s.Channel)
if s.Channel.MembersType == keybase.TEAM {
recentChannelsCount++
@ -632,8 +626,7 @@ func handleMessage(api keybase.ChatAPI) {
}
}
if api.Msg.Channel.MembersType == channel.MembersType && cleanChannelName(api.Msg.Channel.Name) == channel.Name {
if channel.MembersType == keybase.USER || channel.MembersType == keybase.TEAM && channel.TopicName == api.Msg.Channel.TopicName &&
channel.TopicType == api.Msg.Channel.TopicType {
if channel.MembersType == keybase.USER || channel.MembersType == keybase.TEAM && channel.TopicName == api.Msg.Channel.TopicName {
printToView("Chat", formatOutput(api).string())
chat := k.NewChat(channel)
lastMessage.ID = api.Msg.ID