From 548dd9e34ff3f7d7442acfad0641535addd36f0a Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 18 Jun 2024 18:20:58 -0400 Subject: [PATCH] Makes sure the isAcceptable runs on IO thread --- .../amethyst/ui/screen/loggedIn/AccountViewModel.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index e0833cf90..294300cf0 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -269,6 +269,8 @@ class AccountViewModel( accountChoices: Account.LiveHiddenUsers, followUsers: Set, ): NoteComposeReportState { + checkNotInMainThread() + val isFromLoggedIn = note.author?.pubkeyHex == userProfile().pubkeyHex val isFromLoggedInFollow = note.author?.let { followUsers.contains(it.pubkeyHex) } ?: true val isPostHidden = note.isHiddenFor(accountChoices) @@ -310,7 +312,11 @@ class AccountViewModel( note.flow().metadata.stateFlow, note.flow().reports.stateFlow, ) { hiddenUsers, followingUsers, metadata, reports -> - emit(isNoteAcceptable(metadata.note, hiddenUsers, followingUsers.users)) + val isAcceptable = + withContext(Dispatchers.IO) { + isNoteAcceptable(metadata.note, hiddenUsers, followingUsers.users) + } + emit(isAcceptable) }.stateIn( viewModelScope, SharingStarted.Eagerly,