From df54f7bb6714713e9248c203baa6f8d08f1cf872 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 21 Oct 2025 18:30:08 -0400 Subject: [PATCH] Moves all Dispatchers.Default to IO because of the amount of Synchronized code that blocks the thread underneath each coroutine and since Default only has the exact number of threads the processor offers, once they block, we lose computing power --- .../com/vitorpamplona/amethyst/AppModules.kt | 2 +- .../vitorpamplona/amethyst/model/Account.kt | 2 +- .../amethyst/model/LocalCache.kt | 6 ++-- .../model/accountsCache/AccountCacheState.kt | 2 +- .../edits/PrivateStorageRelayListState.kt | 4 +-- .../model/emphChat/EphemeralChatListState.kt | 4 +-- .../model/localRelays/LocalRelayListState.kt | 2 +- .../AccountHomeRelayState.kt | 2 +- .../AccountOutboxRelayState.kt | 2 +- .../NotificationInboxRelayState.kt | 2 +- .../nip01UserMetadata/UserMetadataState.kt | 2 +- .../DeclaredFollowsPerOutboxRelay.kt | 2 +- .../FollowListOutboxOrProxyRelays.kt | 8 ++--- .../FollowListReusedOutboxOrProxyRelays.kt | 8 ++--- .../model/nip02FollowLists/FollowListState.kt | 6 ++-- .../nip02FollowLists/FollowsPerOutboxRelay.kt | 6 ++-- .../IncomingOtsEventVerifier.kt | 2 +- .../model/nip17Dms/DmInboxRelayState.kt | 2 +- .../model/nip17Dms/DmRelayListState.kt | 4 +-- .../nip28PublicChats/PublicChatListState.kt | 6 ++-- .../model/nip30CustomEmojis/EmojiPackState.kt | 4 +-- .../nip47WalletConnect/NwcSignerState.kt | 6 ++-- .../model/nip51Lists/BookmarkListState.kt | 14 ++++----- .../model/nip51Lists/HiddenUsersState.kt | 2 +- .../blockPeopleList/BlockPeopleListState.kt | 2 +- .../blockedRelays/BlockedRelayListState.kt | 4 +-- .../BroadcastRelayListState.kt | 2 +- .../GeohashListDecryptionCache.kt | 2 +- .../geohashLists/GeohashListState.kt | 4 +-- .../hashtagLists/HashtagListState.kt | 4 +-- .../indexerRelays/IndexerRelayListState.kt | 6 ++-- .../nip51Lists/muteList/MuteListState.kt | 4 +-- .../proxyRelays/ProxyRelayListState.kt | 2 +- .../relayLists/GenericRelayListCache.kt | 2 +- .../searchRelays/SearchRelayListState.kt | 6 ++-- .../trustedRelays/TrustedRelayListState.kt | 4 +-- .../nip65RelayList/Nip65RelayListState.kt | 8 ++--- .../nip72Communities/CommunityListState.kt | 6 ++-- .../nip78AppSpecific/AppSpecificState.kt | 2 +- .../FileStorageServerListState.kt | 2 +- .../nipB7Blossom/BlossomServerListState.kt | 2 +- .../preferences/UpdatablePropertyFlow.kt | 2 +- .../serverList/MergedFollowListsState.kt | 2 +- .../MergedFollowPlusMineRelayListsState.kt | 2 +- ...dFollowPlusMineWithIndexRelayListsState.kt | 2 +- ...FollowPlusMineWithSearchRelayListsState.kt | 2 +- .../model/serverList/MergedServerListState.kt | 2 +- .../serverList/TrustedRelayListsState.kt | 2 +- .../topNavFeeds/FeedTopNavFilterState.kt | 2 +- .../MergedTopFeedAuthorListsState.kt | 2 +- .../model/topNavFeeds/OutboxLoaderState.kt | 2 +- .../amethyst/model/torState/TorRelayState.kt | 4 +-- .../service/notifications/PokeyReceiver.kt | 2 +- .../service/okhttp/OkHttpWebSocket.kt | 2 +- .../composable/controls/MuteButton.kt | 2 +- .../eoseManagers/BaseEoseManager.kt | 2 +- .../drafts/AccountDraftsEoseManager.kt | 2 +- .../AccountFollowsLoaderSubAssembler.kt | 4 +-- .../metadata/AccountMetadataEoseManager.kt | 2 +- ...NotificationsEoseFromInboxRelaysManager.kt | 4 +-- ...otificationsEoseFromRandomRelaysManager.kt | 4 +-- .../AccountGiftWrapsEoseManager.kt | 2 +- .../reqCommand/channel/ChannelObservers.kt | 2 +- .../reqCommand/event/EventObservers.kt | 10 +++---- .../reqCommand/user/UserObservers.kt | 26 ++++++++-------- .../vitorpamplona/amethyst/ui/MainActivity.kt | 2 +- .../amethyst/ui/components/CashuRedeem.kt | 2 +- .../amethyst/ui/components/RichTextViewer.kt | 2 +- .../ui/components/ZoomableContentDialog.kt | 2 +- .../ui/feeds/ChannelFeedContentState.kt | 6 ++-- .../amethyst/ui/feeds/FeedContentState.kt | 2 +- .../vitorpamplona/amethyst/ui/note/Loaders.kt | 2 +- .../amethyst/ui/note/MultiSetCompose.kt | 2 +- .../amethyst/ui/note/PollNoteViewModel.kt | 2 +- .../emojiSuggestions/EmojiSuggestionState.kt | 2 +- .../note/creators/invoice/InvoicePreview.kt | 2 +- .../ui/note/creators/previews/PreviewState.kt | 2 +- .../userSuggestions/ShowUserSuggestionList.kt | 4 +-- .../userSuggestions/UserSuggestionState.kt | 2 +- .../nip22Comments/CommentPostViewModel.kt | 6 ++-- .../amethyst/ui/note/types/AppDefinition.kt | 2 +- .../amethyst/ui/note/types/MedicalData.kt | 2 +- .../amethyst/ui/screen/FeedViewModel.kt | 4 +-- .../amethyst/ui/screen/FollowListState.kt | 4 +-- .../amethyst/ui/screen/UserFeedViewModel.kt | 6 ++-- .../ui/screen/loggedIn/AccountViewModel.kt | 30 +++++++++---------- .../privateDM/dal/ChatroomFeedViewModel.kt | 2 +- .../privateDM/send/ChatNewMessageViewModel.kt | 6 ++-- .../send/ChannelNewMessageViewModel.kt | 6 ++-- .../DMsFromUserFilterSubAssembler.kt | 4 +-- .../FollowingEphemeralChatSubAssembler.kt | 2 +- .../FollowingPublicChatSubAssembler.kt | 2 +- ...yFollowsSetsAndLiveStreamsSubAssembler2.kt | 6 ++-- ...yLongFormClassifiedsAndDVMSubAssembler1.kt | 6 ++-- ...yPublicChatsAndCommunitiesSubAssembler3.kt | 6 ++-- .../nip99Classifieds/NewProductViewModel.kt | 6 ++-- .../loggedIn/home/ShortNotePostViewModel.kt | 6 ++-- .../HomeOutboxEventsEoseManager.kt | 8 ++--- .../notifications/CardFeedContentState.kt | 2 +- .../NewPublicMessageViewModel.kt | 6 ++-- .../loggedIn/profile/header/apps/WatchApp.kt | 2 +- .../profile/relays/RelayFeedViewModel.kt | 8 ++--- .../profile/zaps/LnZapFeedViewModel.kt | 2 +- .../loggedIn/search/SearchBarViewModel.kt | 12 ++++---- .../ui/screen/loggedIn/search/SearchScreen.kt | 4 +-- .../loggedIn/settings/StringFeedViewModel.kt | 6 ++-- .../threadview/dal/LevelFeedViewModel.kt | 2 +- .../screen/loggedIn/video/NewImageButton.kt | 2 +- .../VideoOutboxEventsFilterSubAssembler.kt | 4 +-- .../ammolite/relays/BundledUpdate.kt | 8 ++--- .../nip01Core/relay/client/NostrClient.kt | 4 +-- .../sockets/okhttp/BasicOkHttpWebSocket.kt | 2 +- 112 files changed, 231 insertions(+), 231 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index 331f2dc82..e62736ca8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -86,7 +86,7 @@ class AppModules( } val applicationIOScope = CoroutineScope(Dispatchers.IO + SupervisorJob() + exceptionHandler) - val applicationDefaultScope = CoroutineScope(Dispatchers.Default + SupervisorJob() + exceptionHandler) + val applicationDefaultScope = CoroutineScope(Dispatchers.IO + SupervisorJob() + exceptionHandler) // Blocking load of UI Preferences to avoid theme/language blinking val uiPrefs by lazy { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index dfc9fd2a3..10e8955eb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -1761,7 +1761,7 @@ class Account( fun observeDonatedInThisVersion() = settings .observeDonatedInVersion(BuildConfig.VERSION_NAME) - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, hasDonatedInThisVersion()) fun markDonatedInThisVersion() = settings.markDonatedInThisVersion(BuildConfig.VERSION_NAME) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt index 13714ae39..6a4ea2a7a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt @@ -1962,7 +1962,7 @@ object LocalCache : ILocalCache { requestNote?.let { request -> zappedNote?.addZapPayment(request, note) } - GlobalScope.launch(Dispatchers.Default) { + GlobalScope.launch(Dispatchers.IO) { responseCallback(event) } @@ -2913,10 +2913,10 @@ class LocalCacheFlow { val deletedEventBundles = _deletedEventBundles.asSharedFlow() // read-only public view // Refreshes observers in batches. - private val bundler = BundledInsert(1000, Dispatchers.Default) + private val bundler = BundledInsert(1000, Dispatchers.IO) // Refreshes observers in batches. - private val bundler2 = BundledInsert(1000, Dispatchers.Default) + private val bundler2 = BundledInsert(1000, Dispatchers.IO) fun newNote(newNote: Note) { bundler.invalidateList(newNote) { bundledNewNotes -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt index d16c67b3d..0126df2fe 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt @@ -97,7 +97,7 @@ class AccountCacheState( client = client, scope = CoroutineScope( - Dispatchers.Default + + Dispatchers.IO + SupervisorJob() + CoroutineExceptionHandler { _, throwable -> Log.e("AccountCacheState", "Account ${signer.pubKey} caught exception: ${throwable.message}", throwable) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/edits/PrivateStorageRelayListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/edits/PrivateStorageRelayListState.kt index dfad190c9..b67f31d19 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/edits/PrivateStorageRelayListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/edits/PrivateStorageRelayListState.kt @@ -66,7 +66,7 @@ class PrivateStorageRelayListState( .map { normalizePrivateOutboxRelayListWithBackup(it.note) } .onStart { emit(normalizePrivateOutboxRelayListWithBackup(privateOutboxListNote)) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -99,7 +99,7 @@ class PrivateStorageRelayListState( } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Private Home Relay List Collector Start") getPrivateOutboxRelayListFlow().collect { noteState -> Log.d("AccountRegisterObservers", "Updating Private Home Relay List for ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/emphChat/EphemeralChatListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/emphChat/EphemeralChatListState.kt index fab0e395e..3899d0aef 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/emphChat/EphemeralChatListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/emphChat/EphemeralChatListState.kt @@ -69,7 +69,7 @@ class EphemeralChatListState( emit(ephemeralChatListWithBackup(noteState.note)) }.onStart { emit(ephemeralChatListWithBackup(ephemeralChatListNote)) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -117,7 +117,7 @@ class EphemeralChatListState( } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "EphemeralChatList Collector Start") getEphemeralChatListFlow().collect { noteState -> Log.d("AccountRegisterObservers", "EphemeralChatList List for ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/localRelays/LocalRelayListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/localRelays/LocalRelayListState.kt index dcdaa2b36..20917ae6c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/localRelays/LocalRelayListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/localRelays/LocalRelayListState.kt @@ -43,7 +43,7 @@ class LocalRelayListState( val flow = settings.localRelayServers .map { normalizeLocalRelayListWithBackup(it) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/AccountHomeRelayState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/AccountHomeRelayState.kt index 670768683..89403654e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/AccountHomeRelayState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/AccountHomeRelayState.kt @@ -43,7 +43,7 @@ class AccountHomeRelayState( local.flow, ) { nip65Outbox, privateOutBox, localRelays -> nip65Outbox + privateOutBox + localRelays - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/AccountOutboxRelayState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/AccountOutboxRelayState.kt index f3ccbdacf..65f76c500 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/AccountOutboxRelayState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/AccountOutboxRelayState.kt @@ -46,7 +46,7 @@ class AccountOutboxRelayState( broadcast.flow, ) { nip65Outbox, privateOutBox, localRelays, broadcastRelays -> nip65Outbox + privateOutBox + localRelays + broadcastRelays - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/NotificationInboxRelayState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/NotificationInboxRelayState.kt index 1d05dee9b..0729475dc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/NotificationInboxRelayState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/NotificationInboxRelayState.kt @@ -40,7 +40,7 @@ class NotificationInboxRelayState( localRelayList.flow, ) { nip65Inbox, localRelays -> nip65Inbox + localRelays - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/UserMetadataState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/UserMetadataState.kt index 237ab81b2..cd4bc0a43 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/UserMetadataState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip01UserMetadata/UserMetadataState.kt @@ -113,7 +113,7 @@ class UserMetadataState( } // saves contact list for the next time. - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Kind 0 Collector Start") getUserMetadataFlow().collect { Log.d("AccountRegisterObservers", "Updating Kind 0 ${it.user.toBestDisplayName()}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/DeclaredFollowsPerOutboxRelay.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/DeclaredFollowsPerOutboxRelay.kt index b36983003..5bf15c92f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/DeclaredFollowsPerOutboxRelay.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/DeclaredFollowsPerOutboxRelay.kt @@ -55,7 +55,7 @@ class DeclaredFollowsPerOutboxRelay( calculator.authorsPerRelaySnapshot(kind3Follows.flow.value.authors, cache) { it }, ) }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListOutboxOrProxyRelays.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListOutboxOrProxyRelays.kt index 44ea6d2a9..ed08e8bb8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListOutboxOrProxyRelays.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListOutboxOrProxyRelays.kt @@ -60,7 +60,7 @@ class FollowListOutboxOrProxyRelays( OutboxRelayLoader(true).authorsPerRelaySnapshot(kind3Follows.flow.value.authors, cache) { it.keys }, ) }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -72,7 +72,7 @@ class FollowListOutboxOrProxyRelays( followList.minus(blockedRelays) }.onStart { emit(outboxRelayFlow.value.minus(blockedRelayList.flow.value.toSet())) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -94,7 +94,7 @@ class FollowListOutboxOrProxyRelays( outboxRelayMinusBlockedFlow.value }, ) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -108,7 +108,7 @@ class FollowListOutboxOrProxyRelays( relayList.mapTo(mutableSetOf()) { it.url } }.onStart { emit(flow.value.mapTo(mutableSetOf()) { it.url }) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListReusedOutboxOrProxyRelays.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListReusedOutboxOrProxyRelays.kt index 78d5beec0..f356cf779 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListReusedOutboxOrProxyRelays.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListReusedOutboxOrProxyRelays.kt @@ -78,7 +78,7 @@ class FollowListReusedOutboxOrProxyRelays( }, ) }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -90,7 +90,7 @@ class FollowListReusedOutboxOrProxyRelays( followList.minus(blockedRelays) }.onStart { emit(outboxRelayFlow.value.minus(blockedRelayList.flow.value.toSet())) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -112,7 +112,7 @@ class FollowListReusedOutboxOrProxyRelays( outboxRelayMinusBlockedFlow.value }, ) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -126,7 +126,7 @@ class FollowListReusedOutboxOrProxyRelays( relayList.mapTo(mutableSetOf()) { it.url } }.onStart { emit(flow.value.mapTo(mutableSetOf()) { it.url }) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListState.kt index 7bf5816de..8fb2d857e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListState.kt @@ -66,7 +66,7 @@ class FollowListState( val flow = innerFlow - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -81,7 +81,7 @@ class FollowListState( it.authors.mapNotNull { cache.checkGetOrCreateUser(it) } - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -166,7 +166,7 @@ class FollowListState( } // saves contact list for the next time. - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Kind 3 Collector Start") getFollowListFlow().collect { Log.d("AccountRegisterObservers", "Updating Kind 3 ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowsPerOutboxRelay.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowsPerOutboxRelay.kt index b81e95124..a98e5fe7d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowsPerOutboxRelay.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowsPerOutboxRelay.kt @@ -60,7 +60,7 @@ class FollowsPerOutboxRelay( OutboxRelayLoader().authorsPerRelaySnapshot(kind3Follows.flow.value.authors, cache) { it }, ) }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -72,7 +72,7 @@ class FollowsPerOutboxRelay( followList.minus(blockedRelays) }.onStart { emit(outboxPerRelayFlow.value.minus(blockedRelayList.flow.value.toSet())) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -96,7 +96,7 @@ class FollowsPerOutboxRelay( } else { emit(proxyRelayList.flow.value.associateWith { kind3Follows.flow.value.authors }) } - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip03Timestamp/IncomingOtsEventVerifier.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip03Timestamp/IncomingOtsEventVerifier.kt index df51825bf..84f0b77d3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip03Timestamp/IncomingOtsEventVerifier.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip03Timestamp/IncomingOtsEventVerifier.kt @@ -42,7 +42,7 @@ class IncomingOtsEventVerifier( newNotes.forEach { consume(it) } - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip17Dms/DmInboxRelayState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip17Dms/DmInboxRelayState.kt index d1e9def87..6ffe95928 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip17Dms/DmInboxRelayState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip17Dms/DmInboxRelayState.kt @@ -47,7 +47,7 @@ class DmInboxRelayState( localRelayList.flow, ) { nip65Inbox, dmRelayList, privateOutBox, localRelays -> nip65Inbox + dmRelayList + privateOutBox + localRelays - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip17Dms/DmRelayListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip17Dms/DmRelayListState.kt index f582734cf..ba18f9850 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip17Dms/DmRelayListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip17Dms/DmRelayListState.kt @@ -64,7 +64,7 @@ class DmRelayListState( getDMRelayListFlow() .map { normalizeDMRelayListWithBackup(it.note) } .onStart { emit(normalizeDMRelayListWithBackup(dmListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -96,7 +96,7 @@ class DmRelayListState( } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "NIP-17 Relay List Collector Start") getDMRelayListFlow().collect { Log.d("AccountRegisterObservers", "Updating DM Relay List for ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip28PublicChats/PublicChatListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip28PublicChats/PublicChatListState.kt index d30bc4551..f52bd4687 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip28PublicChats/PublicChatListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip28PublicChats/PublicChatListState.kt @@ -71,7 +71,7 @@ class PublicChatListState( emit(publicChatListWithBackup(noteState.note)) }.onStart { emit(publicChatListWithBackup(publicChatListNote)) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -85,7 +85,7 @@ class PublicChatListState( it.mapTo(mutableSetOf()) { it.eventId } }.onStart { emit(flow.value.mapTo(mutableSetOf()) { it.eventId }) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -132,7 +132,7 @@ class PublicChatListState( } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Channel List Collector Start") getChannelListFlow().collect { Log.d("AccountRegisterObservers", "Channel List for ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip30CustomEmojis/EmojiPackState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip30CustomEmojis/EmojiPackState.kt index 0fdb4793a..52d0f1aee 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip30CustomEmojis/EmojiPackState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip30CustomEmojis/EmojiPackState.kt @@ -75,7 +75,7 @@ class EmojiPackState( emit(convertEmojiSelectionPack(it.note.event as? EmojiPackSelectionEvent)) }.onStart { emit(convertEmojiSelectionPack(getEmojiPackSelection())) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -120,7 +120,7 @@ class EmojiPackState( )?.map { it.value }?.toTypedArray() ?: emptyArray(), ), ) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip47WalletConnect/NwcSignerState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip47WalletConnect/NwcSignerState.kt index cc59221ed..8b5990b65 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip47WalletConnect/NwcSignerState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip47WalletConnect/NwcSignerState.kt @@ -76,7 +76,7 @@ class NwcSignerState( settings.zapPaymentRequest .map { buildSigner(it) ?: signer - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -91,7 +91,7 @@ class NwcSignerState( nip47Signer .map { NostrWalletConnectRequestCache(it) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, NostrWalletConnectRequestCache(nip47Signer.value)) /** @@ -102,7 +102,7 @@ class NwcSignerState( nip47Signer .map { NostrWalletConnectResponseCache(it) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, NostrWalletConnectResponseCache(nip47Signer.value)) fun buildSigner(uri: Nip47WalletConnect.Nip47URINorm?) = diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/BookmarkListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/BookmarkListState.kt index a75852253..6606229ec 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/BookmarkListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/BookmarkListState.kt @@ -78,7 +78,7 @@ class BookmarkListState( }.onStart { emit(publicBookmarks(bookmarkList)) }.debounce(100) - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -93,7 +93,7 @@ class BookmarkListState( }.onStart { emit(privateBookmarks(bookmarkList)) }.debounce(100) - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -107,7 +107,7 @@ class BookmarkListState( .mapNotNull { if (it is EventBookmark) it.eventId else null }.toSet() - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -121,7 +121,7 @@ class BookmarkListState( .mapNotNull { if (it is AddressBookmark) it.address else null }.toSet() - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -135,7 +135,7 @@ class BookmarkListState( .mapNotNull { if (it is EventBookmark) it.eventId else null }.toSet() - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -149,7 +149,7 @@ class BookmarkListState( .mapNotNull { if (it is AddressBookmark) it.address else null }.toSet() - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -185,7 +185,7 @@ class BookmarkListState( emit(bookmarkList(private, public)) }.onStart { emit(bookmarkList(privateBookmarks.value, publicBookmarks.value)) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/HiddenUsersState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/HiddenUsersState.kt index ce359259b..b20482350 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/HiddenUsersState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/HiddenUsersState.kt @@ -93,7 +93,7 @@ class HiddenUsersState( settings.syncedSettings.security.showSensitiveContent.value, ), ) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/blockPeopleList/BlockPeopleListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/blockPeopleList/BlockPeopleListState.kt index cfc6a20cd..22ea116b2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/blockPeopleList/BlockPeopleListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/blockPeopleList/BlockPeopleListState.kt @@ -61,7 +61,7 @@ class BlockPeopleListState( getBlockListFlow() .map { blockListWithBackup(it.note) } .onStart { emit(blockListWithBackup(blockListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/blockedRelays/BlockedRelayListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/blockedRelays/BlockedRelayListState.kt index 80c87c435..3fc015f51 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/blockedRelays/BlockedRelayListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/blockedRelays/BlockedRelayListState.kt @@ -67,7 +67,7 @@ class BlockedRelayListState( .map { normalizeBlockedRelayListWithBackup(it.note) }.onStart { emit(normalizeBlockedRelayListWithBackup(blockedListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -99,7 +99,7 @@ class BlockedRelayListState( GlobalScope.launch(Dispatchers.IO) { LocalCache.justConsumeMyOwnEvent(it) } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Blocked Relay List Collector Start") getBlockedRelayListFlow().collect { Log.d("AccountRegisterObservers", "Updating Blocked Relay List for ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/broadcastRelays/BroadcastRelayListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/broadcastRelays/BroadcastRelayListState.kt index 8e6b88e8b..388e78d4c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/broadcastRelays/BroadcastRelayListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/broadcastRelays/BroadcastRelayListState.kt @@ -61,7 +61,7 @@ class BroadcastRelayListState( getBroadcastRelayListFlow() .map { normalizeBroadcastRelayListWithBackup(it.note) } .onStart { emit(normalizeBroadcastRelayListWithBackup(broadcastListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/geohashLists/GeohashListDecryptionCache.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/geohashLists/GeohashListDecryptionCache.kt index 2576cbc12..4ea18aadb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/geohashLists/GeohashListDecryptionCache.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/geohashLists/GeohashListDecryptionCache.kt @@ -72,5 +72,5 @@ class GeohashListDecryptionCache( emit(EmptyGeohashListCard) } }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/geohashLists/GeohashListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/geohashLists/GeohashListState.kt index 1e747c091..fef8ba33b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/geohashLists/GeohashListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/geohashLists/GeohashListState.kt @@ -68,7 +68,7 @@ class GeohashListState( emit(geohashListWithBackup(noteState.note)) }.onStart { emit(geohashListWithBackup(geohashListNote)) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -114,7 +114,7 @@ class GeohashListState( } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Geohash List Collector Start") getGeohashListFlow().collect { noteState -> Log.d("AccountRegisterObservers", "Geohash List for ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/hashtagLists/HashtagListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/hashtagLists/HashtagListState.kt index 16f00e03d..ae9d90f0d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/hashtagLists/HashtagListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/hashtagLists/HashtagListState.kt @@ -68,7 +68,7 @@ class HashtagListState( emit(hashtagListWithBackup(noteState.note)) }.onStart { emit(hashtagListWithBackup(hashtagListNote)) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Companion.Eagerly, @@ -114,7 +114,7 @@ class HashtagListState( } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Hashtag List Collector Start") getHashtagListFlow().collect { Log.d("AccountRegisterObservers", "Hashtag List for ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/indexerRelays/IndexerRelayListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/indexerRelays/IndexerRelayListState.kt index 5a67aecb3..738ec1c6d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/indexerRelays/IndexerRelayListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/indexerRelays/IndexerRelayListState.kt @@ -67,7 +67,7 @@ class IndexerRelayListState( getIndexerRelayListFlow() .map { normalizeIndexerRelayListWithBackup(it.note) } .onStart { emit(normalizeIndexerRelayListWithBackup(indexerListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -78,7 +78,7 @@ class IndexerRelayListState( getIndexerRelayListFlow() .map { normalizeIndexerRelayListWithBackupNoDefaults(it.note) } .onStart { emit(normalizeIndexerRelayListWithBackupNoDefaults(indexerListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -109,7 +109,7 @@ class IndexerRelayListState( GlobalScope.launch(Dispatchers.IO) { LocalCache.justConsumeMyOwnEvent(it) } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Index Relay List Collector Start") getIndexerRelayListFlow().collect { Log.d("AccountRegisterObservers", "Updating Index Relay List for ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/muteList/MuteListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/muteList/MuteListState.kt index 2b8f7e7bf..6ad8b31a6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/muteList/MuteListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/muteList/MuteListState.kt @@ -67,7 +67,7 @@ class MuteListState( getMuteListFlow() .map { muteListWithBackup(it.note) } .onStart { emit(muteListWithBackup(muteListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -149,7 +149,7 @@ class MuteListState( } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Mute List Collector Start") getMuteListFlow().collect { Log.d("AccountRegisterObservers", "Updating Mute List for ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/proxyRelays/ProxyRelayListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/proxyRelays/ProxyRelayListState.kt index 13fe7f0bf..d50c88368 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/proxyRelays/ProxyRelayListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/proxyRelays/ProxyRelayListState.kt @@ -61,7 +61,7 @@ class ProxyRelayListState( getProxyRelayListFlow() .map { normalizeProxyRelayListWithBackup(it.note) } .onStart { emit(normalizeProxyRelayListWithBackup(proxyListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/relayLists/GenericRelayListCache.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/relayLists/GenericRelayListCache.kt index c8735fbda..e62fd6a8a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/relayLists/GenericRelayListCache.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/relayLists/GenericRelayListCache.kt @@ -72,5 +72,5 @@ open class GenericRelayListCache( emit(EmptyRelayListCard) } }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/searchRelays/SearchRelayListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/searchRelays/SearchRelayListState.kt index 2f9da2401..3d5b3919f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/searchRelays/SearchRelayListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/searchRelays/SearchRelayListState.kt @@ -67,7 +67,7 @@ class SearchRelayListState( getSearchRelayListFlow() .map { normalizeSearchRelayListWithBackup(it.note) } .onStart { emit(normalizeSearchRelayListWithBackup(searchListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Companion.Eagerly, @@ -78,7 +78,7 @@ class SearchRelayListState( getSearchRelayListFlow() .map { normalizeSearchRelayListWithBackupNoDefaults(it.note) } .onStart { emit(normalizeSearchRelayListWithBackupNoDefaults(searchListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -109,7 +109,7 @@ class SearchRelayListState( GlobalScope.launch(Dispatchers.IO) { LocalCache.justConsumeMyOwnEvent(it) } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Search Relay List Collector Start") getSearchRelayListFlow().collect { Log.d("AccountRegisterObservers", "Updating Search Relay List for ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/trustedRelays/TrustedRelayListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/trustedRelays/TrustedRelayListState.kt index eabd77993..96250d6f5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/trustedRelays/TrustedRelayListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/trustedRelays/TrustedRelayListState.kt @@ -65,7 +65,7 @@ class TrustedRelayListState( getTrustedRelayListFlow() .map { normalizeTrustedRelayListWithBackup(it.note) } .onStart { emit(normalizeTrustedRelayListWithBackup(trustedListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Companion.Eagerly, @@ -96,7 +96,7 @@ class TrustedRelayListState( GlobalScope.launch(Dispatchers.IO) { cache.justConsumeMyOwnEvent(it) } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Trusted Relay List Collector Start") getTrustedRelayListFlow().collect { Log.d("AccountRegisterObservers", "Updating Trusted Relay List for ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip65RelayList/Nip65RelayListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip65RelayList/Nip65RelayListState.kt index b1d85a429..60a2fb107 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip65RelayList/Nip65RelayListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip65RelayList/Nip65RelayListState.kt @@ -71,7 +71,7 @@ class Nip65RelayListState( getNIP65RelayListFlow() .map { normalizeNIP65WriteRelayListWithBackup(it.note) } .onStart { emit(normalizeNIP65ReadRelayListWithBackup(nip65ListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -82,7 +82,7 @@ class Nip65RelayListState( getNIP65RelayListFlow() .map { normalizeNIP65ReadRelayListWithBackup(it.note) } .onStart { emit(normalizeNIP65ReadRelayListWithBackup(nip65ListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -93,7 +93,7 @@ class Nip65RelayListState( getNIP65RelayListFlow() .map { normalizeNIP65AllRelayListWithBackupNoDefaults(it.note) } .onStart { emit(normalizeNIP65AllRelayListWithBackupNoDefaults(nip65ListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -124,7 +124,7 @@ class Nip65RelayListState( GlobalScope.launch(Dispatchers.IO) { cache.justConsumeMyOwnEvent(it) } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "NIP-65 Relay List Collector Start") getNIP65RelayListFlow().collect { Log.d("AccountRegisterObservers", "Updating NIP-65 List for ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip72Communities/CommunityListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip72Communities/CommunityListState.kt index 7f057593a..0e93aa73c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip72Communities/CommunityListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip72Communities/CommunityListState.kt @@ -72,7 +72,7 @@ class CommunityListState( emit(communityListWithBackup(noteState.note)) }.onStart { emit(communityListWithBackup(communityListNote)) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -86,7 +86,7 @@ class CommunityListState( hint.mapTo(mutableSetOf()) { it.address.toValue() } }.onStart { emit(flow.value.mapTo(mutableSetOf()) { it.address.toValue() }) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -147,7 +147,7 @@ class CommunityListState( } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Community List Collector Start") getCommunityListFlow().collect { Log.d("AccountRegisterObservers", "Community List for ${signer.pubKey}") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip78AppSpecific/AppSpecificState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip78AppSpecific/AppSpecificState.kt index 936191085..6a69cc8e2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip78AppSpecific/AppSpecificState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip78AppSpecific/AppSpecificState.kt @@ -81,7 +81,7 @@ class AppSpecificState( } } - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "AppSpecificData Collector Start") getAppSpecificDataFlow().collect { try { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip96FileStorage/FileStorageServerListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip96FileStorage/FileStorageServerListState.kt index 519d6cb27..2d78464d1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip96FileStorage/FileStorageServerListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip96FileStorage/FileStorageServerListState.kt @@ -59,7 +59,7 @@ class FileStorageServerListState( getFileServersListFlow() .map { normalizeServers(it.note) } .onStart { emit(normalizeServers(fileStorageListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nipB7Blossom/BlossomServerListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nipB7Blossom/BlossomServerListState.kt index 47ee78e48..c3f8f69ef 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nipB7Blossom/BlossomServerListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nipB7Blossom/BlossomServerListState.kt @@ -61,7 +61,7 @@ class BlossomServerListState( getBlossomServersListFlow() .map { normalizeServers(it.note) } .onStart { emit(normalizeServers(blossomListNote)) } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UpdatablePropertyFlow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UpdatablePropertyFlow.kt index af96b24f5..5daabe519 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UpdatablePropertyFlow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UpdatablePropertyFlow.kt @@ -34,7 +34,7 @@ class UpdatablePropertyFlow( ) { val stateFlow = flow - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope = scope, started = SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt index f155da664..81f4e7d6f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt @@ -79,7 +79,7 @@ class MergedFollowListsState( ), ) }.sample(200) - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineRelayListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineRelayListsState.kt index 6498e7bed..a9e0ff6d9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineRelayListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineRelayListsState.kt @@ -65,7 +65,7 @@ class MergedFollowPlusMineRelayListsState( ), ), ) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineWithIndexRelayListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineWithIndexRelayListsState.kt index ae22655e8..37cc66c47 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineWithIndexRelayListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineWithIndexRelayListsState.kt @@ -69,7 +69,7 @@ class MergedFollowPlusMineWithIndexRelayListsState( ), ), ) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineWithSearchRelayListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineWithSearchRelayListsState.kt index 68e5af6b9..825a6d98f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineWithSearchRelayListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineWithSearchRelayListsState.kt @@ -69,7 +69,7 @@ class MergedFollowPlusMineWithSearchRelayListsState( ), ), ) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedServerListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedServerListState.kt index 8c254d660..fb011d83e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedServerListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedServerListState.kt @@ -64,7 +64,7 @@ class MergedServerListState( mergeServerList(nip96s, blossoms) }.onStart { emit(mergeServerList(fileServers.flow.value, blossomServers.flow.value)) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/TrustedRelayListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/TrustedRelayListsState.kt index 86b492d04..be26a1f19 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/TrustedRelayListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/TrustedRelayListsState.kt @@ -75,7 +75,7 @@ class TrustedRelayListsState( ), ), ) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt index efc97e01c..cd6267e09 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt @@ -81,7 +81,7 @@ class FeedTopNavFilterState( emitAll(loadFlowsFor(listName).flow()) }.onStart { loadFlowsFor(feedFilterListName.value).startValue(this) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/MergedTopFeedAuthorListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/MergedTopFeedAuthorListsState.kt index fb860ae39..0728886f2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/MergedTopFeedAuthorListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/MergedTopFeedAuthorListsState.kt @@ -100,7 +100,7 @@ class MergedTopFeedAuthorListsState( notificationNavFilter.value, ), ) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/OutboxLoaderState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/OutboxLoaderState.kt index 257fdccf0..a2980535b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/OutboxLoaderState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/OutboxLoaderState.kt @@ -45,7 +45,7 @@ class OutboxLoaderState( emitAll(filterSettings.toPerRelayFlow(cache)) }.onStart { emit(topNavFilter.value.startValue(cache)) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Companion.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt index 9480564e3..6ec0711f8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt @@ -74,7 +74,7 @@ class TorRelayState( trustedRelaysViaTor = torSettingsFlow.trustedRelaysViaTor.value, ), ) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -108,7 +108,7 @@ class TorRelayState( dmRelayList = dmRelays.value, ), ) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/PokeyReceiver.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/PokeyReceiver.kt index b6f3a2cd2..077a23a91 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/PokeyReceiver.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/PokeyReceiver.kt @@ -47,7 +47,7 @@ class PokeyReceiver : BroadcastReceiver() { Log.e("AmethystCoroutine", "Caught exception: ${throwable.message}", throwable) } - val scope = CoroutineScope(Dispatchers.Default + SupervisorJob() + exceptionHandler) + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob() + exceptionHandler) fun register(app: Context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpWebSocket.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpWebSocket.kt index 56e25c7dd..82ecb29db 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpWebSocket.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpWebSocket.kt @@ -76,7 +76,7 @@ class OkHttpWebSocket( inner class OkHttpWebsocketListener( val out: WebSocketListener, ) : okhttp3.WebSocketListener() { - val scope = CoroutineScope(Dispatchers.Default + exceptionHandler) + val scope = CoroutineScope(Dispatchers.IO + exceptionHandler) val incomingMessages: Channel = Channel(Channel.UNLIMITED) val job = // Launch a coroutine to process messages from the channel. scope.launch { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/composable/controls/MuteButton.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/composable/controls/MuteButton.kt index 39fbc7339..080c50288 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/composable/controls/MuteButton.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/composable/controls/MuteButton.kt @@ -65,7 +65,7 @@ fun MuteButton( } LaunchedEffect(key1 = controllerVisible) { - launch(Dispatchers.Default) { + launch(Dispatchers.IO) { delay(2000) holdOn.value = false } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/eoseManagers/BaseEoseManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/eoseManagers/BaseEoseManager.kt index d59b82205..a5ba24b91 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/eoseManagers/BaseEoseManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/eoseManagers/BaseEoseManager.kt @@ -55,7 +55,7 @@ abstract class BaseEoseManager( fun dismissSubscription(subId: String) = orchestrator.dismissSubscription(subId) // Refreshes observers in batches. - private val bundler = BundledUpdate(sampleTime, Dispatchers.Default) + private val bundler = BundledUpdate(sampleTime, Dispatchers.IO) override fun invalidateFilters(ignoreIfDoing: Boolean) { bundler.invalidate(ignoreIfDoing, ::forceInvalidate) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/drafts/AccountDraftsEoseManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/drafts/AccountDraftsEoseManager.kt index 6b56afd3e..0487a503c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/drafts/AccountDraftsEoseManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/drafts/AccountDraftsEoseManager.kt @@ -63,7 +63,7 @@ class AccountDraftsEoseManager( userJobMap[user]?.forEach { it.cancel() } userJobMap[user] = listOf( - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { relayFlow(key).collectLatest { invalidateFilters() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/follows/AccountFollowsLoaderSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/follows/AccountFollowsLoaderSubAssembler.kt index fc7bcc80b..e15a6c799 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/follows/AccountFollowsLoaderSubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/follows/AccountFollowsLoaderSubAssembler.kt @@ -67,7 +67,7 @@ class AccountFollowsLoaderSubAssembler( private val orchestrator = SubscriptionController(client) // Refreshes observers in batches of 500ms - private val bundler = BundledUpdate(500, Dispatchers.Default) + private val bundler = BundledUpdate(500, Dispatchers.IO) /** * This assembler saves the EOSE per user key. That EOSE includes their metadata, etc @@ -203,7 +203,7 @@ class AccountFollowsLoaderSubAssembler( ) { accountUpdatesJobMap[user]?.cancel() accountUpdatesJobMap[user] = - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { followList.sample(1000).collectLatest { invalidateFilters(true) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/metadata/AccountMetadataEoseManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/metadata/AccountMetadataEoseManager.kt index 7ddeedd85..4b7c90f8c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/metadata/AccountMetadataEoseManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/metadata/AccountMetadataEoseManager.kt @@ -65,7 +65,7 @@ class AccountMetadataEoseManager( userJobMap[user]?.forEach { it.cancel() } userJobMap[user] = listOf( - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { relayFlow(key).collectLatest { invalidateFilters() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip01Notifications/AccountNotificationsEoseFromInboxRelaysManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip01Notifications/AccountNotificationsEoseFromInboxRelaysManager.kt index 61d45d8bd..c4dd64399 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip01Notifications/AccountNotificationsEoseFromInboxRelaysManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip01Notifications/AccountNotificationsEoseFromInboxRelaysManager.kt @@ -71,12 +71,12 @@ class AccountNotificationsEoseFromInboxRelaysManager( userJobMap[user]?.forEach { it.cancel() } userJobMap[user] = listOf( - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { key.account.notificationRelays.flow.sample(1000).collectLatest { invalidateFilters() } }, - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { key.feedContentStates.notifications.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { invalidateFilters() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip01Notifications/AccountNotificationsEoseFromRandomRelaysManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip01Notifications/AccountNotificationsEoseFromRandomRelaysManager.kt index 0e6f82f3f..34074f380 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip01Notifications/AccountNotificationsEoseFromRandomRelaysManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip01Notifications/AccountNotificationsEoseFromRandomRelaysManager.kt @@ -67,13 +67,13 @@ class AccountNotificationsEoseFromRandomRelaysManager( userJobMap[user]?.forEach { it.cancel() } userJobMap[user] = listOf( - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { // no need to hurry here. we can wait the app stabilize key.account.followsPerRelay.debounce(5000).collectLatest { invalidateFilters() } }, - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { key.feedContentStates.notifications.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { invalidateFilters() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip59GiftWraps/AccountGiftWrapsEoseManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip59GiftWraps/AccountGiftWrapsEoseManager.kt index 79a45b409..7771c04a4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip59GiftWraps/AccountGiftWrapsEoseManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip59GiftWraps/AccountGiftWrapsEoseManager.kt @@ -65,7 +65,7 @@ class AccountGiftWrapsEoseManager( userJobMap[user]?.forEach { it.cancel() } userJobMap[user] = listOf( - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { key.account.dmRelays.flow.collectLatest { invalidateFilters() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/channel/ChannelObservers.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/channel/ChannelObservers.kt index 0e60c26c7..1add909d1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/channel/ChannelObservers.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/channel/ChannelObservers.kt @@ -76,7 +76,7 @@ fun observeChannelNoteAuthors( channelToParticipatingUsers(baseChannel, accountViewModel), ) }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } return flow.collectAsStateWithLifecycle(persistentListOf()) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/event/EventObservers.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/event/EventObservers.kt index 665d4fe79..d232a84fc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/event/EventObservers.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/event/EventObservers.kt @@ -97,7 +97,7 @@ fun observeNoteAndMap( .metadata.stateFlow .mapLatest { map(it.note) } .distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } // Subscribe in the LocalCache for changes that arrive in the device @@ -123,7 +123,7 @@ fun observeNoteEventAndMap( .metadata.stateFlow .mapLatest { (it.note.event as? T)?.let { map(it) } } .distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } // Subscribe in the LocalCache for changes that arrive in the device @@ -223,7 +223,7 @@ fun observeNoteReactionCount( .sample(200) .mapLatest { it.note.countReactions() } .distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } // Subscribe in the LocalCache for changes that arrive in the device @@ -278,7 +278,7 @@ fun observeNoteRepostsBy( .boosts.stateFlow .mapLatest { it.note.isBoostedBy(user) } .distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } return flow.collectAsStateWithLifecycle(note.isBoostedBy(user)) @@ -401,7 +401,7 @@ fun observeCommunityApprovalNeedStatus( } } }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } // Subscribe in the LocalCache for changes that arrive in the device diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/UserObservers.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/UserObservers.kt index 77bcab70f..fb7a6764f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/UserObservers.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/UserObservers.kt @@ -253,7 +253,7 @@ fun observeUserFollowCount( .mapLatest { userState -> userState.user.transientFollowCount() ?: 0 }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } return flow.collectAsStateWithLifecycle(0) @@ -281,7 +281,7 @@ fun observeUserTagFollowCount( }.onStart { emit((accountViewModel.hashtagFollows(user).event as? HashtagListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.size ?: 0) }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } return flow.collectAsStateWithLifecycle(0) @@ -309,7 +309,7 @@ fun observeUserTagFollows( }.onStart { emit((accountViewModel.hashtagFollows(user).event as? HashtagListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.sorted() ?: emptyList()) }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } return flow.collectAsStateWithLifecycle(emptyList()) @@ -356,7 +356,7 @@ fun observeUserBookmarkCount( .mapLatest { noteState -> (noteState.note.event as? BookmarkListEvent)?.countBookmarks() ?: 0 }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } return flow.collectAsStateWithLifecycle(0) @@ -396,7 +396,7 @@ fun observeUserFollowerCount( .mapLatest { userState -> userState.user.transientFollowerCount() }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } return flow.collectAsStateWithLifecycle(0) @@ -426,7 +426,7 @@ fun observeUserIsFollowing( .mapLatest { userState -> userState.user.isFollowing(user2) || isUserInFollowSets }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } return flow.collectAsStateWithLifecycle( @@ -450,7 +450,7 @@ fun observeUserIsFollowingHashtag( }.onStart { emit(hashtag in accountViewModel.account.hashtagList.flow.value) }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } return flow.collectAsStateWithLifecycle(hashtag in accountViewModel.account.hashtagList.flow.value) @@ -471,7 +471,7 @@ fun observeUserIsFollowingGeohash( }.onStart { emit(geohash in accountViewModel.account.geohashList.flow.value) }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } return flow.collectAsStateWithLifecycle(geohash in accountViewModel.account.geohashList.flow.value) @@ -496,7 +496,7 @@ fun observeUserIsFollowingChannel( .mapLatest { followingChannels -> channel.idHex in followingChannels }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } @SuppressLint("StateFlowValueCalledInComposition") @@ -522,7 +522,7 @@ fun observeUserIsFollowingChannel( .mapLatest { followingChannels -> channel.roomId in followingChannels }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } @SuppressLint("StateFlowValueCalledInComposition") @@ -563,7 +563,7 @@ fun observeUserZapAmount( .mapLatest { userState -> userState.user.zappedAmount() }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } return flow.collectAsStateWithLifecycle(BigDecimal.ZERO) @@ -630,7 +630,7 @@ fun observeUserStatuses( .mapLatest { userState -> LocalCache.findStatusesForUser(userState.user) }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } return flow.collectAsStateWithLifecycle(persistentListOf()) @@ -649,7 +649,7 @@ fun observeUserRelayIntoList( .mapLatest { relays -> relayUrl in relays }.distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) } return flow.collectAsStateWithLifecycle(false) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt index 26b4398f4..a310b7465 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt @@ -110,7 +110,7 @@ class MainActivity : AppCompatActivity() { // Graph doesn't completely clear. // @OptIn(DelicateCoroutinesApi::class) - // GlobalScope.launch(Dispatchers.Default) { + // GlobalScope.launch(Dispatchers.IO) { // serviceManager.trimMemory() // } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt index 55ccb3871..fecaeada8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt @@ -85,7 +85,7 @@ fun CashuPreview( initialValue = CachedCashuParser.cached(cashutoken), key1 = cashutoken, ) { - val newToken = withContext(Dispatchers.Default) { CachedCashuParser.parse(cashutoken) } + val newToken = withContext(Dispatchers.IO) { CachedCashuParser.parse(cashutoken) } if (value != newToken) { value = newToken } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt index b49e9fa4a..b9388edba 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt @@ -583,7 +583,7 @@ fun DisplaySecretEmoji( if (secretContent == null) { LaunchedEffect(segment) { - launch(Dispatchers.Default) { + launch(Dispatchers.IO) { secretContent = CachedRichTextParser.parseText( EmojiCoder.decode(segment.segmentText), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentDialog.kt index 4e28c413e..42345b014 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentDialog.kt @@ -150,7 +150,7 @@ private fun DialogContent( pagerState.scrollToPage(page) } } - launch(Dispatchers.Default) { + launch(Dispatchers.IO) { delay(2000) withContext(Dispatchers.Main) { controllerVisible.value = false diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedContentState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedContentState.kt index af7b4b419..f615ccbe7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedContentState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedContentState.kt @@ -68,7 +68,7 @@ class ChannelFeedContentState( } private fun refresh() { - viewModelScope.launch(Dispatchers.Default) { refreshSuspended() } + viewModelScope.launch(Dispatchers.IO) { refreshSuspended() } } fun refreshSuspended() { @@ -135,8 +135,8 @@ class ChannelFeedContentState( } } - private val bundler = BundledUpdate(250, Dispatchers.Default) - private val bundlerInsert = BundledInsert>(250, Dispatchers.Default) + private val bundler = BundledUpdate(250, Dispatchers.IO) + private val bundlerInsert = BundledInsert>(250, Dispatchers.IO) override fun invalidateData(ignoreIfDoing: Boolean) { viewModelScope.launch(Dispatchers.IO) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/FeedContentState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/FeedContentState.kt index b17795168..5aad2eff9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/FeedContentState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/FeedContentState.kt @@ -71,7 +71,7 @@ class FeedContentState( } private fun refresh() { - viewModelScope.launch(Dispatchers.Default) { refreshSuspended() } + viewModelScope.launch(Dispatchers.IO) { refreshSuspended() } } fun visibleNotes(): List { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/Loaders.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/Loaders.kt index 1328401a7..ca5886d93 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/Loaders.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/Loaders.kt @@ -134,7 +134,7 @@ fun LoadOts( LaunchedEffect(key1 = noteStatus) { val newOts = - withContext(Dispatchers.Default) { + withContext(Dispatchers.IO) { LocalCache.findEarliestOtsForNote( note = noteStatus?.note ?: note, otsVerifCache = Amethyst.instance.otsVerifCache, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt index 42799727b..1468bc9cf 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt @@ -260,7 +260,7 @@ fun DisplaySecretEmojiAsReaction( if (secretContent == null) { LaunchedEffect(reaction) { - launch(Dispatchers.Default) { + launch(Dispatchers.IO) { secretContent = CachedRichTextParser.parseText( EmojiCoder.decode(reaction), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNoteViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNoteViewModel.kt index 9bee68081..a18b3f221 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNoteViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNoteViewModel.kt @@ -100,7 +100,7 @@ class PollNoteViewModel : ViewModel() { } fun refreshTallies() { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { totalZapped = totalZapped() wasZappedByLoggedInAccount = false wasZappedByLoggedInAccount = account.calculateIfNoteWasZappedByAccount(pollNote, 0) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/emojiSuggestions/EmojiSuggestionState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/emojiSuggestions/EmojiSuggestionState.kt index 82b6f5e23..c29768b53 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/emojiSuggestions/EmojiSuggestionState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/emojiSuggestions/EmojiSuggestionState.kt @@ -44,7 +44,7 @@ class EmojiSuggestionState( } else { emptyList() } - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) fun reset() { if (search.value.isNotEmpty()) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/invoice/InvoicePreview.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/invoice/InvoicePreview.kt index 7ade7a83f..3d4ff6b7b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/invoice/InvoicePreview.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/invoice/InvoicePreview.kt @@ -72,7 +72,7 @@ fun LoadValueFromInvoice( @Suppress("ProduceStateDoesNotAssignValue") val lnInvoice by produceState(initialValue = CachedLnInvoiceParser.cached(lnbcWord), key1 = lnbcWord) { - val newLnInvoice = withContext(Dispatchers.Default) { CachedLnInvoiceParser.parse(lnbcWord) } + val newLnInvoice = withContext(Dispatchers.IO) { CachedLnInvoiceParser.parse(lnbcWord) } if (value != newLnInvoice) { value = newLnInvoice } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/previews/PreviewState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/previews/PreviewState.kt index 096d8c4be..4d36f4603 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/previews/PreviewState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/previews/PreviewState.kt @@ -39,7 +39,7 @@ class PreviewState { .debounce(500) .map { CachedUrlParser.parseValidUrls(it.text) } .distinctUntilChanged() - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) fun reset() { source.tryEmit(TextFieldValue("")) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/ShowUserSuggestionList.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/ShowUserSuggestionList.kt index 9ac137001..f125148b8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/ShowUserSuggestionList.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/ShowUserSuggestionList.kt @@ -64,12 +64,12 @@ fun ShowUserSuggestionList( AnimateOnNewSearch(userSuggestions, listState) LaunchedEffect(Unit) { - launch(Dispatchers.Default) { + launch(Dispatchers.IO) { LocalCache.live.newEventBundles.collect { userSuggestions.invalidateData() } } - launch(Dispatchers.Default) { + launch(Dispatchers.IO) { LocalCache.live.deletedEventBundles.collect { userSuggestions.invalidateData() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/UserSuggestionState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/UserSuggestionState.kt index 453ab6a77..35d3531b2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/UserSuggestionState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/UserSuggestionState.kt @@ -62,7 +62,7 @@ class UserSuggestionState( } else { emptyList() } - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) fun reset() { currentWord.tryEmit("") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt index 4a4772c2b..c24a8012b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt @@ -323,7 +323,7 @@ open class CommentPostViewModel : cancel() accountViewModel.account.signAndComputeBroadcast(template, extraNotesToBroadcast) - accountViewModel.viewModelScope.launch(Dispatchers.Default) { + accountViewModel.viewModelScope.launch(Dispatchers.IO) { accountViewModel.account.deleteDraftIgnoreErrors(version) } } @@ -465,7 +465,7 @@ open class CommentPostViewModel : onError: (title: String, message: String) -> Unit, context: Context, ) { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { val myMultiOrchestrator = multiOrchestrator ?: return@launch isUploadingImage = true @@ -673,7 +673,7 @@ open class CommentPostViewModel : } override fun updateZapFromText() { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { val tagger = NewMessageTagger(message.text, emptyList(), emptyList(), accountViewModel) tagger.run() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/AppDefinition.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/AppDefinition.kt index da226558e..85074bd44 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/AppDefinition.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/AppDefinition.kt @@ -88,7 +88,7 @@ fun RenderAppDefinition( var metadata by remember { mutableStateOf(null) } LaunchedEffect(key1 = noteEvent) { - withContext(Dispatchers.Default) { metadata = noteEvent.appMetaData() } + withContext(Dispatchers.IO) { metadata = noteEvent.appMetaData() } } metadata?.let { theAppMetadata -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/MedicalData.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/MedicalData.kt index 6ee786b6a..e8606d59e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/MedicalData.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/MedicalData.kt @@ -185,7 +185,7 @@ fun RenderFhirResource( fun RenderFhirResource(event: FhirResourceEvent) { @Suppress("ProduceStateDoesNotAssignValue") val state by produceState(initialValue = FhirElementDatabase(), key1 = event) { - withContext(Dispatchers.Default) { + withContext(Dispatchers.IO) { parseResourceBundleOrNull(event.content)?.let { value = it } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt index 4484f8bc8..0ba80943e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt @@ -49,14 +49,14 @@ abstract class FeedViewModel( init { Log.d("Init", "Starting new Model: ${this.javaClass.simpleName}") - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { LocalCache.live.newEventBundles.collect { newNotes -> Log.d("Rendering Metrics", "Update feeds: ${this@FeedViewModel.javaClass.simpleName} with ${newNotes.size}") feedState.updateFeedWith(newNotes) } } - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { LocalCache.live.deletedEventBundles.collect { newNotes -> Log.d("Rendering Metrics", "Delete from feeds: ${this@FeedViewModel.javaClass.simpleName} with ${newNotes.size}") feedState.deleteFromFeed(newNotes) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FollowListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FollowListState.kt index 13ab5552e..d98cc6277 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FollowListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FollowListState.kt @@ -253,11 +253,11 @@ class FollowListState( val kind3GlobalPeopleRoutes = _kind3GlobalPeopleRoutes - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.Eagerly, defaultLists) val kind3GlobalPeople = _kind3GlobalPeople - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.Eagerly, defaultLists) suspend fun initializeSuspend() { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedViewModel.kt index 34203a6dd..0ee61023e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedViewModel.kt @@ -49,7 +49,7 @@ open class UserFeedViewModel( val feedContent = _feedContent.asStateFlow() private fun refresh() { - viewModelScope.launch(Dispatchers.Default) { refreshSuspended() } + viewModelScope.launch(Dispatchers.IO) { refreshSuspended() } } override val isRefreshing: MutableState = mutableStateOf(false) @@ -100,14 +100,14 @@ open class UserFeedViewModel( init { Log.d("Init", "${this.javaClass.simpleName}") - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { LocalCache.live.newEventBundles.collect { newNotes -> Log.d("Rendering Metrics", "Update feeds: ${this@UserFeedViewModel.javaClass.simpleName} with ${newNotes.size}") invalidateData() } } - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { LocalCache.live.deletedEventBundles.collect { newNotes -> Log.d("Rendering Metrics", "Delete from feeds: ${this@UserFeedViewModel.javaClass.simpleName} with ${newNotes.size}") invalidateData() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index b678b35aa..330db6c99 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -202,7 +202,7 @@ class AccountViewModel( val notificationHasNewItemsFlow = notificationHasNewItems - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(30000), false) @OptIn(ExperimentalCoroutinesApi::class) @@ -251,7 +251,7 @@ class AccountViewModel( val messagesHasNewItemsFlow = messagesHasNewItems - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(30000), false) @OptIn(ExperimentalCoroutinesApi::class) @@ -284,7 +284,7 @@ class AccountViewModel( val homeHasNewItemsFlow = homeHasNewItems - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(30000), false) val hasNewItems = @@ -394,7 +394,7 @@ class AccountViewModel( account.kind3FollowList.flow.value.authors, ), ) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( viewModelScope, SharingStarted.WhileSubscribed(10000, 10000), @@ -412,7 +412,7 @@ class AccountViewModel( .relays .stateFlow .map { it.note.relays.size > 3 } - .flowOn(Dispatchers.Default) + .flowOn(Dispatchers.IO) .stateIn( viewModelScope, SharingStarted.WhileSubscribed(10000, 10000), @@ -431,7 +431,7 @@ class AccountViewModel( suspend fun calculateZapAmount(zappedNote: Note): String = if (zappedNote.zapPayments.isNotEmpty()) { - withContext(Dispatchers.Default) { + withContext(Dispatchers.IO) { val it = account.calculateZappedAmount(zappedNote) showAmount(it) } @@ -442,7 +442,7 @@ class AccountViewModel( suspend fun calculateZapraiser(zappedNote: Note): ZapraiserStatus { val zapraiserAmount = zappedNote.event?.zapraiserAmount() ?: 0 return if (zappedNote.zapPayments.isNotEmpty()) { - withContext(Dispatchers.Default) { + withContext(Dispatchers.IO) { val newZapAmount = account.calculateZappedAmount(zappedNote) var percentage = newZapAmount.div(zapraiserAmount.toBigDecimal()).toFloat() @@ -1027,7 +1027,7 @@ class AccountViewModel( fun cachedModificationEventsForNote(note: Note) = LocalCache.cachedModificationEventsForNote(note) suspend fun findModificationEventsForNote(note: Note): List = - withContext(Dispatchers.Default) { + withContext(Dispatchers.IO) { LocalCache.findLatestModificationForNote(note) } @@ -1067,7 +1067,7 @@ class AccountViewModel( hexList: List, onReady: (ImmutableList) -> Unit, ) { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { onReady(loadUsersSync(hexList).toImmutableList()) } } @@ -1094,7 +1094,7 @@ class AccountViewModel( val onIsNew = createdAt > lastTime if (onIsNew) { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { account.markAsRead(routeForLastRead, createdAt) } } @@ -1142,7 +1142,7 @@ class AccountViewModel( init { Log.d("Init", "AccountViewModel") - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { feedStates.init() // awaits for init to finish before starting to capture new events. LocalCache.live.newEventBundles.collect { newNotes -> @@ -1152,7 +1152,7 @@ class AccountViewModel( } } - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { LocalCache.live.deletedEventBundles.collect { newNotes -> logTime("AccountViewModel deletedEventBundle Update with ${newNotes.size} new notes") { feedStates.deleteNotes(newNotes) @@ -1602,7 +1602,7 @@ class AccountViewModel( val accountViewModel: AccountViewModel, ) : GenericBaseCache(20) { override suspend fun compute(key: String): LoadedBechLink? = - withContext(Dispatchers.Default) { + withContext(Dispatchers.IO) { Nip19Parser.uriToRoute(key)?.let { var returningNote: Note? = null @@ -1621,10 +1621,10 @@ class AccountViewModel( } } is NEmbed -> - withContext(Dispatchers.Default) { + withContext(Dispatchers.IO) { val baseNote = LocalCache.getOrCreateNote(parsed.event) if (baseNote.event == null) { - launch(Dispatchers.Default) { + launch(Dispatchers.IO) { LocalCache.justConsume(parsed.event, null, false) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/dal/ChatroomFeedViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/dal/ChatroomFeedViewModel.kt index f2b8973ac..dd6676f11 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/dal/ChatroomFeedViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/dal/ChatroomFeedViewModel.kt @@ -61,7 +61,7 @@ abstract class ListChangeFeedViewModel( init { Log.d("Init", "Starting new Model: ${this.javaClass.simpleName}") - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { localFilter.changesFlow().collect { Log.d("Init", "Collecting changes to: ${this@ListChangeFeedViewModel.javaClass.simpleName}") when (it) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt index 40b51d993..6899d7b14 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt @@ -361,7 +361,7 @@ class ChatNewMessageViewModel : val version = draftTag.current innerSendPost(null) cancel() - accountViewModel.viewModelScope.launch(Dispatchers.Default) { + accountViewModel.viewModelScope.launch(Dispatchers.IO) { accountViewModel.account.deleteDraftIgnoreErrors(version) } } @@ -594,7 +594,7 @@ class ChatNewMessageViewModel : } fun updateRoomFromUsersInput() { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { delay(300) val toUsersTagger = NewMessageTagger(toUsers.text, null, null, accountViewModel) toUsersTagger.run() @@ -717,7 +717,7 @@ class ChatNewMessageViewModel : } override fun updateZapFromText() { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { val tagger = NewMessageTagger(message.text, emptyList(), emptyList(), accountViewModel) tagger.run() tagger.pTags?.forEach { taggedUser -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt index 92526bc53..8272af2ae 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt @@ -277,7 +277,7 @@ open class ChannelNewMessageViewModel : cancel() accountViewModel.account.signAndSendPrivately(template, channelRelays) - accountViewModel.viewModelScope.launch(Dispatchers.Default) { + accountViewModel.viewModelScope.launch(Dispatchers.IO) { accountViewModel.account.deleteDraftIgnoreErrors(version) } } @@ -319,7 +319,7 @@ open class ChannelNewMessageViewModel : context: Context, onceUploaded: suspend () -> Unit, ) { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { val uploadState = uploadState ?: return@launch val myMultiOrchestrator = uploadState.multiOrchestrator ?: return@launch @@ -630,7 +630,7 @@ open class ChannelNewMessageViewModel : } fun updateZapFromText() { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { val tagger = NewMessageTagger(message.text, emptyList(), emptyList(), accountViewModel) tagger.run() tagger.pTags?.forEach { taggedUser -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/DMsFromUserFilterSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/DMsFromUserFilterSubAssembler.kt index f57593127..5a5eae521 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/DMsFromUserFilterSubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/DMsFromUserFilterSubAssembler.kt @@ -61,12 +61,12 @@ class DMsFromUserFilterSubAssembler( userJobMap[user]?.forEach { it.cancel() } userJobMap[user] = listOf( - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { key.account.homeRelays.flow.collectLatest { invalidateFilters() } }, - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { key.account.dmRelays.flow.collectLatest { invalidateFilters() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FollowingEphemeralChatSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FollowingEphemeralChatSubAssembler.kt index 196940e2e..4a733cce0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FollowingEphemeralChatSubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FollowingEphemeralChatSubAssembler.kt @@ -54,7 +54,7 @@ class FollowingEphemeralChatSubAssembler( userJobMap[key.account.userProfile()]?.forEach { it.cancel() } userJobMap[key.account.userProfile()] = listOf( - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { key.account.ephemeralChatList.liveEphemeralChatList.sample(500).collectLatest { invalidateFilters() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FollowingPublicChatSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FollowingPublicChatSubAssembler.kt index e08413b26..405a22c9a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FollowingPublicChatSubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FollowingPublicChatSubAssembler.kt @@ -55,7 +55,7 @@ class FollowingPublicChatSubAssembler( userJobMap[key.account.userProfile()]?.forEach { it.cancel() } userJobMap[key.account.userProfile()] = listOf( - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { key.account.publicChatList.flowSet.sample(500).collectLatest { invalidateFilters() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFollowsSetsAndLiveStreamsSubAssembler2.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFollowsSetsAndLiveStreamsSubAssembler2.kt index a1cb0e32c..eacc12b13 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFollowsSetsAndLiveStreamsSubAssembler2.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFollowsSetsAndLiveStreamsSubAssembler2.kt @@ -70,17 +70,17 @@ class DiscoveryFollowsSetsAndLiveStreamsSubAssembler2( userJobMap[user]?.forEach { it.cancel() } userJobMap[user] = listOf( - key.scope.launch(Dispatchers.Default) { + key.scope.launch(Dispatchers.IO) { key.listNameFlow().collectLatest { invalidateFilters() } }, - key.scope.launch(Dispatchers.Default) { + key.scope.launch(Dispatchers.IO) { key.followsPerRelayFlow().sample(1000).collectLatest { invalidateFilters() } }, - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { combine( key.feedStates.discoverFollowSets.lastNoteCreatedAtWhenFullyLoaded, key.feedStates.discoverLive.lastNoteCreatedAtWhenFullyLoaded, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryLongFormClassifiedsAndDVMSubAssembler1.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryLongFormClassifiedsAndDVMSubAssembler1.kt index 6da653201..0ba4eb8ed 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryLongFormClassifiedsAndDVMSubAssembler1.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryLongFormClassifiedsAndDVMSubAssembler1.kt @@ -72,17 +72,17 @@ class DiscoveryLongFormClassifiedsAndDVMSubAssembler1( userJobMap[user]?.forEach { it.cancel() } userJobMap[user] = listOf( - key.scope.launch(Dispatchers.Default) { + key.scope.launch(Dispatchers.IO) { key.listNameFlow().collectLatest { invalidateFilters() } }, - key.scope.launch(Dispatchers.Default) { + key.scope.launch(Dispatchers.IO) { key.followsPerRelayFlow().sample(500).collectLatest { invalidateFilters() } }, - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { combine( key.feedStates.discoverReads.lastNoteCreatedAtWhenFullyLoaded, key.feedStates.discoverDVMs.lastNoteCreatedAtWhenFullyLoaded, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryPublicChatsAndCommunitiesSubAssembler3.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryPublicChatsAndCommunitiesSubAssembler3.kt index 02826f865..c5a38b8f7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryPublicChatsAndCommunitiesSubAssembler3.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryPublicChatsAndCommunitiesSubAssembler3.kt @@ -69,17 +69,17 @@ class DiscoveryPublicChatsAndCommunitiesSubAssembler3( userJobMap[user]?.forEach { it.cancel() } userJobMap[user] = listOf( - key.scope.launch(Dispatchers.Default) { + key.scope.launch(Dispatchers.IO) { key.listNameFlow().collectLatest { invalidateFilters() } }, - key.scope.launch(Dispatchers.Default) { + key.scope.launch(Dispatchers.IO) { key.followsPerRelayFlow().sample(500).collectLatest { invalidateFilters() } }, - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { combine( key.feedStates.discoverPublicChats.lastNoteCreatedAtWhenFullyLoaded, key.feedStates.discoverCommunities.lastNoteCreatedAtWhenFullyLoaded, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt index 1c8dd17b6..ae52a7d7f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt @@ -297,7 +297,7 @@ open class NewProductViewModel : cancel() accountViewModel.account.signAndSendPrivatelyOrBroadcast(template, relayList = { relayList }) - accountViewModel.viewModelScope.launch(Dispatchers.Default) { + accountViewModel.viewModelScope.launch(Dispatchers.IO) { accountViewModel.account.deleteDraftIgnoreErrors(version) } } @@ -379,7 +379,7 @@ open class NewProductViewModel : onError: (title: String, message: String) -> Unit, context: Context, ) { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { val myAccount = account ?: return@launch val myMultiOrchestrator = multiOrchestrator ?: return@launch @@ -593,7 +593,7 @@ open class NewProductViewModel : } override fun updateZapFromText() { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { val tagger = NewMessageTagger(message.text, emptyList(), emptyList(), accountViewModel!!) tagger.run() tagger.pTags?.forEach { taggedUser -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt index 847214bca..e4d7d7200 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt @@ -483,7 +483,7 @@ open class ShortNotePostViewModel : cancel() accountViewModel.account.signAndComputeBroadcast(template, extraNotesToBroadcast) - accountViewModel.viewModelScope.launch(Dispatchers.Default) { + accountViewModel.viewModelScope.launch(Dispatchers.IO) { accountViewModel.account.deleteDraftIgnoreErrors(version) } } @@ -643,7 +643,7 @@ open class ShortNotePostViewModel : context: Context, useH265: Boolean, ) { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { val myMultiOrchestrator = multiOrchestrator ?: return@launch isUploadingImage = true @@ -899,7 +899,7 @@ open class ShortNotePostViewModel : } override fun updateZapFromText() { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { val tagger = NewMessageTagger(message.text, emptyList(), emptyList(), accountViewModel) tagger.run() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/HomeOutboxEventsEoseManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/HomeOutboxEventsEoseManager.kt index f6e3d4c47..6646fa1ad 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/HomeOutboxEventsEoseManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/HomeOutboxEventsEoseManager.kt @@ -91,22 +91,22 @@ class HomeOutboxEventsEoseManager( userJobMap[user]?.forEach { it.cancel() } userJobMap[user] = listOf( - key.scope.launch(Dispatchers.Default) { + key.scope.launch(Dispatchers.IO) { key.listNameFlow().collectLatest { invalidateFilters() } }, - key.scope.launch(Dispatchers.Default) { + key.scope.launch(Dispatchers.IO) { key.followRelayFlow().sample(1000).collectLatest { invalidateFilters() } }, - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { key.feedState.homeNewThreads.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { invalidateFilters() } }, - key.account.scope.launch(Dispatchers.Default) { + key.account.scope.launch(Dispatchers.IO) { key.feedState.homeReplies.lastNoteCreatedAtWhenFullyLoaded.sample(5000).collectLatest { invalidateFilters() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt index 3d6ef0545..e2e59f680 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt @@ -104,7 +104,7 @@ class CardFeedContentState( fun lastNoteCreatedAtIfFilled() = lastNoteCreatedAtWhenFullyLoaded.value fun refresh() { - viewModelScope.launch(Dispatchers.Default) { refreshSuspended() } + viewModelScope.launch(Dispatchers.IO) { refreshSuspended() } } @Synchronized diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt index 3231287d2..8b975446e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt @@ -320,7 +320,7 @@ class NewPublicMessageViewModel : cancel() accountViewModel.account.signAndComputeBroadcast(template, extraNotesToBroadcast) - accountViewModel.viewModelScope.launch(Dispatchers.Default) { + accountViewModel.viewModelScope.launch(Dispatchers.IO) { accountViewModel.account.deleteDraftIgnoreErrors(version) } } @@ -413,7 +413,7 @@ class NewPublicMessageViewModel : onError: (title: String, message: String) -> Unit, context: Context, ) { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { val myMultiOrchestrator = multiOrchestrator ?: return@launch isUploadingImage = true @@ -628,7 +628,7 @@ class NewPublicMessageViewModel : } override fun updateZapFromText() { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { val tagger = NewMessageTagger(message.text, emptyList(), emptyList(), accountViewModel) tagger.run() tagger.pTags?.forEach { taggedUser -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/apps/WatchApp.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/apps/WatchApp.kt index 2ead89f33..b24d30293 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/apps/WatchApp.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/apps/WatchApp.kt @@ -55,7 +55,7 @@ fun WatchApp( var appName by remember(baseApp) { mutableStateOf(null) } LaunchedEffect(key1 = appState) { - withContext(Dispatchers.Default) { + withContext(Dispatchers.IO) { (appState?.note?.event as? AppDefinitionEvent)?.appMetaData()?.let { metaData -> metaData.picture?.ifBlank { null }?.let { newLogo -> if (newLogo != appLogo) appLogo = newLogo diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/relays/RelayFeedViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/relays/RelayFeedViewModel.kt index a26fd2497..81440c8ec 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/relays/RelayFeedViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/relays/RelayFeedViewModel.kt @@ -89,7 +89,7 @@ class RelayFeedViewModel : } }.onStart { emit(convert((currentUser.value?.nip65RelayListNote?.event as? AdvertisedRelayListEvent)?.writeRelaysNorm()?.toSet(), currentUser.value)) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyList()) @OptIn(ExperimentalCoroutinesApi::class) @@ -113,7 +113,7 @@ class RelayFeedViewModel : } }.onStart { emit(convert((currentUser.value?.nip65RelayListNote?.event as? AdvertisedRelayListEvent)?.readRelaysNorm()?.toSet(), currentUser.value)) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyList()) @OptIn(ExperimentalCoroutinesApi::class) @@ -137,13 +137,13 @@ class RelayFeedViewModel : } }.onStart { emit(convert((currentUser.value?.nip65RelayListNote?.event as? ChatMessageRelayListEvent)?.relays()?.toSet(), currentUser.value)) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyList()) override val isRefreshing: MutableState = mutableStateOf(false) fun refresh() { - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { refreshSuspended() } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/zaps/LnZapFeedViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/zaps/LnZapFeedViewModel.kt index 3e910af2c..1619707db 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/zaps/LnZapFeedViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/zaps/LnZapFeedViewModel.kt @@ -44,7 +44,7 @@ open class LnZapFeedViewModel( val feedContent = _feedContent.asStateFlow() private fun refresh() { - viewModelScope.launch(Dispatchers.Default) { refreshSuspended() } + viewModelScope.launch(Dispatchers.IO) { refreshSuspended() } } private fun refreshSuspended() { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchBarViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchBarViewModel.kt index b6241290c..583083c8c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchBarViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchBarViewModel.kt @@ -75,7 +75,7 @@ class SearchBarViewModel( invalidations.debounce(100), ) { term, version -> LocalCache.findUsersStartingWith(term, account) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, WhileSubscribed(5000), emptyList()) val searchResultsNotes = @@ -86,7 +86,7 @@ class SearchBarViewModel( LocalCache .findNotesStartingWith(term, account.hiddenUsers) .sortedWith(DefaultFeedOrder) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, WhileSubscribed(5000), emptyList()) val searchResultsPublicChatChannels = @@ -95,7 +95,7 @@ class SearchBarViewModel( invalidations, ) { term, version -> LocalCache.findPublicChatChannelsStartingWith(term) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, WhileSubscribed(5000), emptyList()) val searchResultsEphemeralChannels = @@ -104,7 +104,7 @@ class SearchBarViewModel( invalidations, ) { term, version -> LocalCache.findEphemeralChatChannelsStartingWith(term) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, WhileSubscribed(5000), emptyList()) val searchResultsLiveActivityChannels = @@ -113,7 +113,7 @@ class SearchBarViewModel( invalidations, ) { term, version -> LocalCache.findLiveActivityChannelsStartingWith(term) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, WhileSubscribed(5000), emptyList()) val hashtagResults = @@ -122,7 +122,7 @@ class SearchBarViewModel( invalidations, ) { term, version -> findHashtags(term) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, WhileSubscribed(5000), emptyList()) override val isRefreshing = derivedStateOf { searchValue.isNotBlank() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchScreen.kt index ab47c8eb7..df6aa1058 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchScreen.kt @@ -143,7 +143,7 @@ private fun SearchBar( TextSearchDataSourceSubscription(searchBarViewModel, accountViewModel) LaunchedEffect(Unit) { - launch(Dispatchers.Default) { + launch(Dispatchers.IO) { LocalCache.live.newEventBundles.collect { if (searchBarViewModel.isSearchingFun()) { searchBarViewModel.invalidateData() @@ -151,7 +151,7 @@ private fun SearchBar( } } - launch(Dispatchers.Default) { + launch(Dispatchers.IO) { LocalCache.live.deletedEventBundles.collect { if (searchBarViewModel.isSearchingFun()) { searchBarViewModel.invalidateData() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/StringFeedViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/StringFeedViewModel.kt index cc999d797..5d49b9a50 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/StringFeedViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/StringFeedViewModel.kt @@ -50,7 +50,7 @@ open class StringFeedViewModel( override val isRefreshing: MutableState = mutableStateOf(false) private fun refresh() { - viewModelScope.launch(Dispatchers.Default) { refreshSuspended() } + viewModelScope.launch(Dispatchers.IO) { refreshSuspended() } } private fun refreshSuspended() { @@ -99,13 +99,13 @@ open class StringFeedViewModel( init { Log.d("Init", this.javaClass.simpleName) - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { LocalCache.live.newEventBundles.collect { newNotes -> Log.d("Rendering Metrics", "Update feeds: ${this@StringFeedViewModel.javaClass.simpleName} with ${newNotes.size}") invalidateData() } } - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch(Dispatchers.IO) { LocalCache.live.deletedEventBundles.collect { newNotes -> Log.d("Rendering Metrics", "Delete feeds: ${this@StringFeedViewModel.javaClass.simpleName} with ${newNotes.size}") invalidateData() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/dal/LevelFeedViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/dal/LevelFeedViewModel.kt index 2a0115802..3d006fffb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/dal/LevelFeedViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/dal/LevelFeedViewModel.kt @@ -80,7 +80,7 @@ abstract class LevelFeedViewModel( MutableStateFlow(mapOf()) }, ) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( viewModelScope, SharingStarted.WhileSubscribed(5000), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/NewImageButton.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/NewImageButton.kt index 5c1d10c64..05797c81f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/NewImageButton.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/NewImageButton.kt @@ -88,7 +88,7 @@ fun NewImageButton( val postViewModel: NewMediaModel = viewModel() postViewModel.onceUploaded { - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { delay(500) withContext(Dispatchers.Main) { navScrollToTop() } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/VideoOutboxEventsFilterSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/VideoOutboxEventsFilterSubAssembler.kt index 5bc1288e2..ef53e0037 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/VideoOutboxEventsFilterSubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/VideoOutboxEventsFilterSubAssembler.kt @@ -93,12 +93,12 @@ class VideoOutboxEventsFilterSubAssembler( userJobMap[user]?.forEach { it.cancel() } userJobMap[user] = listOf( - key.scope.launch(Dispatchers.Default) { + key.scope.launch(Dispatchers.IO) { key.followsPerRelayFlow().sample(1000).collectLatest { invalidateFilters() } }, - key.scope.launch(Dispatchers.Default) { + key.scope.launch(Dispatchers.IO) { key.feedState.videoFeed.lastNoteCreatedAtWhenFullyLoaded.sample(1000).collectLatest { invalidateFilters() } diff --git a/ammolite/src/main/java/com/vitorpamplona/ammolite/relays/BundledUpdate.kt b/ammolite/src/main/java/com/vitorpamplona/ammolite/relays/BundledUpdate.kt index 66dc0d04e..e94e62a61 100644 --- a/ammolite/src/main/java/com/vitorpamplona/ammolite/relays/BundledUpdate.kt +++ b/ammolite/src/main/java/com/vitorpamplona/ammolite/relays/BundledUpdate.kt @@ -40,7 +40,7 @@ import java.util.concurrent.atomic.AtomicBoolean @Stable class BundledUpdate( val delay: Long, - val dispatcher: CoroutineDispatcher = Dispatchers.Default, + val dispatcher: CoroutineDispatcher = Dispatchers.IO, ) { // Exists to avoid exceptions stopping the coroutine val exceptionHandler = @@ -66,7 +66,7 @@ class BundledUpdate( @Stable class BasicBundledUpdate( val delay: Long, - val dispatcher: CoroutineDispatcher = Dispatchers.Default, + val dispatcher: CoroutineDispatcher = Dispatchers.IO, val scope: CoroutineScope, ) { private var onlyOneInBlock = AtomicBoolean() @@ -104,7 +104,7 @@ class BasicBundledUpdate( @Stable class BundledInsert( val delay: Long, - val dispatcher: CoroutineDispatcher = Dispatchers.Default, + val dispatcher: CoroutineDispatcher = Dispatchers.IO, ) { // Exists to avoid exceptions stopping the coroutine val exceptionHandler = @@ -130,7 +130,7 @@ class BundledInsert( @Stable class BasicBundledInsert( val delay: Long, - val dispatcher: CoroutineDispatcher = Dispatchers.Default, + val dispatcher: CoroutineDispatcher = Dispatchers.IO, val scope: CoroutineScope, ) { private var onlyOneInBlock = AtomicBoolean() diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/NostrClient.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/NostrClient.kt index 1c818969f..c20b7b8fd 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/NostrClient.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/NostrClient.kt @@ -108,7 +108,7 @@ class NostrClient( }.sample(300) .onEach { relayPool.updatePool(it) - }.flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.Eagerly, @@ -229,7 +229,7 @@ class NostrClient( override fun renewFilters(relay: IRelayClient) { if (isActive) { - scope.launch(Dispatchers.Default) { + scope.launch(Dispatchers.IO) { activeRequests.syncState(relay.url, relay::sendOrConnectAndSync) activeCounts.syncState(relay.url, relay::sendOrConnectAndSync) eventOutbox.syncState(relay.url, relay::sendOrConnectAndSync) diff --git a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/sockets/okhttp/BasicOkHttpWebSocket.kt b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/sockets/okhttp/BasicOkHttpWebSocket.kt index 79a02caf1..0d8f20ea1 100644 --- a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/sockets/okhttp/BasicOkHttpWebSocket.kt +++ b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip01Core/relay/sockets/okhttp/BasicOkHttpWebSocket.kt @@ -60,7 +60,7 @@ class BasicOkHttpWebSocket( val listener = object : OkHttpWebSocketListener() { - val scope = CoroutineScope(Dispatchers.Default + exceptionHandler) + val scope = CoroutineScope(Dispatchers.IO + exceptionHandler) val incomingMessages: Channel = Channel(Channel.UNLIMITED) val job = // Launch a coroutine to process messages from the channel. scope.launch {