mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 18:12:25 -05:00
fix timeline preload state check
This commit is contained in:
parent
b026299b46
commit
cc86a08f15
3 changed files with 9 additions and 68 deletions
12
internal/cache/timeline/status.go
vendored
12
internal/cache/timeline/status.go
vendored
|
|
@ -74,6 +74,8 @@ type StatusMeta struct {
|
||||||
// as-needed, caching prepared frontend representations where
|
// as-needed, caching prepared frontend representations where
|
||||||
// possible. This is largely wrapping code for our own codebase
|
// possible. This is largely wrapping code for our own codebase
|
||||||
// to be able to smoothly interact with structr.Timeline{}.
|
// to be able to smoothly interact with structr.Timeline{}.
|
||||||
|
|
||||||
|
// ...
|
||||||
type StatusTimeline struct {
|
type StatusTimeline struct {
|
||||||
|
|
||||||
// underlying timeline cache of *StatusMeta{},
|
// underlying timeline cache of *StatusMeta{},
|
||||||
|
|
@ -302,7 +304,7 @@ func (t *StatusTimeline) Preload(
|
||||||
|
|
||||||
// Check if seen recently.
|
// Check if seen recently.
|
||||||
last := recentBoosts[id]
|
last := recentBoosts[id]
|
||||||
value.repeatBoost = last < 40
|
value.repeatBoost = (last < 40)
|
||||||
|
|
||||||
// Update last-seen idx.
|
// Update last-seen idx.
|
||||||
recentBoosts[id] = idx
|
recentBoosts[id] = idx
|
||||||
|
|
@ -311,8 +313,12 @@ func (t *StatusTimeline) Preload(
|
||||||
|
|
||||||
// Mark timeline as preloaded.
|
// Mark timeline as preloaded.
|
||||||
old := t.preload.Swap(new(any))
|
old := t.preload.Swap(new(any))
|
||||||
if old != nil && *old != false {
|
if old != nil {
|
||||||
log.Errorf(ctx, "BUG: invalid timeline preload state: %#v", *old)
|
switch t := (*old).(type) {
|
||||||
|
case *sync.WaitGroup:
|
||||||
|
default:
|
||||||
|
log.Errorf(ctx, "BUG: invalid timeline preload state: %#v", t)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
|
||||||
|
|
@ -90,35 +90,3 @@ func (p *Processor) HomeTimelineGet(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// preloadHomeTimeline will ensure that the timeline
|
|
||||||
// cache for home owned by given account is preloaded.
|
|
||||||
// func (p *Processor) preloadHomeTimeline(
|
|
||||||
// ctx context.Context,
|
|
||||||
// account *gtsmodel.Account,
|
|
||||||
// ) error {
|
|
||||||
|
|
||||||
// // Get (and so, create) home timeline cache for account ID.
|
|
||||||
// timeline := p.state.Caches.Timelines.Home.MustGet(account.ID)
|
|
||||||
|
|
||||||
// // Preload timeline with funcs.
|
|
||||||
// n, err := timeline.Preload(ctx,
|
|
||||||
|
|
||||||
// // Database load function.
|
|
||||||
// func(page *paging.Page) ([]*gtsmodel.Status, error) {
|
|
||||||
// return p.state.DB.GetHomeTimeline(ctx, account.ID, page)
|
|
||||||
// },
|
|
||||||
|
|
||||||
// // Status filtering function.
|
|
||||||
// func(status *gtsmodel.Status) (bool, error) {
|
|
||||||
// ok, err := p.visFilter.StatusHomeTimelineable(ctx, account, status)
|
|
||||||
// return !ok, err
|
|
||||||
// },
|
|
||||||
// )
|
|
||||||
// if err != nil {
|
|
||||||
// return gtserror.Newf("error preloading home timeline %s: %w", account.ID, err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// log.Infof(ctx, "%s: preloaded %d", account.Username, n)
|
|
||||||
// return nil
|
|
||||||
// }
|
|
||||||
|
|
|
||||||
|
|
@ -103,36 +103,3 @@ func (p *Processor) ListTimelineGet(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// preloadListTimeline will ensure that the timeline
|
|
||||||
// cache for list owned by given account is preloaded.
|
|
||||||
// func (p *Processor) preloadListTimeline(
|
|
||||||
// ctx context.Context,
|
|
||||||
// account *gtsmodel.Account,
|
|
||||||
// list *gtsmodel.List,
|
|
||||||
// ) error {
|
|
||||||
|
|
||||||
// // Get (and so, create) list timeline cache for list ID.
|
|
||||||
// timeline := p.state.Caches.Timelines.List.MustGet(list.ID)
|
|
||||||
|
|
||||||
// // Preload timeline with funcs.
|
|
||||||
// n, err := timeline.Preload(ctx,
|
|
||||||
|
|
||||||
// // Database load function.
|
|
||||||
// func(page *paging.Page) ([]*gtsmodel.Status, error) {
|
|
||||||
// return p.state.DB.GetListTimeline(ctx, list.ID, page)
|
|
||||||
// },
|
|
||||||
|
|
||||||
// // Status filtering function.
|
|
||||||
// func(status *gtsmodel.Status) (bool, error) {
|
|
||||||
// ok, err := p.visFilter.StatusHomeTimelineable(ctx, account, status)
|
|
||||||
// return !ok, err
|
|
||||||
// },
|
|
||||||
// )
|
|
||||||
// if err != nil {
|
|
||||||
// return gtserror.Newf("error preloading list timeline %s: %w", list.ID, err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// log.Infof(ctx, "%s[%q]: preloaded %d", account.Username, list.Title, n)
|
|
||||||
// return nil
|
|
||||||
// }
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue