8d5690d63d
* remove get() with string pt 1 * remove get() with string pt 2 * fix typo * fix some null exceptions in get() * fixup code style
23 lines
684 B
JavaScript
23 lines
684 B
JavaScript
import { store } from '../_store/store'
|
|
import { getLists } from '../_api/lists'
|
|
import { cacheFirstUpdateAfter } from '../_utils/sync'
|
|
import {
|
|
getLists as getListsFromDatabase,
|
|
setLists as setListsInDatabase
|
|
} from '../_database/meta'
|
|
|
|
export async function updateLists () {
|
|
let { currentInstance, accessToken } = store.get()
|
|
|
|
await cacheFirstUpdateAfter(
|
|
() => getLists(currentInstance, accessToken),
|
|
() => getListsFromDatabase(currentInstance),
|
|
lists => setListsInDatabase(currentInstance, lists),
|
|
lists => {
|
|
let { instanceLists } = store.get()
|
|
instanceLists[currentInstance] = lists
|
|
store.set({instanceLists: instanceLists})
|
|
}
|
|
)
|
|
}
|