oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package conversation
2
3import "sort"
4
5type Entry struct {
6 Message *MessageView
7 Card *CardView
8 Sequence int64
9}
10
11func (p *Page) BuildFeed() {
12 p.Feed = nil
13 for i := range p.Messages {
14 m := &p.Messages[i]
15 hidden := false
16 for _, c := range p.Cards {
17 if c.Kind == "project_setup" && c.ID == m.ID {
18 hidden = true
19 break
20 }
21 }
22 if hidden {
23 continue
24 }
25 p.Feed = append(p.Feed, Entry{Message: m, Sequence: m.Sequence})
26 }
27 for i := range p.Cards {
28 c := &p.Cards[i]
29 sequence := c.Sequence
30 if sequence == 0 && len(p.Messages) > 0 {
31 sequence = p.Messages[len(p.Messages)-1].Sequence + 1
32 }
33 p.Feed = append(p.Feed, Entry{Card: c, Sequence: sequence})
34 }
35 sort.SliceStable(p.Feed, func(i, j int) bool { return p.Feed[i].Sequence < p.Feed[j].Sequence })
36}
37