mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 07:22:24 -05:00
[feature] tentatively start adding polls support (#2249)
This commit is contained in:
parent
297b6eeaaa
commit
c6e00afc7c
36 changed files with 657 additions and 393 deletions
|
|
@ -222,7 +222,7 @@ func (t *timeline) getXBetweenIDs(ctx context.Context, amount int, behindID stri
|
|||
// a point where the items are out of the range
|
||||
// we're interested in.
|
||||
rangeF = func(e *list.Element) (bool, error) {
|
||||
entry := e.Value.(*indexedItemsEntry) //nolint:forcetypeassert
|
||||
entry := e.Value.(*indexedItemsEntry)
|
||||
|
||||
if entry.itemID >= behindID {
|
||||
// ID of this item is too high,
|
||||
|
|
@ -276,7 +276,6 @@ func (t *timeline) getXBetweenIDs(ctx context.Context, amount int, behindID stri
|
|||
// Move the mark back one place each loop.
|
||||
beforeIDMark = e
|
||||
|
||||
//nolint:forcetypeassert
|
||||
if entry := e.Value.(*indexedItemsEntry); entry.itemID <= beforeID {
|
||||
// We've gone as far as we can through
|
||||
// the list and reached entries that are
|
||||
|
|
@ -319,7 +318,7 @@ func (t *timeline) getXBetweenIDs(ctx context.Context, amount int, behindID stri
|
|||
// To preserve ordering, we need to reverse the slice
|
||||
// when we're finished.
|
||||
for e := beforeIDMark; e != nil; e = e.Prev() {
|
||||
entry := e.Value.(*indexedItemsEntry) //nolint:forcetypeassert
|
||||
entry := e.Value.(*indexedItemsEntry)
|
||||
|
||||
if entry.itemID == beforeID {
|
||||
// Don't include the beforeID
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ func (t *timeline) indexXBetweenIDs(ctx context.Context, amount int, behindID st
|
|||
)
|
||||
|
||||
for e := t.items.data.Front(); e != nil; e = e.Next() {
|
||||
entry := e.Value.(*indexedItemsEntry) //nolint:forcetypeassert
|
||||
entry := e.Value.(*indexedItemsEntry)
|
||||
|
||||
position++
|
||||
|
||||
|
|
@ -174,7 +174,6 @@ func (t *timeline) grab(ctx context.Context, amount int, behindID string, before
|
|||
// Don't grab more than we need to.
|
||||
amount-grabbed,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
// Grab function already checks for
|
||||
// db.ErrNoEntries, so if an error
|
||||
|
|
@ -280,5 +279,5 @@ func (t *timeline) OldestIndexedItemID() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
return e.Value.(*indexedItemsEntry).itemID //nolint:forcetypeassert
|
||||
return e.Value.(*indexedItemsEntry).itemID
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ func (i *indexedItems) insertIndexed(ctx context.Context, newEntry *indexedItems
|
|||
for e := i.data.Front(); e != nil; e = e.Next() {
|
||||
currentPosition++
|
||||
|
||||
currentEntry := e.Value.(*indexedItemsEntry) //nolint:forcetypeassert
|
||||
currentEntry := e.Value.(*indexedItemsEntry)
|
||||
|
||||
// Check if we need to skip inserting this item based on
|
||||
// the current item.
|
||||
|
|
|
|||
|
|
@ -219,7 +219,6 @@ func (m *manager) UnprepareItemFromAllTimelines(ctx context.Context, itemID stri
|
|||
// Work through all timelines held by this
|
||||
// manager, and call Unprepare for each.
|
||||
m.timelines.Range(func(_ any, v any) bool {
|
||||
// nolint:forcetypeassert
|
||||
if err := v.(Timeline).Unprepare(ctx, itemID); err != nil {
|
||||
errs.Append(err)
|
||||
}
|
||||
|
|
@ -248,7 +247,7 @@ func (m *manager) getOrCreateTimeline(ctx context.Context, timelineID string) Ti
|
|||
i, ok := m.timelines.Load(timelineID)
|
||||
if ok {
|
||||
// Timeline already existed in sync.Map.
|
||||
return i.(Timeline) //nolint:forcetypeassert
|
||||
return i.(Timeline)
|
||||
}
|
||||
|
||||
// Timeline did not yet exist in sync.Map.
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ func (t *timeline) prepareXBetweenIDs(ctx context.Context, amount int, behindID
|
|||
if frontToBack {
|
||||
// Paging forwards / down.
|
||||
for e := t.items.data.Front(); e != nil; e = e.Next() {
|
||||
entry := e.Value.(*indexedItemsEntry) //nolint:forcetypeassert
|
||||
entry := e.Value.(*indexedItemsEntry)
|
||||
|
||||
if entry.itemID > behindID {
|
||||
l.Trace("item is too new, continuing")
|
||||
|
|
@ -91,7 +91,7 @@ func (t *timeline) prepareXBetweenIDs(ctx context.Context, amount int, behindID
|
|||
} else {
|
||||
// Paging backwards / up.
|
||||
for e := t.items.data.Back(); e != nil; e = e.Prev() {
|
||||
entry := e.Value.(*indexedItemsEntry) //nolint:forcetypeassert
|
||||
entry := e.Value.(*indexedItemsEntry)
|
||||
|
||||
if entry.itemID < beforeID {
|
||||
l.Trace("item is too old, continuing")
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ func (t *timeline) Prune(desiredPreparedItemsLength int, desiredIndexedItemsLeng
|
|||
continue
|
||||
}
|
||||
|
||||
entry := e.Value.(*indexedItemsEntry) //nolint:forcetypeassert
|
||||
entry := e.Value.(*indexedItemsEntry)
|
||||
if entry.prepared == nil {
|
||||
// It's already unprepared (mood).
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ func (t *timeline) Remove(ctx context.Context, statusID string) (int, error) {
|
|||
|
||||
var toRemove []*list.Element
|
||||
for e := t.items.data.Front(); e != nil; e = e.Next() {
|
||||
entry := e.Value.(*indexedItemsEntry) // nolint:forcetypeassert
|
||||
entry := e.Value.(*indexedItemsEntry)
|
||||
|
||||
if entry.itemID != statusID {
|
||||
// Not relevant.
|
||||
|
|
@ -78,7 +78,7 @@ func (t *timeline) RemoveAllByOrBoosting(ctx context.Context, accountID string)
|
|||
|
||||
var toRemove []*list.Element
|
||||
for e := t.items.data.Front(); e != nil; e = e.Next() {
|
||||
entry := e.Value.(*indexedItemsEntry) // nolint:forcetypeassert
|
||||
entry := e.Value.(*indexedItemsEntry)
|
||||
|
||||
if entry.accountID != accountID && entry.boostOfAccountID != accountID {
|
||||
// Not relevant.
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ func (t *timeline) Unprepare(ctx context.Context, itemID string) error {
|
|||
}
|
||||
|
||||
for e := t.items.data.Front(); e != nil; e = e.Next() {
|
||||
entry := e.Value.(*indexedItemsEntry) // nolint:forcetypeassert
|
||||
entry := e.Value.(*indexedItemsEntry)
|
||||
|
||||
if entry.itemID != itemID && entry.boostOfID != itemID {
|
||||
// Not relevant.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue