Fix tag filtering

master
bel 2020-01-20 16:06:33 -07:00
parent 097ca9b8c0
commit b47327dfe6
1 changed files with 10 additions and 8 deletions

View File

@ -27,17 +27,19 @@ func (a *Ajax) loadTasks(w http.ResponseWriter, r *http.Request) error {
if len(whitelistTags) == 0 {
return true
}
whitelistTagMap := make(map[string]struct{})
for _, tag := range whitelistTags {
whitelistTagMap[tag] = struct{}{}
}
for _, whitelisted := range whitelistTags {
found := false
for _, tag := range t.Tags {
if _, ok := whitelistTagMap[tag]; ok {
return true
if whitelisted == tag {
found = true
}
}
if !found {
return false
}
}
return true
}
filterSubstr := func(t *task.Task) bool {
substr := form.Get(r, "s")
return substr == "" || strings.Contains(fmt.Sprintf("%+v", t), substr)