diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index 1e4ff2904..5e6338614 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -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 { 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