fix: update cache + timeline when items are updated/deleted (#556)
This commit is contained in:
parent
720b5114af
commit
dc76ab2477
5 changed files with 28 additions and 15 deletions
|
@ -20,16 +20,29 @@ export function usePaginator<T>(paginator: Paginator<any, T[]>, stream?: WsEvent
|
|||
}
|
||||
|
||||
stream?.on(eventType, (status) => {
|
||||
if ('uri' in status)
|
||||
cacheStatus(status, undefined, true)
|
||||
|
||||
prevItems.value.unshift(status as any)
|
||||
})
|
||||
|
||||
// TODO: update statuses
|
||||
stream?.on('status.update', (status) => {
|
||||
cacheStatus(status, undefined, true)
|
||||
|
||||
const index = items.value.findIndex((s: any) => s.id === status.id)
|
||||
if (index >= 0)
|
||||
items.value[index] = status as any
|
||||
})
|
||||
|
||||
stream?.on('delete', (id) => {
|
||||
removeCachedStatus(id)
|
||||
|
||||
const index = items.value.findIndex((s: any) => s.id === id)
|
||||
if (index >= 0)
|
||||
items.value.splice(index, 1)
|
||||
})
|
||||
|
||||
async function loadNext() {
|
||||
if (state.value !== 'idle')
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue