Modifies the behavior of new posts to clear the background color after 5 seconds

This commit is contained in:
Vitor Pamplona
2025-05-13 17:21:22 -04:00
parent dba51acbd5
commit f3e2327676
@@ -205,6 +205,7 @@ import com.vitorpamplona.quartz.nip90Dvms.NIP90ContentDiscoveryResponseEvent
import com.vitorpamplona.quartz.nip90Dvms.NIP90StatusEvent
import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent
import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent
import kotlinx.coroutines.delay
@Composable
fun NoteCompose(
@@ -363,25 +364,33 @@ fun calculateBackgroundColor(
): MutableState<Color> {
val defaultBackgroundColor = MaterialTheme.colorScheme.background
val newItemColor = MaterialTheme.colorScheme.newItemBackgroundColor
return remember(createdAt) {
mutableStateOf(
if (routeForLastRead != null) {
val isNew = accountViewModel.loadAndMarkAsRead(routeForLastRead, createdAt)
val bgColor =
remember(createdAt) {
mutableStateOf(
if (routeForLastRead != null) {
val isNew = accountViewModel.loadAndMarkAsRead(routeForLastRead, createdAt)
if (isNew) {
if (parentBackgroundColor != null) {
newItemColor.compositeOver(parentBackgroundColor.value)
if (isNew) {
if (parentBackgroundColor != null) {
newItemColor.compositeOver(parentBackgroundColor.value)
} else {
newItemColor.compositeOver(defaultBackgroundColor)
}
} else {
newItemColor.compositeOver(defaultBackgroundColor)
parentBackgroundColor?.value ?: Color.Transparent
}
} else {
parentBackgroundColor?.value ?: Color.Transparent
}
} else {
parentBackgroundColor?.value ?: Color.Transparent
},
)
},
)
}
LaunchedEffect(createdAt) {
delay(5000)
bgColor.value = parentBackgroundColor?.value ?: Color.Transparent
}
return bgColor
}
@Composable