mirror of
https://github.com/whyorean/AuroraStore.git
synced 2026-05-19 13:55:46 -04:00
Fix infinite cluster load animation
This commit is contained in:
@@ -60,9 +60,17 @@ class StreamBrowseViewModel @Inject constructor(
|
||||
liveData.postValue(streamCluster)
|
||||
} else {
|
||||
Log.i(TAG, "End of Cluster")
|
||||
postClusterEnd()
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun postClusterEnd() {
|
||||
streamCluster = streamCluster.copy(
|
||||
clusterNextPageUrl = ""
|
||||
)
|
||||
liveData.postValue(streamCluster)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,11 @@ class StreamViewModel @Inject constructor(
|
||||
|
||||
liveData.postValue(ViewState.Success(stash.toMap()))
|
||||
} else {
|
||||
Log.i(TAG, "End of cluster ${streamCluster.id}")
|
||||
stashMutex.withLock {
|
||||
postClusterEnd(category, streamCluster.id)
|
||||
}
|
||||
|
||||
liveData.postValue(ViewState.Success(stash.toMap()))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
liveData.postValue(ViewState.Error(e.message))
|
||||
@@ -142,6 +146,18 @@ class StreamViewModel @Inject constructor(
|
||||
stash[category] = bundle.copy(streamClusters = updatedClusters)
|
||||
}
|
||||
|
||||
private fun postClusterEnd(category: StreamContract.Category, clusterID: Int) {
|
||||
val bundle = stash[category] ?: return
|
||||
val oldCluster = bundle.streamClusters[clusterID] ?: return
|
||||
|
||||
val updatedCluster = oldCluster.copy(clusterNextPageUrl = "")
|
||||
val updatedClusters = bundle.streamClusters.toMutableMap().apply {
|
||||
this[clusterID] = updatedCluster
|
||||
}
|
||||
|
||||
stash[category] = bundle.copy(streamClusters = updatedClusters)
|
||||
}
|
||||
|
||||
private fun targetBundle(category: StreamContract.Category): StreamBundle {
|
||||
return stash.getOrPut(category) { StreamBundle() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user