Extra safety

This commit is contained in:
Blatzar 2023-06-15 00:21:12 +02:00
parent 9f029de5af
commit c7fc797788

View file

@ -165,10 +165,15 @@ class PlayerGeneratorViewModel : ViewModel() {
generator?.generateLinks(clearCache = clearCache, isCasting = isCasting, { generator?.generateLinks(clearCache = clearCache, isCasting = isCasting, {
currentLinks.add(it) currentLinks.add(it)
// Clone to prevent ConcurrentModificationException // Clone to prevent ConcurrentModificationException
_currentLinks.postValue(currentLinks.toSet()) normalSafeApiCall {
// Extra normalSafeApiCall since .toSet() iterates.
_currentLinks.postValue(currentLinks.toSet())
}
}, { }, {
currentSubs.add(it) currentSubs.add(it)
_currentSubs.postValue(currentSubs.toSet()) normalSafeApiCall {
_currentSubs.postValue(currentSubs.toSet())
}
}) })
} }