fun List<SyncedDeviceTabs>.toComposeList( taskContinuityEnabled: Boolean, ): List<SyncedTabsListItem> = asSequence().flatMap { (device, tabs) -> if (taskContinuityEnabled) { val deviceTabs = if (tabs.isEmpty()) { emptyList() } else { tabs.map { val url = it.active().url val titleText = it.active().title.ifEmpty { url.trimmed() } SyncedTabsListItem.Tab(titleText, url, it) } } sequenceOf(SyncedTabsListItem.DeviceSection(device.displayName, deviceTabs)) } else { val deviceTabs = if (tabs.isEmpty()) { sequenceOf(SyncedTabsListItem.NoTabs) } else { tabs.asSequence().map { val url = it.active().url val titleText = it.active().title.ifEmpty { url.trimmed() } SyncedTabsListItem.Tab(titleText, url, it) } } sequenceOf(SyncedTabsListItem.Device(device.displayName)) + deviceTabs } }.toList()
Converts a list of [SyncedDeviceTabs] into a list of [SyncedTabsListItem].