Fixes blocked lists on Videos.

This commit is contained in:
Vitor Pamplona 2023-11-30 17:18:41 -05:00
parent e9ec1c45a0
commit efb9814f1b
5 changed files with 35 additions and 20 deletions

View File

@ -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()

View File

@ -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)
}
}

View File

@ -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<ImmutableList<Note>>,
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(

View File

@ -6,7 +6,7 @@
<string name="profile_image">Profile Image</string>
<string name="scan_qr">Scan QR</string>
<string name="show_anyway">Show Anyway</string>
<string name="post_was_flagged_as_inappropriate_by">Post was reported by</string>
<string name="post_was_flagged_as_inappropriate_by">Post was muted or reported by</string>
<string name="post_not_found">Event is loading or can\'t be found in your relay list</string>
<string name="channel_image">Channel Image</string>
<string name="referenced_event_not_found">Referenced event not found</string>

View File

@ -58,7 +58,10 @@ abstract class GeneralListEvent(
}
fun privateTags(signer: NostrSigner, onReady: (Array<Array<String>>) -> Unit) {
if (content.isBlank()) return
if (content.isEmpty()) {
onReady(emptyArray())
return
}
privateTagsCache?.let {
onReady(it)