From 2131fb3a3ddff7ff9a4239259880c117c1bde657 Mon Sep 17 00:00:00 2001 From: "Alinson S. Xavier" Date: Tue, 24 Jan 2023 05:58:26 -0600 Subject: [PATCH] EntryList: Copy notes from original entries Fixes #1566 --- .../java/org/isoron/uhabits/core/models/EntryList.kt | 11 +++++++++-- .../org/isoron/uhabits/core/models/EntryListTest.kt | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/uhabits-core/src/jvmMain/java/org/isoron/uhabits/core/models/EntryList.kt b/uhabits-core/src/jvmMain/java/org/isoron/uhabits/core/models/EntryList.kt index 2d9662b21..774181e7d 100644 --- a/uhabits-core/src/jvmMain/java/org/isoron/uhabits/core/models/EntryList.kt +++ b/uhabits-core/src/jvmMain/java/org/isoron/uhabits/core/models/EntryList.kt @@ -204,9 +204,16 @@ open class EntryList { // Copy original entries original.forEach { entry -> val offset = entry.timestamp.daysUntil(to) - if (result[offset].value == UNKNOWN || entry.value == SKIP || entry.value == YES_MANUAL) { - result[offset] = entry + val value = if ( + result[offset].value == UNKNOWN || + entry.value == SKIP || + entry.value == YES_MANUAL + ) { + entry.value + } else { + YES_AUTO } + result[offset] = Entry(entry.timestamp, value, entry.notes) } return result diff --git a/uhabits-core/src/jvmTest/java/org/isoron/uhabits/core/models/EntryListTest.kt b/uhabits-core/src/jvmTest/java/org/isoron/uhabits/core/models/EntryListTest.kt index 9c7de4bb3..c1f1bde2d 100644 --- a/uhabits-core/src/jvmTest/java/org/isoron/uhabits/core/models/EntryListTest.kt +++ b/uhabits-core/src/jvmTest/java/org/isoron/uhabits/core/models/EntryListTest.kt @@ -217,7 +217,7 @@ class EntryListTest { fun testAddFromInterval() { val entries = listOf( Entry(day(1), YES_MANUAL), - Entry(day(2), NO), + Entry(day(2), NO, "Test"), Entry(day(4), NO), Entry(day(5), YES_MANUAL), Entry(day(10), YES_MANUAL), @@ -230,7 +230,7 @@ class EntryListTest { ) val expected = listOf( Entry(day(1), YES_MANUAL), - Entry(day(2), YES_AUTO), + Entry(day(2), YES_AUTO, "Test"), Entry(day(3), UNKNOWN), Entry(day(4), YES_AUTO), Entry(day(5), YES_MANUAL),