Set modification and snooze in task dao update

pull/1055/head
Alex Baker 4 years ago
parent 489b0298c6
commit 234af09ad5

@ -73,13 +73,7 @@ class TaskDao @Inject constructor(
suspend fun save(task: Task) = save(task, fetch(task.id))
suspend fun save(task: Task, original: Task?) {
if (!task.insignificantChange(original)) {
task.modificationDate = DateUtilities.now()
}
if (task.dueDate != original?.dueDate) {
task.reminderSnooze = 0
}
if (taskDao.update(task) == 1) {
if (taskDao.update(task, original)) {
workManager.afterSave(task, original)
}
}

@ -187,8 +187,18 @@ SELECT EXISTS(SELECT 1 FROM tasks WHERE parent > 0 AND deleted = 0) AS hasSubtas
@Insert
abstract suspend fun insert(task: Task): Long
suspend fun update(task: Task, original: Task? = null): Boolean {
if (!task.insignificantChange(original)) {
task.modificationDate = DateUtilities.now()
}
if (task.dueDate != original?.dueDate) {
task.reminderSnooze = 0
}
return updateInternal(task) == 1
}
@Update
abstract suspend fun update(task: Task): Int
internal abstract suspend fun updateInternal(task: Task): Int
suspend fun createNew(task: Task) {
task.id = NO_ID

Loading…
Cancel
Save