Add support for temporarily blocking with end time

This commit is contained in:
Jonas Lochmann
2020-01-27 01:00:00 +01:00
parent b55c375506
commit 719af663f5
8 changed files with 92 additions and 13 deletions
@@ -45,6 +45,7 @@ export async function dispatchCreateCategory ({ action, cache }: {
title: action.title,
blockedMinutesInWeek: '',
temporarilyBlocked: false,
temporarilyBlockedEndTime: 0,
extraTimeInMillis: 0,
timeLimitRulesVersion: generateVersionId(),
baseVersion: generateVersionId(),
@@ -1,6 +1,6 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 Jonas Lochmann
* Copyright (C) 2019 - 2020 Jonas Lochmann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -29,7 +29,8 @@ export async function dispatchUpdateCategoryTemporarilyBlocked ({ action, cache
}
const [affectedRows] = await cache.database.category.update({
temporarilyBlocked: action.blocked
temporarilyBlocked: action.blocked,
temporarilyBlockedEndTime: action.blocked ? (action.endTime ?? 0) : 0
}, {
where: {
familyId: cache.familyId,
+6 -3
View File
@@ -341,7 +341,8 @@ export const generateServerDataStatus = async ({ database, clientStatus, familyI
'blockAllNotifications',
'timeWarningFlags',
'minBatteryCharging',
'minBatteryMobile'
'minBatteryMobile',
'temporarilyBlockedEndTime'
],
transaction
})).map((item) => ({
@@ -356,7 +357,8 @@ export const generateServerDataStatus = async ({ database, clientStatus, familyI
blockAllNotifications: item.blockAllNotifications,
timeWarningFlags: item.timeWarningFlags,
minBatteryCharging: item.minBatteryCharging,
minBatteryMobile: item.minBatteryMobile
minBatteryMobile: item.minBatteryMobile,
temporarilyBlockedEndTime: item.temporarilyBlockedEndTime
}))
result.categoryBase = dataForSyncing.map((item): ServerUpdatedCategoryBaseData => ({
@@ -371,7 +373,8 @@ export const generateServerDataStatus = async ({ database, clientStatus, familyI
blockAllNotifications: item.blockAllNotifications,
timeWarnings: item.timeWarningFlags,
mblMobile: item.minBatteryMobile,
mblCharging: item.minBatteryCharging
mblCharging: item.minBatteryCharging,
tempBlockTime: item.temporarilyBlockedEndTime
}))
}