BugFix for marking chat as read

pull/549/head
Vitor Pamplona 2023-08-12 13:50:40 -04:00
rodzic c8172265dd
commit cb7b51e8d1
2 zmienionych plików z 6 dodań i 26 usunięć

Wyświetl plik

@ -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")
}
}
}

Wyświetl plik

@ -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