|
|
|
@ -42,7 +42,8 @@ class Upgrader @Inject constructor(
|
|
|
|
private val iCal: iCalendar,
|
|
|
|
private val iCal: iCalendar,
|
|
|
|
private val widgetManager: AppWidgetManager,
|
|
|
|
private val widgetManager: AppWidgetManager,
|
|
|
|
private val taskMover: TaskMover,
|
|
|
|
private val taskMover: TaskMover,
|
|
|
|
private val upgraderDao: UpgraderDao) {
|
|
|
|
private val upgraderDao: UpgraderDao,
|
|
|
|
|
|
|
|
private val openTaskDao: OpenTaskDao) {
|
|
|
|
|
|
|
|
|
|
|
|
fun upgrade(from: Int, to: Int) {
|
|
|
|
fun upgrade(from: Int, to: Int) {
|
|
|
|
if (from > 0) {
|
|
|
|
if (from > 0) {
|
|
|
|
@ -73,6 +74,7 @@ class Upgrader @Inject constructor(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
run(from, V11_3) {
|
|
|
|
run(from, V11_3) {
|
|
|
|
applyiCalendarStartDates()
|
|
|
|
applyiCalendarStartDates()
|
|
|
|
|
|
|
|
applyOpenTaskStartDates()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
preferences.setBoolean(R.string.p_just_updated, true)
|
|
|
|
preferences.setBoolean(R.string.p_just_updated, true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -133,6 +135,27 @@ class Upgrader @Inject constructor(
|
|
|
|
.let { taskDao.touch(it) }
|
|
|
|
.let { taskDao.touch(it) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private suspend fun applyOpenTaskStartDates() {
|
|
|
|
|
|
|
|
openTaskDao.getLists().forEach { list ->
|
|
|
|
|
|
|
|
val (hasStartDate, noStartDate) =
|
|
|
|
|
|
|
|
upgraderDao
|
|
|
|
|
|
|
|
.getOpenTasksForList(list.account!!, list.url!!)
|
|
|
|
|
|
|
|
.partition { it.startDate > 0 }
|
|
|
|
|
|
|
|
for (task in noStartDate) {
|
|
|
|
|
|
|
|
openTaskDao
|
|
|
|
|
|
|
|
.getTask(list.id, task.remoteId!!)
|
|
|
|
|
|
|
|
?.dtStart
|
|
|
|
|
|
|
|
?.let {
|
|
|
|
|
|
|
|
it.apply(task.task)
|
|
|
|
|
|
|
|
upgraderDao.setStartDate(task.id, task.startDate)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
hasStartDate
|
|
|
|
|
|
|
|
.map { it.id }
|
|
|
|
|
|
|
|
.let { taskDao.touch(it) }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private suspend fun applyCaldavOrder() {
|
|
|
|
private suspend fun applyCaldavOrder() {
|
|
|
|
for (task in upgraderDao.tasksWithVtodos().map(CaldavTaskContainer::caldavTask)) {
|
|
|
|
for (task in upgraderDao.tasksWithVtodos().map(CaldavTaskContainer::caldavTask)) {
|
|
|
|
val remoteTask = fromVtodo(task.vtodo!!) ?: continue
|
|
|
|
val remoteTask = fromVtodo(task.vtodo!!) ?: continue
|
|
|
|
|