From cb7b51e8d1d9c353675242b05561c722ccd99dc7 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Sat, 12 Aug 2023 13:50:40 -0400 Subject: [PATCH] BugFix for marking chat as read --- .../amethyst/ui/note/ChatroomHeaderCompose.kt | 10 ++++----- .../ui/screen/ChatroomListFeedView.kt | 22 +------------------ 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomHeaderCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomHeaderCompose.kt index 3896ea550..15751756e 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomHeaderCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomHeaderCompose.kt @@ -198,7 +198,7 @@ private fun ChannelRoomCompose( channelIdHex = chanHex, channelPicture = channelPicture, channelTitle = { modifier -> - ChannelTitleWithBoostInfo(channelName, modifier) + ChannelTitleWithLabelInfo(channelName, modifier) }, channelLastTime = remember(note) { note.createdAt() }, channelLastContent = remember(note) { "$authorName: $description" }, @@ -208,10 +208,10 @@ private fun ChannelRoomCompose( } @Composable -private fun ChannelTitleWithBoostInfo(channelName: String, modifier: Modifier) { - val boosted = stringResource(id = R.string.public_chat) +private fun ChannelTitleWithLabelInfo(channelName: String, modifier: Modifier) { + val label = stringResource(id = R.string.public_chat) val placeHolderColor = MaterialTheme.colors.placeholderText - val channelNameAndBoostInfo = remember { + val channelNameAndBoostInfo = remember(channelName) { buildAnnotatedString { withStyle( SpanStyle( @@ -227,7 +227,7 @@ private fun ChannelTitleWithBoostInfo(channelName: String, modifier: Modifier) { fontWeight = FontWeight.Normal ) ) { - append(" $boosted") + append(" $label") } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ChatroomListFeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ChatroomListFeedView.kt index 80c425daa..4c7cd1bb0 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ChatroomListFeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ChatroomListFeedView.kt @@ -17,12 +17,8 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.service.model.ChatroomKeyable -import com.vitorpamplona.amethyst.service.model.GiftWrapEvent -import com.vitorpamplona.amethyst.service.model.SealedGossipEvent import com.vitorpamplona.amethyst.ui.note.ChatroomHeaderCompose import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext import kotlin.time.ExperimentalTime import kotlin.time.measureTimedValue @@ -88,28 +84,12 @@ private fun FeedLoaded( LaunchedEffect(key1 = markAsRead.value) { if (markAsRead.value) { for (note in state.feed.value) { - var myEvent = if (note.event is GiftWrapEvent) { - val unwrapped = accountViewModel.unwrap(note.event as GiftWrapEvent) - if (unwrapped is SealedGossipEvent) { - accountViewModel.unseal(unwrapped) - } else { - unwrapped - } - } else { - note.event - } - - myEvent?.let { noteEvent -> + note.event?.let { noteEvent -> val channelHex = note.channelHex() val route = if (channelHex != null) { "Channel/$channelHex" } else if (note.event is ChatroomKeyable) { val withKey = (note.event as ChatroomKeyable).chatroomKey(accountViewModel.userProfile().pubkeyHex) - - withContext(Dispatchers.IO) { - accountViewModel.userProfile().createChatroom(withKey) - } - "Room/${withKey.hashCode()}" } else { null