mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-14 04:58:52 -06:00
Implement sub habit reordering within group
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user