@@ 2,6 2,8 @@ changelog
### next
++ Another tune up for thread sort.
+
+ Rework setup and admin screens.
+ Add some compat for forgefed activities.
@@ 1319,6 1319,14 @@ func threadsort(honks []*Honk) []*Honk {
thread := make([]*Honk, 0, len(honks))
var nextlevel func(p *Honk)
level := 0
+ hasreply := func(p *Honk, who string) bool {
+ for _, h := range kids[p.XID] {
+ if h.Honker == who {
+ return true
+ }
+ }
+ return false
+ }
nextlevel = func(p *Honk) {
levelup := level < 4
if pp := honkx[p.RID]; p.RID == "" || (pp != nil && sameperson(p, pp)) {
@@ 1334,16 1342,20 @@ func threadsort(honks []*Honk) []*Honk {
}
p.Style += fmt.Sprintf(" level%d", level)
childs := kids[p.XID]
- if false {
- sort.SliceStable(childs, func(i, j int) bool {
- return sameperson(childs[i], p) && !sameperson(childs[j], p)
- })
- }
- if true {
- sort.SliceStable(childs, func(i, j int) bool {
- return !sameperson(childs[i], p) && sameperson(childs[j], p)
- })
- }
+ sort.SliceStable(childs, func(i, j int) bool {
+ var ipts, jpts int
+ if sameperson(childs[i], p) {
+ ipts += 1
+ } else if hasreply(childs[i], p.Honker) {
+ ipts += 2
+ }
+ if sameperson(childs[j], p) {
+ jpts += 1
+ } else if hasreply(childs[j], p.Honker) {
+ jpts += 2
+ }
+ return ipts > jpts
+ })
for _, h := range childs {
if !done[h] {
done[h] = true