1
0
mirror of https://github.com/Rudi9719/kbtui.git synced 2026-03-22 09:57:24 +00:00

updated to pull channel members

This commit is contained in:
2019-10-16 13:17:51 -06:00
parent 60c55b69bc
commit 5db54c9934

29
main.go
View File

@ -221,6 +221,30 @@ func populateList() {
} }
} }
func getCurrentChannelMembership() []string {
var rs []string
if channel.Name != "" {
t := k.NewTeam(channel.Name)
if testVar, err := t.MemberList(); err != nil {
printToView("Feed", fmt.Sprintf("Error getting member list - %+v", err))
} else {
for _, m := range testVar.Result.Members.Owners {
rs = append(rs, fmt.Sprintf("%+v", m.Username))
}
for _, m := range testVar.Result.Members.Admins {
rs = append(rs, fmt.Sprintf("%+v", m.Username))
}
for _, m := range testVar.Result.Members.Writers {
rs = append(rs, fmt.Sprintf("%+v", m.Username))
}
for _, m := range testVar.Result.Members.Readers {
rs = append(rs, fmt.Sprintf("%+v", m.Username))
}
}
}
return rs
}
func filterStringSlice(ss []string, fv string) []string { func filterStringSlice(ss []string, fv string) []string {
var rs []string var rs []string
for _, s := range ss { for _, s := range ss {
@ -307,6 +331,11 @@ func generateChannelTabCompletionSlice(inputWord string) []string {
firstSlice = appendIfNotInSlice(firstSlice, cleanChannelName(s.Name)) firstSlice = appendIfNotInSlice(firstSlice, cleanChannelName(s.Name))
} }
} }
// next fetch all members of the current channel and add them to the slice
secondSlice := getCurrentChannelMembership()
for _, m := range secondSlice {
firstSlice = appendIfNotInSlice(firstSlice, m)
}
// now return the resultSlice which contains all that are prefixed with inputWord // now return the resultSlice which contains all that are prefixed with inputWord
resultSlice := filterStringSlice(firstSlice, inputWord) resultSlice := filterStringSlice(firstSlice, inputWord)
return resultSlice return resultSlice