Filter actioned messages from listing by default, add ?all=true override
This commit is contained in:
parent
80bdc5fb6a
commit
5084e879ef
Binary file not shown.
21
main.go
21
main.go
|
|
@ -302,17 +302,22 @@ func handleMessages(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// Filter by source if specified
|
// Filter by source if specified
|
||||||
sourceFilter := r.URL.Query().Get("source")
|
sourceFilter := r.URL.Query().Get("source")
|
||||||
if sourceFilter != "" {
|
showAll := r.URL.Query().Get("all") == "true"
|
||||||
var filtered []UnifiedMessage
|
|
||||||
for _, msg := range messages {
|
var filtered []UnifiedMessage
|
||||||
if msg.Source == sourceFilter {
|
for _, msg := range messages {
|
||||||
filtered = append(filtered, msg)
|
if sourceFilter != "" && msg.Source != sourceFilter {
|
||||||
}
|
continue
|
||||||
}
|
}
|
||||||
messages = filtered
|
// By default, exclude actioned messages (archived/deleted/etc.)
|
||||||
|
// Use ?all=true to include everything
|
||||||
|
if !showAll && orch.HasAction(msg.ID) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
filtered = append(filtered, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
json.NewEncoder(w).Encode(messages)
|
json.NewEncoder(w).Encode(filtered)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMessagesNew(w http.ResponseWriter, r *http.Request) {
|
func handleMessagesNew(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue