fix: issue with group selection selecting users with partial name of group users

This commit is contained in:
Slug-Boi
2024-11-16 22:17:37 +01:00
parent 6e2293beb5
commit ea0755af29
+4 -18
View File
@@ -1,7 +1,6 @@
package tui package tui
import ( import (
"log"
"slices" "slices"
"strings" "strings"
@@ -76,11 +75,13 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
delete(selected, string(sel)) delete(selected, string(sel))
} }
users := utils.Groups[group] users := utils.Groups[group]
//TODO: this may be able to be done in a more efficient way currently this would scale poorly
for k, v := range dupProtect { for k, v := range dupProtect {
if _, ok := selected[k]; !ok { if _, ok := selected[k]; !ok {
for _, user := range users { for _, user := range users {
if strings.Contains(user.Names, v) { split := strings.Split(user.Names, "/")
selected[k] = item(k) if split[0] == v || split[1] == v {
selectToggle(item(k))
} }
} }
} }
@@ -144,18 +145,3 @@ func (m *mainModel) Next() {
m.index++ m.index++
} }
} }
func Entry_GR() string {
p := tea.NewProgram(newModel())
m, err := p.Run()
if err != nil {
log.Fatal(err)
}
if m.(mainModel).currentFocusedModel() != "" {
// returns the group name
return strings.Split(m.(mainModel).currentFocusedModel(), ":")[0]
}
return ""
}