From 824cb4e5f16a0e71dc16e5d49985dd26cd04f74e Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Thu, 26 Sep 2024 11:36:52 -0400 Subject: [PATCH] @Suppress("ProduceStateDoesNotAssignValue") until we figure out what's wrong with this lint. --- .../vitorpamplona/amethyst/ui/components/CashuRedeem.kt | 1 + .../amethyst/ui/components/InvoicePreview.kt | 9 ++++----- .../amethyst/ui/components/LoadUrlPreview.kt | 1 + .../amethyst/ui/navigation/AccountSwitchBottomSheet.kt | 1 + .../java/com/vitorpamplona/amethyst/ui/note/Loaders.kt | 1 + .../vitorpamplona/amethyst/ui/note/MultiSetCompose.kt | 1 + .../com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt | 2 ++ .../com/vitorpamplona/amethyst/ui/note/RelayListRow.kt | 1 + .../amethyst/ui/note/elements/DisplayUncitedHashtags.kt | 1 + .../vitorpamplona/amethyst/ui/note/types/MedicalData.kt | 1 + .../screen/loggedIn/chatrooms/ChatroomMessageCompose.kt | 1 + .../amethyst/commons/compose/AsyncCachedState.kt | 2 ++ .../amethyst/commons/compose/CachedState.kt | 2 ++ 13 files changed, 19 insertions(+), 5 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt index 89f9e7fb2..5123cbc39 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt @@ -85,6 +85,7 @@ fun CashuPreview( cashutoken: String, accountViewModel: AccountViewModel, ) { + @Suppress("ProduceStateDoesNotAssignValue") val cashuData by produceState( initialValue = CachedCashuProcessor.cached(cashutoken), key1 = cashutoken, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/InvoicePreview.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/InvoicePreview.kt index bacc64738..149d8f664 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/InvoicePreview.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/InvoicePreview.kt @@ -69,13 +69,12 @@ fun LoadValueFromInvoice( lnbcWord: String, inner: @Composable (invoiceAmount: InvoiceAmount?) -> Unit, ) { + @Suppress("ProduceStateDoesNotAssignValue") val lnInvoice by produceState(initialValue = CachedLnInvoiceParser.cached(lnbcWord), key1 = lnbcWord) { - withContext(Dispatchers.IO) { - val newLnInvoice = CachedLnInvoiceParser.parse(lnbcWord) - if (value != newLnInvoice) { - value = newLnInvoice - } + val newLnInvoice = withContext(Dispatchers.Default) { CachedLnInvoiceParser.parse(lnbcWord) } + if (value != newLnInvoice) { + value = newLnInvoice } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/LoadUrlPreview.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/LoadUrlPreview.kt index 7ef2508c6..f1105390f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/LoadUrlPreview.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/LoadUrlPreview.kt @@ -41,6 +41,7 @@ fun LoadUrlPreview( if (!accountViewModel.settings.showUrlPreview.value) { ClickableUrl(urlText, url) } else { + @Suppress("ProduceStateDoesNotAssignValue") val urlPreviewState by produceState( initialValue = UrlCachedPreviewer.cache.get(url) ?: UrlPreviewState.Loading, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AccountSwitchBottomSheet.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AccountSwitchBottomSheet.kt index 2c5d85181..fdf671472 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AccountSwitchBottomSheet.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AccountSwitchBottomSheet.kt @@ -81,6 +81,7 @@ fun AccountSwitchBottomSheet( accountViewModel: AccountViewModel, accountStateViewModel: AccountStateViewModel, ) { + @Suppress("ProduceStateDoesNotAssignValue") val accounts by produceState(initialValue = LocalPreferences.cachedAccounts()) { if (value == null) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/Loaders.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/Loaders.kt index 585c9c815..8cc0d2c7e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/Loaders.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/Loaders.kt @@ -73,6 +73,7 @@ fun LoadDecryptedContentOrNull( accountViewModel: AccountViewModel, inner: @Composable (String?) -> Unit, ) { + @Suppress("ProduceStateDoesNotAssignValue") val decryptedContent by produceState(initialValue = accountViewModel.cachedDecrypt(note), key1 = note.event?.id()) { accountViewModel.decrypt(note) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt index e6f01164b..8ca2c1770 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt @@ -229,6 +229,7 @@ fun DecryptAndRenderZapGallery( accountViewModel: AccountViewModel, nav: INav, ) { + @Suppress("ProduceStateDoesNotAssignValue") val zapEvents by produceState(initialValue = accountViewModel.cachedDecryptAmountMessageInGroup(multiSetCard.zapEvents)) { accountViewModel.decryptAmountMessageInGroup(multiSetCard.zapEvents) { value = it } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt index d49eb73d5..45fc0e3a5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt @@ -892,6 +892,7 @@ fun ObserveLikeIcon( ) { val reactionsState by baseNote.live().reactions.observeAsState() + @Suppress("ProduceStateDoesNotAssignValue") val reactionType by produceState(initialValue = null as String?, key1 = reactionsState) { val newReactionType = accountViewModel.loadReactionTo(reactionsState?.note) @@ -1226,6 +1227,7 @@ fun ObserveZapAmountText( val zapsState by baseNote.live().zaps.observeAsState() if (zapsState?.note?.zapPayments?.isNotEmpty() == true) { + @Suppress("ProduceStateDoesNotAssignValue") val zapAmountTxt by produceState(initialValue = showAmount(baseNote.zapsAmount), key1 = zapsState) { zapsState?.note?.let { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListRow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListRow.kt index 56100bb34..57209e901 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListRow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListRow.kt @@ -122,6 +122,7 @@ fun RenderRelay( accountViewModel: AccountViewModel, nav: INav, ) { + @Suppress("ProduceStateDoesNotAssignValue") val relayInfo by produceState( initialValue = Nip11CachedRetriever.getFromCache(relay.url), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayUncitedHashtags.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayUncitedHashtags.kt index 919ed7a71..113cf5ced 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayUncitedHashtags.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayUncitedHashtags.kt @@ -57,6 +57,7 @@ fun DisplayUncitedHashtags( callbackUri: String? = null, nav: INav, ) { + @Suppress("ProduceStateDoesNotAssignValue") val unusedHashtags by produceState(initialValue = emptyList()) { val tagsInEvent = event.hashtags() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/MedicalData.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/MedicalData.kt index e15d4c229..45d1cbc8d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/MedicalData.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/MedicalData.kt @@ -87,6 +87,7 @@ fun RenderFhirResource( @Composable fun RenderFhirResource(event: FhirResourceEvent) { + @Suppress("ProduceStateDoesNotAssignValue") val state by produceState(initialValue = FhirElementDatabase(), key1 = event) { withContext(Dispatchers.Default) { parseResourceBundleOrNull(event.content)?.let { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chatrooms/ChatroomMessageCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chatrooms/ChatroomMessageCompose.kt index efbaf2c6b..99a8dbf4b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chatrooms/ChatroomMessageCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chatrooms/ChatroomMessageCompose.kt @@ -532,6 +532,7 @@ private fun RenderReply( onWantsToEditDraft: (Note) -> Unit, ) { Row(verticalAlignment = Alignment.CenterVertically) { + @Suppress("ProduceStateDoesNotAssignValue") val replyTo = produceState(initialValue = note.replyTo?.lastOrNull()) { accountViewModel.unwrapIfNeeded(value) { diff --git a/commons/src/main/java/com/vitorpamplona/amethyst/commons/compose/AsyncCachedState.kt b/commons/src/main/java/com/vitorpamplona/amethyst/commons/compose/AsyncCachedState.kt index 7d1504e68..276d7d1c5 100644 --- a/commons/src/main/java/com/vitorpamplona/amethyst/commons/compose/AsyncCachedState.kt +++ b/commons/src/main/java/com/vitorpamplona/amethyst/commons/compose/AsyncCachedState.kt @@ -30,6 +30,7 @@ fun produceCachedStateAsync( cache: AsyncCachedState, key: K, ): State = + @Suppress("ProduceStateDoesNotAssignValue") produceState(initialValue = cache.cached(key), key1 = key) { cache.update(key) { value = it @@ -42,6 +43,7 @@ fun produceCachedStateAsync( key: String, updateValue: K, ): State = + @Suppress("ProduceStateDoesNotAssignValue") produceState(initialValue = cache.cached(updateValue), key1 = key) { cache.update(updateValue) { value = it diff --git a/commons/src/main/java/com/vitorpamplona/amethyst/commons/compose/CachedState.kt b/commons/src/main/java/com/vitorpamplona/amethyst/commons/compose/CachedState.kt index f8ae3a298..701faf2ed 100644 --- a/commons/src/main/java/com/vitorpamplona/amethyst/commons/compose/CachedState.kt +++ b/commons/src/main/java/com/vitorpamplona/amethyst/commons/compose/CachedState.kt @@ -30,6 +30,7 @@ fun produceCachedState( cache: CachedState, key: K, ): State = + @Suppress("ProduceStateDoesNotAssignValue") produceState(initialValue = cache.cached(key), key1 = key) { val newValue = cache.update(key) if (value != newValue) { @@ -43,6 +44,7 @@ fun produceCachedState( key: String, updateValue: K, ): State = + @Suppress("ProduceStateDoesNotAssignValue") produceState(initialValue = cache.cached(updateValue), key1 = key) { val newValue = cache.update(updateValue) if (value != newValue) {