From b88ab06154c52c8434f5ec92ce5276df23461a00 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Fri, 16 Feb 2024 15:48:54 -0500 Subject: [PATCH] Counts quotes as retweets in the notification stats bar --- .../amethyst/ui/note/UserReactionsRow.kt | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserReactionsRow.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserReactionsRow.kt index e0f79881f..5358eab70 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserReactionsRow.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserReactionsRow.kt @@ -68,11 +68,11 @@ import com.vitorpamplona.amethyst.ui.theme.Size24Modifier import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer import com.vitorpamplona.amethyst.ui.theme.placeholderText import com.vitorpamplona.quartz.encoders.HexKey +import com.vitorpamplona.quartz.events.BaseTextNoteEvent import com.vitorpamplona.quartz.events.GenericRepostEvent import com.vitorpamplona.quartz.events.LnZapEvent import com.vitorpamplona.quartz.events.ReactionEvent import com.vitorpamplona.quartz.events.RepostEvent -import com.vitorpamplona.quartz.events.TextNoteEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableStateFlow @@ -256,10 +256,19 @@ class UserReactionsViewModel(val account: Account) : ViewModel() { (zaps[netDate] ?: BigDecimal.ZERO) + (noteEvent.amount ?: BigDecimal.ZERO) takenIntoAccount.add(noteEvent.id()) } - } else if (noteEvent is TextNoteEvent) { + } else if (noteEvent is BaseTextNoteEvent) { if (noteEvent.isTaggedUser(currentUser) && noteEvent.pubKey != currentUser) { + val isCitation = + noteEvent.findCitations().any { + LocalCache.getNoteIfExists(it)?.author?.pubkeyHex == currentUser + } + val netDate = formatDate(noteEvent.createdAt) - replies[netDate] = (replies[netDate] ?: 0) + 1 + if (isCitation) { + boosts[netDate] = (boosts[netDate] ?: 0) + 1 + } else { + replies[netDate] = (replies[netDate] ?: 0) + 1 + } takenIntoAccount.add(noteEvent.id()) } } @@ -315,10 +324,19 @@ class UserReactionsViewModel(val account: Account) : ViewModel() { takenIntoAccount.add(noteEvent.id()) hasNewElements = true } - } else if (noteEvent is TextNoteEvent) { + } else if (noteEvent is BaseTextNoteEvent) { if (noteEvent.isTaggedUser(currentUser) && noteEvent.pubKey != currentUser) { + val isCitation = + noteEvent.findCitations().any { + LocalCache.getNoteIfExists(it)?.author?.pubkeyHex == currentUser + } + val netDate = formatDate(noteEvent.createdAt) - replies[netDate] = (replies[netDate] ?: 0) + 1 + if (isCitation) { + boosts[netDate] = (boosts[netDate] ?: 0) + 1 + } else { + replies[netDate] = (replies[netDate] ?: 0) + 1 + } takenIntoAccount.add(noteEvent.id()) hasNewElements = true }