[bugfix] fix case of failed timeline preload causing lockups (#4182)

- moves preloader Done() function calling to be handled entirely by the preloader, not the caller
- adds tests for multiple preload success / failure / clear states

Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4182
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
This commit is contained in:
kim 2025-05-17 11:52:49 +00:00 committed by kim
commit 3a29a59e55
3 changed files with 129 additions and 37 deletions

View file

@ -196,14 +196,9 @@ func (t *StatusTimeline) Preload(
n int,
err error,
) {
t.preloader.CheckPreload(func(ptr *any) {
err = t.preloader.CheckPreload(func() error {
n, err = t.preload(loadPage, filter)
if err != nil {
return
}
// Mark as preloaded.
t.preloader.Done(ptr)
return err
})
return
}