Fix saving app list in the new format

This commit is contained in:
Jonas Lochmann 2022-11-21 01:00:00 +01:00
parent 89e9b85bda
commit 83619eb98e
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36
2 changed files with 22 additions and 19 deletions

View file

@ -16,12 +16,32 @@
*/
import { UpdateInstalledAppsAction } from '../../../../action'
import { types } from '../../../../database/encryptedapplist'
import { generateVersionId } from '../../../../util/token'
import { Cache } from '../cache'
export async function dispatchUpdateInstalledApps (_: {
export async function dispatchUpdateInstalledApps ({ deviceId, action, cache }: {
deviceId: string
action: UpdateInstalledAppsAction
cache: Cache
}) {
// do nothing
async function upsert({ type, data }: { type: number, data: Buffer }) {
await cache.database.encryptedAppList.upsert({
familyId: cache.familyId,
deviceId,
type,
version: generateVersionId(),
data
}, { transaction: cache.transaction })
}
if (action.base) {
await upsert({ type: types.base, data: action.base })
}
if (action.diff) {
await upsert({ type: types.diff, data: action.diff })
}
cache.incrementTriggeredSyncLevel(1)
}