refactor: upgrade masto
This commit is contained in:
parent
e1332345ad
commit
caa02446c7
6 changed files with 34 additions and 25 deletions
|
@ -1,5 +1,4 @@
|
|||
import { Paginator } from 'masto'
|
||||
import type { WsEvents, mastodon } from 'masto'
|
||||
import type { Paginator, WsEvents, mastodon } from 'masto'
|
||||
import type { PaginatorState } from '~/types'
|
||||
|
||||
export function usePaginator<T, P, U = T>(
|
||||
|
@ -9,11 +8,10 @@ export function usePaginator<T, P, U = T>(
|
|||
preprocess: (items: (T | U)[]) => U[] = items => items as unknown as U[],
|
||||
buffer = 10,
|
||||
) {
|
||||
// TODO: wait PR https://github.com/neet/masto.js/pull/801
|
||||
// called `next` method will mutate the internal state of the variable, and we need its initial state after HMR
|
||||
// called `next` method will mutate the internal state of the variable,
|
||||
// and we need its initial state after HMR
|
||||
// so clone it
|
||||
// @ts-expect-error clone it
|
||||
const paginator: Paginator<T[], P> = new Paginator(_paginator.http, _paginator.nextPath, _paginator.nextParams)
|
||||
const paginator = _paginator.clone()
|
||||
|
||||
const state = ref<PaginatorState>(isMastoInitialised.value ? 'idle' : 'loading')
|
||||
const items = ref<U[]>([])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue