mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-15 13:38:52 -06:00
Fix habit group creation
This commit is contained in:
@@ -56,6 +56,8 @@ data class Habit(
|
||||
val uriString: String
|
||||
get() = "content://org.isoron.uhabits/habit/$id"
|
||||
|
||||
fun isSubHabit(): Boolean = parentUUID != null
|
||||
|
||||
fun hasReminder(): Boolean = reminder != null
|
||||
|
||||
fun isCompletedToday(): Boolean {
|
||||
|
||||
@@ -472,6 +472,10 @@ class HabitCardListCache @Inject constructor(
|
||||
fromPosition: Int,
|
||||
toPosition: Int
|
||||
) {
|
||||
if (fromPosition < data.habits.size || fromPosition > data.habits.size + data.habitGroups.size) {
|
||||
logger.error("performMove: $fromPosition for habit group is out of bounds")
|
||||
return
|
||||
}
|
||||
data.habitGroups.removeAt(fromPosition)
|
||||
|
||||
// Workaround for https://github.com/iSoron/uhabits/issues/968
|
||||
@@ -536,7 +540,7 @@ class HabitCardListCache @Inject constructor(
|
||||
val habitGroup = newData.habitGroups[currentPosition - data.habits.size]
|
||||
val uuid = habitGroup.uuid
|
||||
val prevPosition = data.habitGroups.indexOf(habitGroup) + data.habits.size
|
||||
if (prevPosition < 0) {
|
||||
if (prevPosition < data.habits.size) {
|
||||
performInsert(habitGroup, currentPosition)
|
||||
} else {
|
||||
if (prevPosition != currentPosition) {
|
||||
|
||||
Reference in New Issue
Block a user