summaryrefslogtreecommitdiff
path: root/internal/timeline/postindex.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-06-19 11:18:55 +0200
committerLibravatar GitHub <noreply@github.com>2021-06-19 11:18:55 +0200
commitaa8a0d08501cbb22400a67ece85c45fdfbdc6131 (patch)
tree4a4581fb8f1c9bf8cac742be15d7a57eec170a1b /internal/timeline/postindex.go
parentupdate CONTRIBUTING with css bundling instructions, and go fmt (#48) (diff)
downloadgotosocial-aa8a0d08501cbb22400a67ece85c45fdfbdc6131.tar.xz
Streaming (#49)
Add new status and notification websocket streaming capabilities
Diffstat (limited to 'internal/timeline/postindex.go')
-rw-r--r--internal/timeline/postindex.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/internal/timeline/postindex.go b/internal/timeline/postindex.go
index 7142035a7..44765bf50 100644
--- a/internal/timeline/postindex.go
+++ b/internal/timeline/postindex.go
@@ -14,7 +14,7 @@ type postIndexEntry struct {
boostOfID string
}
-func (p *postIndex) insertIndexed(i *postIndexEntry) error {
+func (p *postIndex) insertIndexed(i *postIndexEntry) (bool, error) {
if p.data == nil {
p.data = &list.List{}
}
@@ -22,7 +22,7 @@ func (p *postIndex) insertIndexed(i *postIndexEntry) error {
// if we have no entries yet, this is both the newest and oldest entry, so just put it in the front
if p.data.Len() == 0 {
p.data.PushFront(i)
- return nil
+ return true, nil
}
var insertMark *list.Element
@@ -34,14 +34,14 @@ func (p *postIndex) insertIndexed(i *postIndexEntry) error {
entry, ok := e.Value.(*postIndexEntry)
if !ok {
- return errors.New("index: could not parse e as a postIndexEntry")
+ return false, errors.New("index: could not parse e as a postIndexEntry")
}
// don't insert this if it's a boost of a status we've seen recently
if i.boostOfID != "" {
if i.boostOfID == entry.boostOfID || i.boostOfID == entry.statusID {
if position < boostReinsertionDepth {
- return nil
+ return false, nil
}
}
}
@@ -55,16 +55,16 @@ func (p *postIndex) insertIndexed(i *postIndexEntry) error {
// make sure we don't insert a duplicate
if entry.statusID == i.statusID {
- return nil
+ return false, nil
}
}
if insertMark != nil {
p.data.InsertBefore(i, insertMark)
- return nil
+ return true, nil
}
// if we reach this point it's the oldest post we've seen so put it at the back
p.data.PushBack(i)
- return nil
+ return true, nil
}