Ignores unloaded notes in the MultiComposeSet renderer.
This commit is contained in:
@@ -63,20 +63,14 @@ import kotlinx.coroutines.launch
|
|||||||
fun MultiSetCompose(multiSetCard: MultiSetCard, routeForLastRead: String, accountViewModel: AccountViewModel, nav: (String) -> Unit) {
|
fun MultiSetCompose(multiSetCard: MultiSetCard, routeForLastRead: String, accountViewModel: AccountViewModel, nav: (String) -> Unit) {
|
||||||
val baseNote = remember { multiSetCard.note }
|
val baseNote = remember { multiSetCard.note }
|
||||||
|
|
||||||
val noteState by baseNote.live().metadata.observeAsState()
|
|
||||||
val note = remember(noteState) { noteState?.note } ?: return
|
|
||||||
|
|
||||||
var popupExpanded by remember { mutableStateOf(false) }
|
var popupExpanded by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
if (note.event == null) {
|
|
||||||
BlankNote(Modifier, false)
|
|
||||||
} else {
|
|
||||||
var isNew by remember { mutableStateOf(false) }
|
var isNew by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
LaunchedEffect(key1 = multiSetCard.createdAt()) {
|
LaunchedEffect(key1 = multiSetCard.createdAt()) {
|
||||||
scope.launch(Dispatchers.IO) {
|
launch(Dispatchers.IO) {
|
||||||
val newIsNew = multiSetCard.maxCreatedAt > NotificationCache.load(routeForLastRead)
|
val newIsNew = multiSetCard.maxCreatedAt > NotificationCache.load(routeForLastRead)
|
||||||
|
|
||||||
NotificationCache.markAsRead(routeForLastRead, multiSetCard.maxCreatedAt)
|
NotificationCache.markAsRead(routeForLastRead, multiSetCard.maxCreatedAt)
|
||||||
@@ -147,8 +141,7 @@ fun MultiSetCompose(multiSetCard: MultiSetCard, routeForLastRead: String, accoun
|
|||||||
nav = nav
|
nav = nav
|
||||||
)
|
)
|
||||||
|
|
||||||
NoteDropDownMenu(note, popupExpanded, { popupExpanded = false }, accountViewModel)
|
NoteDropDownMenu(baseNote, popupExpanded, { popupExpanded = false }, accountViewModel)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,10 +91,9 @@ private fun WatchZapsAndUpdateTallies(
|
|||||||
pollViewModel: PollNoteViewModel
|
pollViewModel: PollNoteViewModel
|
||||||
) {
|
) {
|
||||||
val zapsState by baseNote.live().zaps.observeAsState()
|
val zapsState by baseNote.live().zaps.observeAsState()
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
|
|
||||||
LaunchedEffect(key1 = zapsState) {
|
LaunchedEffect(key1 = zapsState) {
|
||||||
scope.launch(Dispatchers.IO) {
|
launch(Dispatchers.Default) {
|
||||||
pollViewModel.refreshTallies()
|
pollViewModel.refreshTallies()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -520,7 +520,7 @@ private fun ZapIcon(
|
|||||||
val zapsState by baseNote.live().zaps.observeAsState()
|
val zapsState by baseNote.live().zaps.observeAsState()
|
||||||
|
|
||||||
LaunchedEffect(key1 = zapsState) {
|
LaunchedEffect(key1 = zapsState) {
|
||||||
launch(Dispatchers.IO) {
|
launch(Dispatchers.Default) {
|
||||||
zapsState?.note?.let {
|
zapsState?.note?.let {
|
||||||
if (!wasZappedByLoggedInUser) {
|
if (!wasZappedByLoggedInUser) {
|
||||||
val newWasZapped = accountViewModel.calculateIfNoteWasZappedByAccount(it)
|
val newWasZapped = accountViewModel.calculateIfNoteWasZappedByAccount(it)
|
||||||
@@ -561,7 +561,7 @@ private fun ZapAmountText(
|
|||||||
var zapAmountTxt by remember { mutableStateOf("") }
|
var zapAmountTxt by remember { mutableStateOf("") }
|
||||||
|
|
||||||
LaunchedEffect(key1 = zapsState) {
|
LaunchedEffect(key1 = zapsState) {
|
||||||
launch(Dispatchers.IO) {
|
launch(Dispatchers.Default) {
|
||||||
zapsState?.note?.let {
|
zapsState?.note?.let {
|
||||||
val newZapAmount = showAmount(accountViewModel.calculateZapAmount(it))
|
val newZapAmount = showAmount(accountViewModel.calculateZapAmount(it))
|
||||||
if (newZapAmount != zapAmountTxt) {
|
if (newZapAmount != zapAmountTxt) {
|
||||||
|
|||||||
@@ -153,10 +153,18 @@ fun UserActionOptions(
|
|||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
|
|
||||||
val accountState by accountViewModel.accountLiveData.observeAsState()
|
val accountState by accountViewModel.accountLiveData.observeAsState()
|
||||||
val isHidden = remember(accountState) { accountState?.account?.isHidden(baseAuthor) } ?: return
|
val isHidden by remember(accountState) {
|
||||||
|
derivedStateOf {
|
||||||
|
accountState?.account?.isHidden(baseAuthor) ?: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val userState by accountViewModel.account.userProfile().live().follows.observeAsState()
|
val userState by accountViewModel.account.userProfile().live().follows.observeAsState()
|
||||||
val isFollowing = remember(userState) { userState?.user?.isFollowingCached(baseAuthor) } ?: return
|
val isFollowing by remember(userState) {
|
||||||
|
derivedStateOf {
|
||||||
|
userState?.user?.isFollowingCached(baseAuthor) ?: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isHidden) {
|
if (isHidden) {
|
||||||
ShowUserButton {
|
ShowUserButton {
|
||||||
|
|||||||
Reference in New Issue
Block a user