fix: update cache + timeline when items are updated/deleted (#556)

This commit is contained in:
Daniel Roe 2022-12-25 15:52:37 +01:00 committed by GitHub
parent 720b5114af
commit dc76ab2477
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 15 deletions

View file

@ -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