mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Add support for custom time warnings
This commit is contained in:
+23
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user