fix: paginator values being cloned
This commit is contained in:
parent
a42fdcb26a
commit
65cd76a108
2 changed files with 4 additions and 2 deletions
|
|
@ -45,9 +45,10 @@ export function useNotifications() {
|
||||||
|
|
||||||
const position = await client.value.v1.markers.fetch({ timeline: ['notifications'] })
|
const position = await client.value.v1.markers.fetch({ timeline: ['notifications'] })
|
||||||
const paginator = client.value.v1.notifications.list({ limit: 30 })
|
const paginator = client.value.v1.notifications.list({ limit: 30 })
|
||||||
|
const paginatorValues = paginator.values()
|
||||||
|
|
||||||
do {
|
do {
|
||||||
const result = await paginator.next()
|
const result = await paginatorValues.next()
|
||||||
if (!result.done && result.value.length) {
|
if (!result.done && result.value.length) {
|
||||||
for (const notification of result.value) {
|
for (const notification of result.value) {
|
||||||
if (notification.id === position.notifications.lastReadId)
|
if (notification.id === position.notifications.lastReadId)
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ export function usePaginator<T, P, U = T>(
|
||||||
// so clone it
|
// so clone it
|
||||||
const paginator = _paginator.clone()
|
const paginator = _paginator.clone()
|
||||||
|
|
||||||
|
const paginatorValues = paginator.values()
|
||||||
const state = ref<PaginatorState>(isHydrated.value ? 'idle' : 'loading')
|
const state = ref<PaginatorState>(isHydrated.value ? 'idle' : 'loading')
|
||||||
const items = ref<U[]>([])
|
const items = ref<U[]>([])
|
||||||
const nextItems = ref<U[]>([])
|
const nextItems = ref<U[]>([])
|
||||||
|
|
@ -75,7 +76,7 @@ export function usePaginator<T, P, U = T>(
|
||||||
|
|
||||||
state.value = 'loading'
|
state.value = 'loading'
|
||||||
try {
|
try {
|
||||||
const result = await paginator.next()
|
const result = await paginatorValues.next()
|
||||||
|
|
||||||
if (!result.done && result.value.length) {
|
if (!result.done && result.value.length) {
|
||||||
const preprocessedItems = preprocess([...nextItems.value, ...result.value] as (U | T)[])
|
const preprocessedItems = preprocess([...nextItems.value, ...result.value] as (U | T)[])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue