Loading cardinal-android/app/src/main/java/earth/maps/cardinal/data/sync/FavoritesLocalDataSource.kt +9 −3 Original line number Diff line number Diff line Loading @@ -133,9 +133,9 @@ class FavoritesLocalDataSource internal constructor( } private fun shouldApplyRemoteListItem(remoteItem: ListItem, localItems: List<ListItem>): Boolean { val newestLocalItem = localItems.maxByOrNull { it.placementUpdatedAt } return newestLocalItem == null || remoteItem.placementUpdatedAt > newestLocalItem.placementUpdatedAt val strongestLocalPlacement = localItems.maxWithOrNull(LIST_ITEM_PLACEMENT_COMPARATOR) return strongestLocalPlacement == null || LIST_ITEM_PLACEMENT_COMPARATOR.compare(remoteItem, strongestLocalPlacement) > 0 } private suspend fun ensureRootList(payload: FavoritesSyncPayloadDto): SavedList { Loading Loading @@ -208,3 +208,9 @@ private data class ListItemIdentity( private fun ListItem.identity(): ListItemIdentity { return ListItemIdentity(itemId = itemId, itemType = itemType) } private val LIST_ITEM_PLACEMENT_COMPARATOR = compareBy<ListItem> { it.placementUpdatedAt } .thenBy { it.listId } .thenBy { it.position } .thenBy { it.itemType.name } .thenBy { it.itemId } Loading
cardinal-android/app/src/main/java/earth/maps/cardinal/data/sync/FavoritesLocalDataSource.kt +9 −3 Original line number Diff line number Diff line Loading @@ -133,9 +133,9 @@ class FavoritesLocalDataSource internal constructor( } private fun shouldApplyRemoteListItem(remoteItem: ListItem, localItems: List<ListItem>): Boolean { val newestLocalItem = localItems.maxByOrNull { it.placementUpdatedAt } return newestLocalItem == null || remoteItem.placementUpdatedAt > newestLocalItem.placementUpdatedAt val strongestLocalPlacement = localItems.maxWithOrNull(LIST_ITEM_PLACEMENT_COMPARATOR) return strongestLocalPlacement == null || LIST_ITEM_PLACEMENT_COMPARATOR.compare(remoteItem, strongestLocalPlacement) > 0 } private suspend fun ensureRootList(payload: FavoritesSyncPayloadDto): SavedList { Loading Loading @@ -208,3 +208,9 @@ private data class ListItemIdentity( private fun ListItem.identity(): ListItemIdentity { return ListItemIdentity(itemId = itemId, itemType = itemType) } private val LIST_ITEM_PLACEMENT_COMPARATOR = compareBy<ListItem> { it.placementUpdatedAt } .thenBy { it.listId } .thenBy { it.position } .thenBy { it.itemType.name } .thenBy { it.itemId }