Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 048f81c4 authored by mitulsheth's avatar mitulsheth
Browse files

feat: Murena Workspace Login Part 1 of 9

parent 681c1cc7
Loading
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -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 {
@@ -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 }