mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Fix saving app list in the new format
This commit is contained in:
@@ -40,7 +40,6 @@ export class Cache {
|
|||||||
categoriesWithModifiedUsedTimes = new Set<string>()
|
categoriesWithModifiedUsedTimes = new Set<string>()
|
||||||
categoriesWithModifiedTasks = new Set<string>()
|
categoriesWithModifiedTasks = new Set<string>()
|
||||||
|
|
||||||
devicesWithModifiedInstalledApps = new Set<string>()
|
|
||||||
devicesWithModifiedShowDeviceConnected = new Map<string, boolean>()
|
devicesWithModifiedShowDeviceConnected = new Map<string, boolean>()
|
||||||
|
|
||||||
invalidiateUserList = false
|
invalidiateUserList = false
|
||||||
@@ -241,22 +240,6 @@ export class Cache {
|
|||||||
this.categoriesWithModifiedUsedTimes.clear()
|
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) {
|
if (this.invalidiateUserList) {
|
||||||
await database.family.update({
|
await database.family.update({
|
||||||
userListVersion: generateVersionId()
|
userListVersion: generateVersionId()
|
||||||
|
|||||||
@@ -16,12 +16,32 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { UpdateInstalledAppsAction } from '../../../../action'
|
import { UpdateInstalledAppsAction } from '../../../../action'
|
||||||
|
import { types } from '../../../../database/encryptedapplist'
|
||||||
|
import { generateVersionId } from '../../../../util/token'
|
||||||
import { Cache } from '../cache'
|
import { Cache } from '../cache'
|
||||||
|
|
||||||
export async function dispatchUpdateInstalledApps (_: {
|
export async function dispatchUpdateInstalledApps ({ deviceId, action, cache }: {
|
||||||
deviceId: string
|
deviceId: string
|
||||||
action: UpdateInstalledAppsAction
|
action: UpdateInstalledAppsAction
|
||||||
cache: Cache
|
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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user