Sort items in timeline
This commit is contained in:
parent
36af7ae115
commit
062e60ee81
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/pstuifzand/microsub-server/microsub"
|
||||
|
@ -158,6 +159,15 @@ func (b *memoryBackend) TimelineGet(after, before, channel string) microsub.Time
|
|||
}
|
||||
}
|
||||
|
||||
sort.Slice(items, func(a, b int) bool {
|
||||
timeA, okA := items[a]["published"].(string)
|
||||
timeB, okB := items[b]["published"].(string)
|
||||
if okA && okB {
|
||||
return strings.Compare(timeA, timeB) > 0
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
return microsub.Timeline{
|
||||
Paging: microsub.Pagination{},
|
||||
Items: items,
|
||||
|
|
Loading…
Reference in New Issue
Block a user