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

@ -13,6 +13,9 @@ export function setCached(key: string, value: any, override = false) {
if (override || !cache.has(key))
cache.set(key, value)
}
function removeCached(key: string) {
cache.delete(key)
}
export function fetchStatus(id: string, force = false): Promise<Status> {
const server = currentServer.value
@ -82,6 +85,10 @@ export function cacheStatus(status: Status, server = currentServer.value, overri
setCached(`${server}:status:${status.id}`, status, override)
}
export function removeCachedStatus(id: string, server = currentServer.value) {
removeCached(`${server}:status:${id}`)
}
export function cacheAccount(account: Account, server = currentServer.value, override?: boolean) {
setCached(`${server}:account:${account.id}`, account, override)
setCached(`${server}:account:${account.acct}`, account, override)