Add support for custom time warnings

This commit is contained in:
Jonas Lochmann
2022-03-28 02:00:00 +02:00
parent d7799f2d06
commit 2ab23ea811
19 changed files with 330 additions and 9 deletions
@@ -1,6 +1,6 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2020 Jonas Lochmann
* Copyright (C) 2019 - 2022 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
@@ -43,6 +43,28 @@ export async function dispatchUpdateCategoryTimeWarnings ({ action, cache }: {
await categoryEntry.save({ transaction: cache.transaction })
if (action.minutes !== undefined) {
if (action.enable) {
await cache.database.categoryTimeWarning.create({
familyId: cache.familyId,
categoryId: action.categoryId,
minutes: action.minutes
}, {
transaction: cache.transaction,
ignoreDuplicates: true
})
} else {
await cache.database.categoryTimeWarning.destroy({
where: {
familyId: cache.familyId,
categoryId: action.categoryId,
minutes: action.minutes
},
transaction: cache.transaction
})
}
}
cache.categoriesWithModifiedBaseData.add(action.categoryId)
cache.areChangesImportant = true
}