Skip to content

Commit 0eba377

Browse files
committed
Fix imageNames sorting to preserve descending timestamp order
- Add explicit sortedByDescending in ViewModel to ensure images are returned sorted by upload timestamp (newest first) - Ensures sort order is preserved through Flow transformations - Fixes #5013
1 parent aa60642 commit 0eba377

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

app/src/main/java/openfoodfacts/github/scrachx/openfood/features/product/view/photos/ProductPhotosViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ProductPhotosViewModel @Inject constructor(
3636
.filterNotNull()
3737
.map { product ->
3838
ImageNameParser.extractImageNames(productsAPI.getProductImages(product.code))
39+
.sortedByDescending { it.timestamp } // Ensure explicit sorting
3940
.map { it.value }
4041
}.stateIn(
4142
viewModelScope,

0 commit comments

Comments
 (0)