Fix play console crash reports.

This commit is contained in:
Sagar
2025-03-31 20:40:49 +05:30
committed by Greyson Parrelli
parent 63c00e638d
commit 02ee1c794b
7 changed files with 166 additions and 152 deletions

View File

@@ -8,7 +8,6 @@ package org.thoughtcrime.securesms.banner
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.platform.ComposeView
@@ -37,18 +36,16 @@ class BannerManager @JvmOverloads constructor(
* Re-evaluates the [Banner]s, choosing one to render (if any) and updating the view.
*/
fun updateContent(composeView: ComposeView) {
val banner: Banner<Any>? = banners.firstOrNull { it.enabled } as Banner<Any>?
composeView.apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
val banner: Banner<Any>? = banners.firstOrNull { it.enabled } as Banner<Any>?
if (banner == null) {
onNoBannerShownListener()
return@setContent
}
val state: State<Any?> = banner.dataFlow.collectAsStateWithLifecycle(initialValue = null)
val bannerState by state
val bannerState by banner.dataFlow.collectAsStateWithLifecycle(initialValue = null)
bannerState?.let { model ->
SignalTheme {