Implement sub habit reordering within group

pull/2020/head
Dharanish 1 year ago
parent be81a06e62
commit 8df1fb765c

@ -259,10 +259,11 @@ class HabitCardListCache @Inject constructor(
@Synchronized
fun reorder(from: Int, to: Int) {
if (from == to) return
if (data.positionTypes[from] == STANDALONE_HABIT) {
val type = data.positionTypes[from]
if (type == STANDALONE_HABIT || type == SUB_HABIT) {
val habit = data.positionToHabit[from]!!
data.performMove(habit, from, to)
} else if (data.positionTypes[from] == HABIT_GROUP) {
} else {
val habitGroup = data.positionToHabitGroup[from]!!
data.performMove(habitGroup, from, to)
}

@ -112,7 +112,10 @@ open class ListHabitsBehavior @Inject constructor(
}
fun onReorderHabit(from: Habit, to: Habit) {
taskRunner.execute { habitList.reorder(from, to) }
if (from.parent == to.parent) {
val list = from.parent?.habitList ?: habitList
taskRunner.execute { list.reorder(from, to) }
}
}
fun onRepairDB() {

Loading…
Cancel
Save