diff --git a/common/list/src/commonMain/kotlin/com/shabinder/common/list/store/SpotiFlyerListStoreProvider.kt b/common/list/src/commonMain/kotlin/com/shabinder/common/list/store/SpotiFlyerListStoreProvider.kt index a6162851..a8667fc3 100644 --- a/common/list/src/commonMain/kotlin/com/shabinder/common/list/store/SpotiFlyerListStoreProvider.kt +++ b/common/list/src/commonMain/kotlin/com/shabinder/common/list/store/SpotiFlyerListStoreProvider.kt @@ -174,12 +174,10 @@ internal class SpotiFlyerListStoreProvider(dependencies: SpotiFlyerList.Dependen } } - private fun List.updateTracksStatuses(map: HashMap): List { - val titleList = this.map { it.title } - val updatedList = mutableListOf().also { it.addAll(this) } - - for (newTrack in map) { - titleList.indexOf(newTrack.key).let { position -> + private fun List.updateTracksStatuses(map: Map): List { + val updatedList = ArrayList(this) + LinkedHashMap(map).forEach { newTrack -> + indexOfFirst { it.title == newTrack.key }.let { position -> if (position != -1) { updatedList.getOrNull(position)?.copy( downloaded = newTrack.value,