diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index a66f92d06..2f7d3db2a 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -441,9 +441,7 @@ fun WatchForReports( val noteReportsState by note.live().reports.observeAsState() LaunchedEffect(key1 = noteReportsState, key2 = userFollowsState) { - launch(Dispatchers.Default) { - accountViewModel.isNoteAcceptable(note, onChange) - } + accountViewModel.isNoteAcceptable(note, onChange) } } 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 4194e9d45..0b4a4ede2 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 @@ -411,24 +411,26 @@ class AccountViewModel(val account: Account) : ViewModel() { } fun isNoteAcceptable(note: Note, onReady: (Boolean, Boolean, ImmutableSet) -> Unit) { - val isFromLoggedIn = note.author?.pubkeyHex == userProfile().pubkeyHex - val isFromLoggedInFollow = note.author?.let { userProfile().isFollowingCached(it) } ?: true + viewModelScope.launch { + val isFromLoggedIn = note.author?.pubkeyHex == userProfile().pubkeyHex + val isFromLoggedInFollow = note.author?.let { userProfile().isFollowingCached(it) } ?: true - if (isFromLoggedIn || isFromLoggedInFollow) { - // No need to process if from trusted people - onReady(true, true, persistentSetOf()) - } else { - val newCanPreview = !note.hasAnyReports() - - val newIsAcceptable = account.isAcceptable(note) - - if (newCanPreview && newIsAcceptable) { - // No need to process reports if nothing is wrong + if (isFromLoggedIn || isFromLoggedInFollow) { + // No need to process if from trusted people onReady(true, true, persistentSetOf()) } else { - val newRelevantReports = account.getRelevantReports(note) + val newCanPreview = !note.hasAnyReports() - onReady(newIsAcceptable, newCanPreview, newRelevantReports.toImmutableSet()) + val newIsAcceptable = account.isAcceptable(note) + + if (newCanPreview && newIsAcceptable) { + // No need to process reports if nothing is wrong + onReady(true, true, persistentSetOf()) + } else { + val newRelevantReports = account.getRelevantReports(note) + + onReady(newIsAcceptable, newCanPreview, newRelevantReports.toImmutableSet()) + } } } }