fix: use lazy pagination (#563)
This commit is contained in:
parent
59d0cfa10e
commit
c8a7e6e7e7
4 changed files with 34 additions and 4 deletions
|
@ -3,7 +3,7 @@ import { useDeactivated } from './lifecycle'
|
|||
import type { PaginatorState } from '~/types'
|
||||
|
||||
export function usePaginator<T>(paginator: Paginator<any, T[]>, stream?: WsEvents, eventType: 'notification' | 'update' = 'update') {
|
||||
const state = ref<PaginatorState>('idle')
|
||||
const state = ref<PaginatorState>(isMastoInitialised.value ? 'idle' : 'loading')
|
||||
const items = ref<T[]>([])
|
||||
const nextItems = ref<T[]>([])
|
||||
const prevItems = ref<T[]>([])
|
||||
|
@ -74,6 +74,13 @@ export function usePaginator<T>(paginator: Paginator<any, T[]>, stream?: WsEvent
|
|||
bound.update()
|
||||
}, 1000)
|
||||
|
||||
if (!isMastoInitialised.value) {
|
||||
watchOnce(isMastoInitialised, () => {
|
||||
state.value = 'idle'
|
||||
loadNext()
|
||||
})
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [isInScreen, state],
|
||||
() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue