diff --git a/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index 59cccf609..e28e9cf2c 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -345,18 +345,22 @@ class Account( ) { localLive, blockList, muteList -> checkNotInMainThread() - val resultBlockList = withTimeoutOrNull(1000) { - suspendCancellableCoroutine { continuation -> - (blockList.note.event as? PeopleListEvent)?.publicAndPrivateUsersAndWords(signer) { - continuation.resume(it) + val resultBlockList = (blockList.note.event as? PeopleListEvent)?.let { + withTimeoutOrNull(1000) { + suspendCancellableCoroutine { continuation -> + it.publicAndPrivateUsersAndWords(signer) { + continuation.resume(it) + } } } } ?: PeopleListEvent.UsersAndWords() - val resultMuteList = withTimeoutOrNull(1000) { - suspendCancellableCoroutine { continuation -> - (muteList.note.event as? MuteListEvent)?.publicAndPrivateUsersAndWords(signer) { - continuation.resume(it) + val resultMuteList = (muteList.note.event as? MuteListEvent)?.let { + withTimeoutOrNull(1000) { + suspendCancellableCoroutine { continuation -> + it.publicAndPrivateUsersAndWords(signer) { + continuation.resume(it) + } } } } ?: PeopleListEvent.UsersAndWords() 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 a342dafb5..a5275afea 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 @@ -76,6 +76,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.core.graphics.drawable.toBitmap import androidx.core.graphics.get +import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.distinctUntilChanged import androidx.lifecycle.map import coil.compose.AsyncImage @@ -434,8 +435,9 @@ fun WatchForReports( ) { val userFollowsState by accountViewModel.userFollows.observeAsState() val noteReportsState by note.live().reports.observeAsState() + val userBlocks by accountViewModel.account.flowHiddenUsers.collectAsStateWithLifecycle() - LaunchedEffect(key1 = noteReportsState, key2 = userFollowsState) { + LaunchedEffect(key1 = noteReportsState, key2 = userFollowsState, userBlocks) { accountViewModel.isNoteAcceptable(note, onChange) } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/VideoScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/VideoScreen.kt index 6c242e8c2..39e8a511c 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/VideoScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/VideoScreen.kt @@ -115,8 +115,9 @@ fun VideoScreen( @Composable fun WatchAccountForVideoScreen(videoFeedView: NostrVideoFeedViewModel, accountViewModel: AccountViewModel) { val listState by accountViewModel.account.liveStoriesFollowLists.collectAsStateWithLifecycle() + val hiddenUsers = accountViewModel.account.flowHiddenUsers.collectAsStateWithLifecycle() - LaunchedEffect(accountViewModel, listState) { + LaunchedEffect(accountViewModel, listState, hiddenUsers) { NostrVideoDataSource.resetFilters() videoFeedView.checkKeysInvalidateDataAndSendToTop() } @@ -193,6 +194,7 @@ private fun LoadedState( SlidingCarousel( state.feed, pagerState, + state.showHidden.value, accountViewModel, nav ) @@ -204,6 +206,7 @@ private fun LoadedState( fun SlidingCarousel( feed: MutableState>, pagerState: PagerState, + showHidden: Boolean, accountViewModel: AccountViewModel, nav: (String) -> Unit ) { @@ -216,7 +219,7 @@ fun SlidingCarousel( } ) { index -> feed.value.getOrNull(index)?.let { note -> - LoadedVideoCompose(note, accountViewModel, nav) + LoadedVideoCompose(note, showHidden, accountViewModel, nav) } } } @@ -224,6 +227,7 @@ fun SlidingCarousel( @Composable fun LoadedVideoCompose( note: Note, + showHidden: Boolean, accountViewModel: AccountViewModel, nav: (String) -> Unit ) { @@ -233,17 +237,19 @@ fun LoadedVideoCompose( ) } - val scope = rememberCoroutineScope() + if (!showHidden) { + val scope = rememberCoroutineScope() - WatchForReports(note, accountViewModel) { newState -> - if (state != newState) { - scope.launch(Dispatchers.Main) { - state = newState + WatchForReports(note, accountViewModel) { newState -> + if (state != newState) { + scope.launch(Dispatchers.Main) { + state = newState + } } } } - Crossfade(targetState = state) { + Crossfade(targetState = state, label = "LoadedVideoCompose") { RenderReportState( it, note, @@ -262,7 +268,7 @@ fun RenderReportState( ) { var showReportedNote by remember { mutableStateOf(false) } - Crossfade(targetState = !state.isAcceptable && !showReportedNote) { showHiddenNote -> + Crossfade(targetState = (!state.isAcceptable || state.isHiddenAuthor) && !showReportedNote) { showHiddenNote -> if (showHiddenNote) { Column(remember { Modifier.fillMaxSize() }, verticalArrangement = Arrangement.Center) { HiddenNote( diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b774b9547..a7371d7b1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -6,7 +6,7 @@ Profile Image Scan QR Show Anyway - Post was reported by + Post was muted or reported by Event is loading or can\'t be found in your relay list Channel Image Referenced event not found diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/events/GeneralListEvent.kt b/quartz/src/main/java/com/vitorpamplona/quartz/events/GeneralListEvent.kt index e60eb67d6..ea2797d62 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/events/GeneralListEvent.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/events/GeneralListEvent.kt @@ -58,7 +58,10 @@ abstract class GeneralListEvent( } fun privateTags(signer: NostrSigner, onReady: (Array>) -> Unit) { - if (content.isBlank()) return + if (content.isEmpty()) { + onReady(emptyArray()) + return + } privateTagsCache?.let { onReady(it)