Merge pull request #1857 from kouki4416/fix-daily-streak-bug

Fix deselecting daily item does not decrement count(issue #1845)
This commit is contained in:
Hafizzle 2022-10-17 12:17:07 -04:00 committed by GitHub
commit 2cef29f475
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -145,8 +145,12 @@ class TaskRepositoryImpl(
bgTask.value = (bgTask.value - localDelta) + res.delta
if (TaskType.DAILY == bgTask.type || TaskType.TODO == bgTask.type) {
bgTask.completed = up
if (TaskType.DAILY == bgTask.type && up) {
bgTask.streak = (bgTask.streak ?: 0) + 1
if (TaskType.DAILY == bgTask.type) {
if (up) {
bgTask.streak = (bgTask.streak ?: 0) + 1
} else {
bgTask.streak = (bgTask.streak ?: 0) - 1
}
}
} else if (TaskType.HABIT == bgTask.type) {
if (up) {