mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-04 18:24:34 +02:00
Moves isAcceptableNote calculations to viewModel
This commit is contained in:
@@ -441,10 +441,8 @@ fun WatchForReports(
|
|||||||
val noteReportsState by note.live().reports.observeAsState()
|
val noteReportsState by note.live().reports.observeAsState()
|
||||||
|
|
||||||
LaunchedEffect(key1 = noteReportsState, key2 = userFollowsState) {
|
LaunchedEffect(key1 = noteReportsState, key2 = userFollowsState) {
|
||||||
launch(Dispatchers.Default) {
|
|
||||||
accountViewModel.isNoteAcceptable(note, onChange)
|
accountViewModel.isNoteAcceptable(note, onChange)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@@ -411,6 +411,7 @@ class AccountViewModel(val account: Account) : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun isNoteAcceptable(note: Note, onReady: (Boolean, Boolean, ImmutableSet<Note>) -> Unit) {
|
fun isNoteAcceptable(note: Note, onReady: (Boolean, Boolean, ImmutableSet<Note>) -> Unit) {
|
||||||
|
viewModelScope.launch {
|
||||||
val isFromLoggedIn = note.author?.pubkeyHex == userProfile().pubkeyHex
|
val isFromLoggedIn = note.author?.pubkeyHex == userProfile().pubkeyHex
|
||||||
val isFromLoggedInFollow = note.author?.let { userProfile().isFollowingCached(it) } ?: true
|
val isFromLoggedInFollow = note.author?.let { userProfile().isFollowingCached(it) } ?: true
|
||||||
|
|
||||||
@@ -432,6 +433,7 @@ class AccountViewModel(val account: Account) : ViewModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun unwrap(event: GiftWrapEvent): Event? {
|
fun unwrap(event: GiftWrapEvent): Event? {
|
||||||
return account.unwrap(event)
|
return account.unwrap(event)
|
||||||
|
Reference in New Issue
Block a user