fix: paginator values being cloned
This commit is contained in:
parent
e521bad2d1
commit
5b1803cdd0
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.values().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)
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ export function usePaginator<T, P, U = T>(
|
||||||
// and we need its initial state after HMR
|
// and we need its initial state after HMR
|
||||||
// so clone it
|
// so clone it
|
||||||
|
|
||||||
|
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[]>([])
|
||||||
|
|
@ -74,7 +75,7 @@ export function usePaginator<T, P, U = T>(
|
||||||
|
|
||||||
state.value = 'loading'
|
state.value = 'loading'
|
||||||
try {
|
try {
|
||||||
const result = await paginator.values().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