hide deleted from last user view

This commit is contained in:
Umputun
2018-06-18 15:49:13 -05:00
parent d302679f07
commit c445ecece0
2 changed files with 10 additions and 1 deletions
+9
View File
@@ -238,3 +238,12 @@ func renderJSONFromBytes(w http.ResponseWriter, r *http.Request, data []byte) {
log.Printf("[WARN] failed to send response to %s, %s", r.RemoteAddr, err)
}
}
func filterComments(comments []store.Comment, fn func(c store.Comment) bool) (filtered []store.Comment) {
for _, c := range comments {
if fn(c) {
filtered = append(filtered, c)
}
}
return filtered
}
+1 -1
View File
@@ -185,7 +185,7 @@ func (s *Rest) findUserCommentsCtrl(w http.ResponseWriter, r *http.Request) {
return nil, e
}
comments = s.adminService.alterComments(comments, r)
comments = filterComments(comments, func(c store.Comment) bool { return !c.Deleted })
count, e := s.DataService.UserCount(siteID, userID)
if e != nil {
return nil, e