Avoids double request to show anyway when the user has hidden a post and ALSO the user's followers have reported the post.

This commit is contained in:
Vitor Pamplona
2024-03-19 10:06:53 -04:00
parent 6ab5488852
commit 9858d98722
@@ -266,10 +266,8 @@ fun CheckHiddenNoteCompose(
// Ignores reports as well // Ignores reports as well
normalNote(true) normalNote(true)
} else { } else {
WatchIsHidden(note, showHiddenWarning, accountViewModel) { WatchIsHidden(note, showHiddenWarning, modifier, accountViewModel, nav) { canPreview ->
LoadReportsNoteCompose(note, modifier, accountViewModel, nav) { canPreview -> normalNote(canPreview)
normalNote(canPreview)
}
} }
} }
} }
@@ -278,10 +276,12 @@ fun CheckHiddenNoteCompose(
fun WatchIsHidden( fun WatchIsHidden(
note: Note, note: Note,
showHiddenWarning: Boolean, showHiddenWarning: Boolean,
modifier: Modifier = Modifier,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
notHiddenNote: @Composable () -> Unit, nav: (String) -> Unit,
normalNote: @Composable (canPreview: Boolean) -> Unit,
) { ) {
val isHidden by remember(note) { val isHiddenState by remember(note) {
accountViewModel.account.liveHiddenUsers accountViewModel.account.liveHiddenUsers
.map { note.isHiddenFor(it) } .map { note.isHiddenFor(it) }
.distinctUntilChanged() .distinctUntilChanged()
@@ -293,9 +293,13 @@ fun WatchIsHidden(
mutableStateOf(false) mutableStateOf(false)
} }
Crossfade(targetState = isHidden, label = "CheckHiddenNoteCompose") { Crossfade(targetState = isHiddenState, label = "CheckHiddenNoteCompose") { isHidden ->
if (!it || showAnyway.value) { if (showAnyway.value) {
notHiddenNote() normalNote(true)
} else if (!isHidden) {
LoadReportsNoteCompose(note, modifier, accountViewModel, nav) { canPreview ->
normalNote(canPreview)
}
} else if (showHiddenWarning) { } else if (showHiddenWarning) {
// if it is a quoted or boosted note, how the hidden warning. // if it is a quoted or boosted note, how the hidden warning.
HiddenNoteByMe( HiddenNoteByMe(