mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-15 13:38:52 -06:00
Implement edits sub habits
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user