diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt index 74d0f89a1..618191e81 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt @@ -176,7 +176,9 @@ private fun Galeries( if (hasZapEvents) { var zapEvents by remember(multiSetCard.zapEvents) { - mutableStateOf>(persistentListOf()) + mutableStateOf( + accountViewModel.cachedDecryptAmountMessageInGroup(multiSetCard.zapEvents) + ) } LaunchedEffect(key1 = Unit) { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt index 83db96829..0751acbb9 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt @@ -453,7 +453,7 @@ private fun WatchZapAndRenderGallery( val zapsState by baseNote.live().zaps.observeAsState() var zapEvents by remember(zapsState) { - mutableStateOf>( + mutableStateOf( accountViewModel.cachedDecryptAmountMessageInGroup(baseNote) ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index dad98ede9..4830f9585 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -248,6 +248,34 @@ class AccountViewModel(val account: Account, val settings: SettingsState) : View } } + fun cachedDecryptAmountMessageInGroup(zapNotes: List): ImmutableList { + return zapNotes.map { + val request = it.request.event as? LnZapRequestEvent + if (request?.isPrivateZap() == true) { + val cachedPrivateRequest = request.cachedPrivateZap() + if (cachedPrivateRequest != null) { + ZapAmountCommentNotification( + LocalCache.getUserIfExists(cachedPrivateRequest.pubKey) ?: it.request.author, + cachedPrivateRequest.content.ifBlank { null }, + showAmountAxis((it.response.event as? LnZapEvent)?.amount) + ) + } else { + ZapAmountCommentNotification( + it.request.author, + it.request.event?.content()?.ifBlank { null }, + showAmountAxis((it.response.event as? LnZapEvent)?.amount) + ) + } + } else { + ZapAmountCommentNotification( + it.request.author, + it.request.event?.content()?.ifBlank { null }, + showAmountAxis((it.response.event as? LnZapEvent)?.amount) + ) + } + }.toImmutableList() + } + fun cachedDecryptAmountMessageInGroup(baseNote: Note): ImmutableList { val myList = baseNote.zaps.toList() diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt index fd0725d0f..fc0f6ef5a 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt @@ -84,7 +84,6 @@ import com.vitorpamplona.amethyst.ui.screen.NostrHomeRepliesFeedViewModel import com.vitorpamplona.amethyst.ui.screen.NostrVideoFeedViewModel import com.vitorpamplona.amethyst.ui.screen.NotificationViewModel import com.vitorpamplona.amethyst.ui.screen.SharedPreferencesViewModel -import com.vitorpamplona.amethyst.ui.theme.Size55Modifier import kotlinx.coroutines.launch import kotlin.math.abs