Don't always add reminders to new incoming tasks

* Don't add reminders on initial sync
* Don't add reminders for tasks created by clients with alarm support
pull/2278/head
Alex Baker 2 years ago
parent 47f4ae8dde
commit a739b21f0f

@ -211,7 +211,12 @@ class iCalendar @Inject constructor(
tagDao.applyTags(task, tagDataDao, getTags(remote.categories))
}
if (isNew && remote.reminders.isEmpty()) {
if (
isNew &&
remote.reminders.isEmpty() &&
!calendar.ctag.isNullOrBlank() && // not initial sync
!remote.prodId().supportsReminders() // other client doesn't support reminder sync
) {
task.setDefaultReminders(preferences)
alarmService.synchronizeAlarms(task.id, task.getDefaultAlarms().toMutableSet())
} else if (account.reminderSync) {
@ -296,6 +301,16 @@ class iCalendar @Inject constructor(
else -> task.createHideUntil(HIDE_UNTIL_SPECIFIC_DAY, getLocal(this))
}
// this isn't necessarily the task originator but its the best we can do
fun ProdId.supportsReminders(): Boolean =
CLIENTS_WITH_REMINDER_SYNC.any { value.contains(it) }
private val CLIENTS_WITH_REMINDER_SYNC = listOf(
"tasks.org",
"Mozilla.org",
"Apple Inc.",
)
internal fun getLocal(property: DateProperty): Long =
org.tasks.time.DateTime.from(property.date)?.toLocal()?.millis ?: 0

Loading…
Cancel
Save