Skip to content

Commit cf9bdfb

Browse files
committed
Impl offline mode enhancements
1 parent aa0e878 commit cf9bdfb

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

shared/src/androidInstrumentedTest/kotlin/ui/MjImagesScreenTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class MjImagesScreenTest {
6363
}
6464

6565
composeTestRule
66-
.onNodeWithText("offline", substring = true)
66+
.onNodeWithText("offline", substring = true, ignoreCase = true)
6767
.assertIsDisplayed()
6868
}
6969

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<resources>
22
<string name="snack_message">1) Click image to open in browser\n2) Long click to preview image</string>
3-
<string name="failed_fetch_message">Failed to fetch images, using offline mode</string>
3+
<string name="failed_fetch_message">Offline mode is being utilised as latest photos cannot be collected..</string>
44
</resources>

shared/src/commonMain/kotlin/domain/model/MjImage.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package domain.model
22

3-
data class MjImage(
3+
import kotlin.uuid.ExperimentalUuidApi
4+
import kotlin.uuid.Uuid
5+
6+
data class MjImage @OptIn(ExperimentalUuidApi::class) constructor(
7+
val id: String = Uuid.random().toString(),
48
val date: String,
59
val imageUrl: String,
610
val hqImageUrl: String,

shared/src/commonMain/kotlin/domain/model/MjImages.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ data class MjImages(
1111

1212
fun isEmpty() = images.isEmpty()
1313

14-
operator fun plus(images: MjImages): MjImages =
14+
operator fun plus(other: MjImages): MjImages =
1515
MjImages(
16-
currentPage = images.currentPage,
17-
images = (this.images + images.images).distinct(),
18-
totalPages = images.totalPages
16+
currentPage = other.currentPage,
17+
images = (this.images + other.images).distinctBy(MjImage::imageUrl),
18+
totalPages = other.totalPages
1919
)
2020
}

shared/src/commonMain/kotlin/ui/MjImagesApp.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ fun MjImagesList(
219219
) {
220220
items(
221221
items = images.images,
222-
key = MjImage::imageUrl
222+
key = MjImage::id,
223223
) { image ->
224224
MjImageItem(
225225
image = image,

0 commit comments

Comments
 (0)