No need to remember simple state.

pull/732/head
Vitor Pamplona 2023-12-23 17:28:04 -05:00
rodzic 560c1f797c
commit 5a2e149fa0
2 zmienionych plików z 7 dodań i 21 usunięć

Wyświetl plik

@ -2645,19 +2645,8 @@ private fun BadgeBox(
accountViewModel: AccountViewModel,
nav: (String) -> Unit
) {
val isRepost by remember(baseNote) {
derivedStateOf {
baseNote.event is RepostEvent || baseNote.event is GenericRepostEvent
}
}
if (isRepost) {
val baseReply by remember(baseNote) {
derivedStateOf {
baseNote.replyTo?.lastOrNull()
}
}
baseReply?.let {
if (baseNote.event is RepostEvent || baseNote.event is GenericRepostEvent) {
baseNote.replyTo?.lastOrNull()?.let {
RelayBadges(it, accountViewModel, nav)
}
} else {

Wyświetl plik

@ -139,19 +139,13 @@ fun UserPicture(
accountViewModel: AccountViewModel,
nav: (String) -> Unit
) {
val route by remember(user) {
derivedStateOf {
"User/${user.pubkeyHex}"
}
}
ClickableUserPicture(
baseUser = user,
size = size,
accountViewModel = accountViewModel,
modifier = pictureModifier,
onClick = {
nav(route)
nav("User/${user.pubkeyHex}")
}
)
}
@ -365,7 +359,10 @@ fun WatchUserFollows(userHex: String, accountViewModel: AccountViewModel, onFoll
accountViewModel.userFollows.map {
it.user.isFollowingCached(userHex) || (userHex == accountViewModel.account.userProfile().pubkeyHex)
}.distinctUntilChanged()
}.observeAsState(false)
}.observeAsState(
accountViewModel.account.userProfile().isFollowingCached(userHex) ||
(userHex == accountViewModel.account.userProfile().pubkeyHex)
)
onFollowChanges(showFollowingMark)
}