Fix session reset for the session duration limit

This commit is contained in:
Jonas Lochmann 2020-05-25 02:00:00 +02:00
parent ef1b19a01c
commit 7b7f888335
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36

View file

@ -121,19 +121,19 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache }:
}) })
if (oldItem) { if (oldItem) {
if (hasTrustedTimestamp) {
oldItem.lastUsage = action.trustedTimestamp.toString(10)
}
if ( if (
hasTrustedTimestamp && hasTrustedTimestamp &&
action.trustedTimestamp > parseInt(oldItem.lastUsage, 10) + oldItem.sessionPauseDuration action.trustedTimestamp - item.timeToAdd > parseInt(oldItem.lastUsage, 10) + oldItem.sessionPauseDuration
) { ) {
oldItem.lastSessionDuration = item.timeToAdd oldItem.lastSessionDuration = item.timeToAdd
} else { } else {
oldItem.lastSessionDuration = oldItem.lastSessionDuration + item.timeToAdd oldItem.lastSessionDuration = oldItem.lastSessionDuration + item.timeToAdd
} }
if (hasTrustedTimestamp) {
oldItem.lastUsage = action.trustedTimestamp.toString(10)
}
oldItem.roundedLastUpdate = roundedTimestampForSessionDuration oldItem.roundedLastUpdate = roundedTimestampForSessionDuration
await oldItem.save({ transaction: cache.transaction }) await oldItem.save({ transaction: cache.transaction })