Fix crash when collapsing/expanding all

pull/996/head
Alex Baker 5 years ago
parent e482a881f9
commit 6987fe8bd7

@ -386,12 +386,12 @@ class TaskListFragment : InjectingFragment(), OnRefreshListener, Toolbar.OnMenuI
true
}
R.id.menu_expand_subtasks -> {
taskDao.setCollapsed(taskListViewModel.value, false)
taskDao.setCollapsed(preferences, filter, false)
localBroadcastManager.broadcastRefresh()
true
}
R.id.menu_collapse_subtasks -> {
taskDao.setCollapsed(taskListViewModel.value, true)
taskDao.setCollapsed(preferences, filter, true)
localBroadcastManager.broadcastRefresh()
true
}

@ -210,8 +210,11 @@ abstract class TaskDao(private val database: Database) {
abstract fun setCollapsed(id: Long, collapsed: Boolean)
@Transaction
open fun setCollapsed(tasks: List<TaskContainer>, collapsed: Boolean) {
DbUtils.batch(tasks.filter(TaskContainer::hasChildren).map(TaskContainer::getId)) {
open fun setCollapsed(preferences: Preferences, filter: Filter, collapsed: Boolean) {
val tasks = fetchTasks(preferences, filter)
.filter(TaskContainer::hasChildren)
.map(TaskContainer::getId)
DbUtils.batch(tasks) {
collapse(it, collapsed)
}
}

Loading…
Cancel
Save