diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index 1c9e320bf..87c54364a 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -29,7 +29,6 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -85,6 +84,7 @@ import com.vitorpamplona.amethyst.ui.note.types.RenderAppDefinition import com.vitorpamplona.amethyst.ui.note.types.RenderAudioHeader import com.vitorpamplona.amethyst.ui.note.types.RenderAudioTrack import com.vitorpamplona.amethyst.ui.note.types.RenderBadgeAward +import com.vitorpamplona.amethyst.ui.note.types.RenderChannelMessage import com.vitorpamplona.amethyst.ui.note.types.RenderChatMessage import com.vitorpamplona.amethyst.ui.note.types.RenderClassifieds import com.vitorpamplona.amethyst.ui.note.types.RenderEmojiPack @@ -121,7 +121,6 @@ import com.vitorpamplona.amethyst.ui.theme.Size34dp import com.vitorpamplona.amethyst.ui.theme.Size55Modifier import com.vitorpamplona.amethyst.ui.theme.Size55dp import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer -import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer import com.vitorpamplona.amethyst.ui.theme.UserNameMaxRowHeight import com.vitorpamplona.amethyst.ui.theme.UserNameRowHeight import com.vitorpamplona.amethyst.ui.theme.WidthAuthorPictureModifier @@ -171,8 +170,6 @@ import com.vitorpamplona.quartz.events.TextNoteModificationEvent import com.vitorpamplona.quartz.events.VideoHorizontalEvent import com.vitorpamplona.quartz.events.VideoVerticalEvent import com.vitorpamplona.quartz.events.WikiNoteEvent -import kotlinx.collections.immutable.persistentListOf -import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.launch @Composable @@ -528,16 +525,6 @@ fun NoteBody( Spacer(modifier = Modifier.height(3.dp)) } - if (!makeItShort) { - ReplyRow( - baseNote, - unPackReply, - backgroundColor, - accountViewModel, - nav, - ) - } - RenderNoteRow( baseNote = baseNote, backgroundColor = backgroundColor, @@ -545,6 +532,7 @@ fun NoteBody( canPreview = canPreview, editState = editState, quotesLeft = quotesLeft, + unPackReply = unPackReply, accountViewModel = accountViewModel, nav = nav, ) @@ -564,6 +552,7 @@ private fun RenderNoteRow( makeItShort: Boolean, canPreview: Boolean, quotesLeft: Int, + unPackReply: Boolean, editState: State>, accountViewModel: AccountViewModel, nav: (String) -> Unit, @@ -658,6 +647,7 @@ private fun RenderNoteRow( makeItShort, canPreview, quotesLeft, + unPackReply, backgroundColor, accountViewModel, nav, @@ -687,6 +677,17 @@ private fun RenderNoteRow( nav, ) } + is ChannelMessageEvent -> + RenderChannelMessage( + baseNote, + makeItShort, + canPreview, + quotesLeft, + backgroundColor, + editState, + accountViewModel, + nav, + ) is LiveActivitiesChatMessageEvent -> RenderLiveActivityChatMessage( baseNote, @@ -704,6 +705,7 @@ private fun RenderNoteRow( makeItShort, canPreview, quotesLeft, + unPackReply, backgroundColor, editState, accountViewModel, @@ -748,14 +750,6 @@ fun RenderDraft( ObserveDraftEvent(note, accountViewModel) { val edits = remember { mutableStateOf(GenericLoadable.Empty()) } - ReplyRow( - it, - true, - backgroundColor, - accountViewModel, - nav, - ) - RenderNoteRow( baseNote = it, backgroundColor = backgroundColor, @@ -763,6 +757,7 @@ fun RenderDraft( canPreview = true, editState = edits, quotesLeft = 3, + unPackReply = true, accountViewModel = accountViewModel, nav = nav, ) @@ -808,81 +803,7 @@ fun getGradient(backgroundColor: MutableState): Brush { } @Composable -private fun ReplyRow( - note: Note, - unPackReply: Boolean, - backgroundColor: MutableState, - accountViewModel: AccountViewModel, - nav: (String) -> Unit, -) { - val noteEvent = note.event - - val showReply by - remember(note) { - derivedStateOf { - noteEvent is BaseTextNoteEvent && (note.replyTo != null || noteEvent.hasAnyTaggedUser()) - } - } - - val showChannelInfo by - remember(note) { - derivedStateOf { - if (noteEvent is ChannelMessageEvent || noteEvent is LiveActivitiesChatMessageEvent) { - note.channelHex() - } else { - null - } - } - } - - showChannelInfo?.let { - ChannelHeader( - channelHex = it, - showVideo = false, - sendToChannel = true, - modifier = MaterialTheme.colorScheme.replyModifier.padding(10.dp), - accountViewModel = accountViewModel, - nav = nav, - ) - Spacer(modifier = StdVertSpacer) - } - - if (showReply) { - val replyingDirectlyTo = - remember(note) { - if (noteEvent is BaseTextNoteEvent) { - val replyingTo = noteEvent.replyingToAddressOrEvent() - if (replyingTo != null) { - val newNote = accountViewModel.getNoteIfExists(replyingTo) - if (newNote != null && newNote.channelHex() == null && newNote.event?.kind() != CommunityDefinitionEvent.KIND) { - newNote - } else { - note.replyTo?.lastOrNull { it.event?.kind() != CommunityDefinitionEvent.KIND } - } - } else { - note.replyTo?.lastOrNull { it.event?.kind() != CommunityDefinitionEvent.KIND } - } - } else { - note.replyTo?.lastOrNull { it.event?.kind() != CommunityDefinitionEvent.KIND } - } - } - if (replyingDirectlyTo != null && unPackReply) { - ReplyNoteComposition(replyingDirectlyTo, backgroundColor, accountViewModel, nav) - Spacer(modifier = StdVertSpacer) - } else if (showChannelInfo != null) { - val replies = remember { note.replyTo?.toImmutableList() } - val mentions = - remember { - (note.event as? BaseTextNoteEvent)?.mentions()?.toImmutableList() ?: persistentListOf() - } - - ReplyInformationChannel(replies, mentions, accountViewModel, nav) - } - } -} - -@Composable -private fun ReplyNoteComposition( +fun ReplyNoteComposition( replyingDirectlyTo: Note, backgroundColor: MutableState, accountViewModel: AccountViewModel, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ChannelMessage.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ChannelMessage.kt new file mode 100644 index 000000000..48e6f7626 --- /dev/null +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ChannelMessage.kt @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2024 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.ui.note.types + +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.State +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import com.vitorpamplona.amethyst.model.Note +import com.vitorpamplona.amethyst.ui.components.GenericLoadable +import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.ChannelHeader +import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer +import com.vitorpamplona.amethyst.ui.theme.replyModifier +import com.vitorpamplona.quartz.events.ChannelMessageEvent + +@Composable +fun RenderChannelMessage( + note: Note, + makeItShort: Boolean, + canPreview: Boolean, + quotesLeft: Int, + backgroundColor: MutableState, + editState: State>, + accountViewModel: AccountViewModel, + nav: (String) -> Unit, +) { + val noteEvent = note.event + val showChannelInfo = + remember(noteEvent) { + if (noteEvent is ChannelMessageEvent) { + noteEvent.channel() + } else { + null + } + } + + showChannelInfo?.let { + ChannelHeader( + channelHex = it, + showVideo = false, + sendToChannel = true, + modifier = MaterialTheme.colorScheme.replyModifier.padding(10.dp), + accountViewModel = accountViewModel, + nav = nav, + ) + Spacer(modifier = StdVertSpacer) + } + + RenderTextEvent( + note, + makeItShort, + canPreview, + quotesLeft, + unPackReply = false, + backgroundColor, + editState, + accountViewModel, + nav, + ) +} diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ChatMessage.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ChatMessage.kt index 13e3a779d..e581c7cfd 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ChatMessage.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ChatMessage.kt @@ -33,6 +33,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.ui.components.GenericLoadable +import com.vitorpamplona.amethyst.ui.navigation.routeFor import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.ChatroomHeader import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer @@ -59,7 +60,11 @@ fun RenderChatMessage( userRoom?.let { if (it.users.size > 1 || (it.users.size == 1 && note.author == accountViewModel.account.userProfile())) { - ChatroomHeader(it, MaterialTheme.colorScheme.replyModifier.padding(10.dp), accountViewModel, nav) + ChatroomHeader(it, MaterialTheme.colorScheme.replyModifier.padding(10.dp), accountViewModel) { + routeFor(note, accountViewModel.userProfile())?.let { + nav(it) + } + } Spacer(modifier = StdVertSpacer) } } @@ -69,6 +74,7 @@ fun RenderChatMessage( makeItShort, canPreview, quotesLeft, + unPackReply = false, backgroundColor, editState, accountViewModel, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/LiveActivityChatMessage.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/LiveActivityChatMessage.kt index 369fe586a..e0f3eceac 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/LiveActivityChatMessage.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/LiveActivityChatMessage.kt @@ -76,6 +76,7 @@ fun RenderLiveActivityChatMessage( makeItShort, canPreview, quotesLeft, + unPackReply = false, backgroundColor, editState, accountViewModel, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Poll.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Poll.kt index 9984ecc79..08ea6674b 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Poll.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Poll.kt @@ -20,11 +20,14 @@ */ package com.vitorpamplona.amethyst.ui.note.types +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -33,9 +36,13 @@ import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.ui.components.SensitivityWarning import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer import com.vitorpamplona.amethyst.ui.note.PollNote +import com.vitorpamplona.amethyst.ui.note.ReplyNoteComposition import com.vitorpamplona.amethyst.ui.note.elements.DisplayUncitedHashtags import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer import com.vitorpamplona.amethyst.ui.theme.placeholderText +import com.vitorpamplona.quartz.events.BaseTextNoteEvent +import com.vitorpamplona.quartz.events.CommunityDefinitionEvent import com.vitorpamplona.quartz.events.EmptyTagList import com.vitorpamplona.quartz.events.PollNoteEvent import com.vitorpamplona.quartz.events.toImmutableListOfLists @@ -47,6 +54,7 @@ fun RenderPoll( makeItShort: Boolean, canPreview: Boolean, quotesLeft: Int, + unPackReply: Boolean, backgroundColor: MutableState, accountViewModel: AccountViewModel, nav: (String) -> Unit, @@ -54,6 +62,38 @@ fun RenderPoll( val noteEvent = note.event as? PollNoteEvent ?: return val eventContent = noteEvent.content() + val showReply by + remember(note) { + derivedStateOf { + noteEvent is BaseTextNoteEvent && !makeItShort && unPackReply && (note.replyTo != null || noteEvent.hasAnyTaggedUser()) + } + } + + if (showReply) { + val replyingDirectlyTo = + remember(note) { + if (noteEvent is BaseTextNoteEvent) { + val replyingTo = noteEvent.replyingToAddressOrEvent() + if (replyingTo != null) { + val newNote = accountViewModel.getNoteIfExists(replyingTo) + if (newNote != null && newNote.channelHex() == null && newNote.event?.kind() != CommunityDefinitionEvent.KIND) { + newNote + } else { + note.replyTo?.lastOrNull { it.event?.kind() != CommunityDefinitionEvent.KIND } + } + } else { + note.replyTo?.lastOrNull { it.event?.kind() != CommunityDefinitionEvent.KIND } + } + } else { + note.replyTo?.lastOrNull { it.event?.kind() != CommunityDefinitionEvent.KIND } + } + } + if (replyingDirectlyTo != null) { + ReplyNoteComposition(replyingDirectlyTo, backgroundColor, accountViewModel, nav) + Spacer(modifier = StdVertSpacer) + } + } + if (makeItShort && accountViewModel.isLoggedUser(note.author)) { Text( text = eventContent, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PrivateMessage.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PrivateMessage.kt index 9a6088065..f6eca3d7e 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PrivateMessage.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PrivateMessage.kt @@ -39,6 +39,7 @@ import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.ui.components.SensitivityWarning import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer +import com.vitorpamplona.amethyst.ui.navigation.routeFor import com.vitorpamplona.amethyst.ui.note.LoadDecryptedContent import com.vitorpamplona.amethyst.ui.note.elements.DisplayUncitedHashtags import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @@ -75,7 +76,11 @@ fun RenderPrivateMessage( userRoom?.let { if (it.users.size > 1 || (it.users.size == 1 && note.author == accountViewModel.account.userProfile())) { - ChatroomHeader(it, MaterialTheme.colorScheme.replyModifier.padding(10.dp), accountViewModel, nav) + ChatroomHeader(it, MaterialTheme.colorScheme.replyModifier.padding(10.dp), accountViewModel) { + routeFor(note, accountViewModel.userProfile())?.let { + nav(it) + } + } Spacer(modifier = StdVertSpacer) } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Text.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Text.kt index 8cebd27f4..a5dd06d07 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Text.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Text.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.amethyst.ui.note.types +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -37,9 +38,13 @@ import com.vitorpamplona.amethyst.ui.components.GenericLoadable import com.vitorpamplona.amethyst.ui.components.SensitivityWarning import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer import com.vitorpamplona.amethyst.ui.note.LoadDecryptedContent +import com.vitorpamplona.amethyst.ui.note.ReplyNoteComposition import com.vitorpamplona.amethyst.ui.note.elements.DisplayUncitedHashtags import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer import com.vitorpamplona.amethyst.ui.theme.placeholderText +import com.vitorpamplona.quartz.events.BaseTextNoteEvent +import com.vitorpamplona.quartz.events.CommunityDefinitionEvent import com.vitorpamplona.quartz.events.EmptyTagList import com.vitorpamplona.quartz.events.TextNoteEvent import com.vitorpamplona.quartz.events.toImmutableListOfLists @@ -52,11 +57,46 @@ fun RenderTextEvent( makeItShort: Boolean, canPreview: Boolean, quotesLeft: Int, + unPackReply: Boolean, backgroundColor: MutableState, editState: State>, accountViewModel: AccountViewModel, nav: (String) -> Unit, ) { + val noteEvent = note.event + + val showReply by + remember(note) { + derivedStateOf { + noteEvent is BaseTextNoteEvent && !makeItShort && unPackReply && (note.replyTo != null || noteEvent.hasAnyTaggedUser()) + } + } + + if (showReply) { + val replyingDirectlyTo = + remember(note) { + if (noteEvent is BaseTextNoteEvent) { + val replyingTo = noteEvent.replyingToAddressOrEvent() + if (replyingTo != null) { + val newNote = accountViewModel.getNoteIfExists(replyingTo) + if (newNote != null && newNote.channelHex() == null && newNote.event?.kind() != CommunityDefinitionEvent.KIND) { + newNote + } else { + note.replyTo?.lastOrNull { it.event?.kind() != CommunityDefinitionEvent.KIND } + } + } else { + note.replyTo?.lastOrNull { it.event?.kind() != CommunityDefinitionEvent.KIND } + } + } else { + note.replyTo?.lastOrNull { it.event?.kind() != CommunityDefinitionEvent.KIND } + } + } + if (replyingDirectlyTo != null && unPackReply) { + ReplyNoteComposition(replyingDirectlyTo, backgroundColor, accountViewModel, nav) + Spacer(modifier = StdVertSpacer) + } + } + LoadDecryptedContent( note, accountViewModel, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt index b2370009d..08924100c 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt @@ -121,14 +121,17 @@ import com.vitorpamplona.amethyst.ui.note.types.EditState import com.vitorpamplona.amethyst.ui.note.types.FileHeaderDisplay import com.vitorpamplona.amethyst.ui.note.types.FileStorageHeaderDisplay import com.vitorpamplona.amethyst.ui.note.types.RenderAppDefinition +import com.vitorpamplona.amethyst.ui.note.types.RenderChannelMessage import com.vitorpamplona.amethyst.ui.note.types.RenderEmojiPack import com.vitorpamplona.amethyst.ui.note.types.RenderFhirResource import com.vitorpamplona.amethyst.ui.note.types.RenderGitIssueEvent import com.vitorpamplona.amethyst.ui.note.types.RenderGitPatchEvent import com.vitorpamplona.amethyst.ui.note.types.RenderGitRepositoryEvent +import com.vitorpamplona.amethyst.ui.note.types.RenderLiveActivityChatMessage import com.vitorpamplona.amethyst.ui.note.types.RenderPinListEvent import com.vitorpamplona.amethyst.ui.note.types.RenderPoll import com.vitorpamplona.amethyst.ui.note.types.RenderPostApproval +import com.vitorpamplona.amethyst.ui.note.types.RenderPrivateMessage import com.vitorpamplona.amethyst.ui.note.types.RenderTextEvent import com.vitorpamplona.amethyst.ui.note.types.RenderTextModificationEvent import com.vitorpamplona.amethyst.ui.note.types.VideoDisplay @@ -152,6 +155,7 @@ import com.vitorpamplona.quartz.events.AudioHeaderEvent import com.vitorpamplona.quartz.events.AudioTrackEvent import com.vitorpamplona.quartz.events.BadgeDefinitionEvent import com.vitorpamplona.quartz.events.ChannelCreateEvent +import com.vitorpamplona.quartz.events.ChannelMessageEvent import com.vitorpamplona.quartz.events.ChannelMetadataEvent import com.vitorpamplona.quartz.events.ClassifiedsEvent import com.vitorpamplona.quartz.events.CommunityDefinitionEvent @@ -167,10 +171,12 @@ import com.vitorpamplona.quartz.events.GitIssueEvent import com.vitorpamplona.quartz.events.GitPatchEvent import com.vitorpamplona.quartz.events.GitRepositoryEvent import com.vitorpamplona.quartz.events.HighlightEvent +import com.vitorpamplona.quartz.events.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.events.LongTextNoteEvent import com.vitorpamplona.quartz.events.PeopleListEvent import com.vitorpamplona.quartz.events.PinListEvent import com.vitorpamplona.quartz.events.PollNoteEvent +import com.vitorpamplona.quartz.events.PrivateDmEvent import com.vitorpamplona.quartz.events.RelaySetEvent import com.vitorpamplona.quartz.events.RepostEvent import com.vitorpamplona.quartz.events.TextNoteModificationEvent @@ -480,6 +486,11 @@ fun NoteMaster( ), ) { Column { + val canPreview = + note.author == account.userProfile() || + (note.author?.let { account.userProfile().isFollowingCached(it) } ?: true) || + !noteForReports.hasAnyReports() + if ( (noteEvent is ChannelCreateEvent || noteEvent is ChannelMetadataEvent) && note.channelHex() != null @@ -570,31 +581,55 @@ fun NoteMaster( nav, ) } else if (noteEvent is PollNoteEvent) { - val canPreview = - note.author == account.userProfile() || - (note.author?.let { account.userProfile().isFollowingCached(it) } ?: true) || - !noteForReports.hasAnyReports() - RenderPoll( baseNote, false, canPreview, quotesLeft = 3, + unPackReply = false, backgroundColor, accountViewModel, nav, ) + } else if (noteEvent is PrivateDmEvent) { + RenderPrivateMessage( + baseNote, + false, + canPreview, + 3, + backgroundColor, + accountViewModel, + nav, + ) + } else if (noteEvent is ChannelMessageEvent) { + RenderChannelMessage( + baseNote, + false, + canPreview, + 3, + backgroundColor, + editState, + accountViewModel, + nav, + ) + } else if (noteEvent is LiveActivitiesChatMessageEvent) { + RenderLiveActivityChatMessage( + baseNote, + false, + canPreview, + 3, + backgroundColor, + editState, + accountViewModel, + nav, + ) } else { - val canPreview = - note.author == account.userProfile() || - (note.author?.let { account.userProfile().isFollowingCached(it) } ?: true) || - !noteForReports.hasAnyReports() - RenderTextEvent( baseNote, false, canPreview, quotesLeft = 3, + unPackReply = false, backgroundColor, editState, accountViewModel, @@ -876,6 +911,7 @@ private fun RenderWikiHeaderForThreadPreview() { false, true, quotesLeft = 3, + unPackReply = false, backgroundColor, editState, accountViewModel, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomScreen.kt index dfe9b374b..de961dfa2 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomScreen.kt @@ -94,7 +94,6 @@ import com.vitorpamplona.amethyst.ui.actions.PostButton import com.vitorpamplona.amethyst.ui.actions.ServerOption import com.vitorpamplona.amethyst.ui.actions.UploadFromGallery import com.vitorpamplona.amethyst.ui.actions.UrlUserTagTransformation -import com.vitorpamplona.amethyst.ui.components.ObserveDisplayNip05Status import com.vitorpamplona.amethyst.ui.note.ClickableUserPicture import com.vitorpamplona.amethyst.ui.note.DisplayRoomSubject import com.vitorpamplona.amethyst.ui.note.DisplayUserSetAsSubject @@ -591,7 +590,7 @@ fun ChatroomHeader( room: ChatroomKey, modifier: Modifier = StdPadding, accountViewModel: AccountViewModel, - nav: (String) -> Unit, + onClick: () -> Unit, ) { if (room.users.size == 1) { LoadUser(baseUserHex = room.users.first(), accountViewModel) { baseUser -> @@ -600,7 +599,7 @@ fun ChatroomHeader( baseUser = baseUser, modifier = modifier, accountViewModel = accountViewModel, - nav = nav, + onClick = onClick, ) } } @@ -609,7 +608,7 @@ fun ChatroomHeader( room = room, modifier = modifier, accountViewModel = accountViewModel, - nav = nav, + onClick = onClick, ) } } @@ -619,13 +618,13 @@ fun ChatroomHeader( baseUser: User, modifier: Modifier = StdPadding, accountViewModel: AccountViewModel, - nav: (String) -> Unit, + onClick: () -> Unit, ) { Column( modifier = Modifier.fillMaxWidth() .clickable( - onClick = { nav("User/${baseUser.pubkeyHex}") }, + onClick = onClick, ), ) { Column( @@ -641,7 +640,6 @@ fun ChatroomHeader( Column(modifier = Modifier.padding(start = 10.dp)) { UsernameDisplay(baseUser) - ObserveDisplayNip05Status(baseUser, accountViewModel = accountViewModel, nav = nav) } } } @@ -653,12 +651,10 @@ fun GroupChatroomHeader( room: ChatroomKey, modifier: Modifier = StdPadding, accountViewModel: AccountViewModel, - nav: (String) -> Unit, + onClick: () -> Unit, ) { - val expanded = remember { mutableStateOf(false) } - Column( - modifier = Modifier.fillMaxWidth().clickable { expanded.value = !expanded.value }, + modifier = Modifier.fillMaxWidth().clickable(onClick = onClick), ) { Column( verticalArrangement = Arrangement.Center, @@ -676,10 +672,6 @@ fun GroupChatroomHeader( DisplayUserSetAsSubject(room, accountViewModel, FontWeight.Normal) } } - - if (expanded.value) { - LongRoomHeader(room = room, accountViewModel = accountViewModel, nav = nav) - } } } }