mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-09 19:42:36 +02:00
Reducing double launch or co-routines
This commit is contained in:
@@ -194,14 +194,12 @@ abstract class NostrDataSource(val debugName: String) {
|
|||||||
private val bundler = BundledUpdate(300, Dispatchers.IO)
|
private val bundler = BundledUpdate(300, Dispatchers.IO)
|
||||||
|
|
||||||
fun invalidateFilters() {
|
fun invalidateFilters() {
|
||||||
scope.launch(Dispatchers.IO) {
|
bundler.invalidate {
|
||||||
bundler.invalidate {
|
// println("DataSource: ${this.javaClass.simpleName} InvalidateFilters")
|
||||||
// println("DataSource: ${this.javaClass.simpleName} InvalidateFilters")
|
|
||||||
|
|
||||||
// adds the time to perform the refresh into this delay
|
// adds the time to perform the refresh into this delay
|
||||||
// holding off new updates in case of heavy refresh routines.
|
// holding off new updates in case of heavy refresh routines.
|
||||||
resetFiltersSuspend()
|
resetFiltersSuspend()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -436,13 +436,11 @@ abstract class FeedViewModel(val localFilter: FeedFilter<Note>) :
|
|||||||
|
|
||||||
fun checkKeysInvalidateDataAndSendToTop() {
|
fun checkKeysInvalidateDataAndSendToTop() {
|
||||||
if (lastFeedKey != localFilter.feedKey()) {
|
if (lastFeedKey != localFilter.feedKey()) {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
bundler.invalidate(false) {
|
||||||
bundler.invalidate(false) {
|
// adds the time to perform the refresh into this delay
|
||||||
// adds the time to perform the refresh into this delay
|
// holding off new updates in case of heavy refresh routines.
|
||||||
// holding off new updates in case of heavy refresh routines.
|
refreshSuspended()
|
||||||
refreshSuspended()
|
sendToTop()
|
||||||
sendToTop()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -95,12 +95,10 @@ open class StringFeedViewModel(val dataSource: FeedFilter<String>) :
|
|||||||
private val bundler = BundledUpdate(250, Dispatchers.IO)
|
private val bundler = BundledUpdate(250, Dispatchers.IO)
|
||||||
|
|
||||||
override fun invalidateData(ignoreIfDoing: Boolean) {
|
override fun invalidateData(ignoreIfDoing: Boolean) {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
bundler.invalidate(ignoreIfDoing) {
|
||||||
bundler.invalidate(ignoreIfDoing) {
|
// adds the time to perform the refresh into this delay
|
||||||
// adds the time to perform the refresh into this delay
|
// holding off new updates in case of heavy refresh routines.
|
||||||
// holding off new updates in case of heavy refresh routines.
|
refreshSuspended()
|
||||||
refreshSuspended()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -126,12 +126,10 @@ open class UserFeedViewModel(val dataSource: FeedFilter<User>) :
|
|||||||
private val bundler = BundledUpdate(250, Dispatchers.IO)
|
private val bundler = BundledUpdate(250, Dispatchers.IO)
|
||||||
|
|
||||||
override fun invalidateData(ignoreIfDoing: Boolean) {
|
override fun invalidateData(ignoreIfDoing: Boolean) {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
bundler.invalidate(ignoreIfDoing) {
|
||||||
bundler.invalidate(ignoreIfDoing) {
|
// adds the time to perform the refresh into this delay
|
||||||
// adds the time to perform the refresh into this delay
|
// holding off new updates in case of heavy refresh routines.
|
||||||
// holding off new updates in case of heavy refresh routines.
|
refreshSuspended()
|
||||||
refreshSuspended()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user