Only calculates follows when needed.

This commit is contained in:
Vitor Pamplona
2023-04-07 17:44:40 -04:00
parent b01df2b38e
commit 42b89f438b
2 changed files with 4 additions and 3 deletions

View File

@@ -109,8 +109,6 @@ fun NoteQuickActionMenu(note: Note, popupExpanded: Boolean, onDismiss: () -> Uni
var showDeleteAlertDialog by remember { mutableStateOf(false) } var showDeleteAlertDialog by remember { mutableStateOf(false) }
var showBlockAlertDialog by remember { mutableStateOf(false) } var showBlockAlertDialog by remember { mutableStateOf(false) }
var showReportDialog by remember { mutableStateOf(false) } var showReportDialog by remember { mutableStateOf(false) }
val isOwnNote = accountViewModel.isLoggedUser(note.author)
val isFollowingUser = !isOwnNote && accountViewModel.isFollowing(note.author!!)
val backgroundColor = if (MaterialTheme.colors.isLight) { val backgroundColor = if (MaterialTheme.colors.isLight) {
MaterialTheme.colors.primary MaterialTheme.colors.primary
@@ -129,6 +127,9 @@ fun NoteQuickActionMenu(note: Note, popupExpanded: Boolean, onDismiss: () -> Uni
} }
if (popupExpanded) { if (popupExpanded) {
val isOwnNote = accountViewModel.isLoggedUser(note.author)
val isFollowingUser = !isOwnNote && accountViewModel.isFollowing(note.author!!)
Popup(onDismissRequest = onDismiss) { Popup(onDismissRequest = onDismiss) {
Card( Card(
modifier = Modifier.shadow(elevation = 6.dp, shape = cardShape), modifier = Modifier.shadow(elevation = 6.dp, shape = cardShape),

View File

@@ -170,7 +170,7 @@ class AccountViewModel(private val account: Account) : ViewModel() {
} }
fun isLoggedUser(user: User?): Boolean { fun isLoggedUser(user: User?): Boolean {
return account.userProfile() == user return account.userProfile() === user
} }
fun isFollowing(user: User?): Boolean { fun isFollowing(user: User?): Boolean {