Fix saving app list in the new format

This commit is contained in:
Jonas Lochmann
2022-11-25 07:25:54 +01:00
parent 89e9b85bda
commit 83619eb98e
2 changed files with 22 additions and 19 deletions
-17
View File
@@ -40,7 +40,6 @@ export class Cache {
categoriesWithModifiedUsedTimes = new Set<string>()
categoriesWithModifiedTasks = new Set<string>()
devicesWithModifiedInstalledApps = new Set<string>()
devicesWithModifiedShowDeviceConnected = new Map<string, boolean>()
invalidiateUserList = false
@@ -241,22 +240,6 @@ export class Cache {
this.categoriesWithModifiedUsedTimes.clear()
}
if (this.devicesWithModifiedInstalledApps.size > 0) {
await database.device.update({
installedAppsVersion: generateVersionId()
}, {
where: {
familyId,
deviceId: {
[Sequelize.Op.in]: setToList(this.devicesWithModifiedInstalledApps)
}
},
transaction
})
this.devicesWithModifiedInstalledApps.clear()
}
if (this.invalidiateUserList) {
await database.family.update({
userListVersion: generateVersionId()
@@ -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)
}