Implement edits sub habits

This commit is contained in:
Dharanish
2024-07-05 16:02:36 +02:00
parent 6ff9c2da61
commit b043c90770
4 changed files with 25 additions and 19 deletions

View File

@@ -24,11 +24,11 @@ import org.isoron.uhabits.core.models.HabitNotFoundException
data class EditHabitCommand(
val habitList: HabitList,
val habitId: Long,
val habitUUID: String,
val modified: Habit
) : Command {
override fun run() {
val habit = habitList.getById(habitId) ?: throw HabitNotFoundException()
val habit = habitList.getByUUID(habitUUID) ?: throw HabitNotFoundException()
habit.copyFrom(modified)
habitList.update(habit)
habit.observable.notifyListeners()

View File

@@ -89,7 +89,7 @@ class LoopDBImporter
val modified = modelFactory.buildHabit()
habitRecord.id = habit.id
habitRecord.copyTo(modified)
EditHabitCommand(habitList, habit.id!!, modified).run()
EditHabitCommand(habitList, habit.uuid!!, modified).run()
}
// Reload saved version of the habit