diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChannelCardCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChannelCardCompose.kt index 145760686..1fedd41e6 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChannelCardCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChannelCardCompose.kt @@ -492,6 +492,7 @@ fun RenderLiveActivityThumb( showVideo = false, showBottomDiviser = false, showFlag = false, + sendToChannel = true, modifier = remember { Modifier.padding(start = 0.dp, end = 0.dp, top = 5.dp, bottom = 5.dp) }, 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 61de2a8c4..eb999a605 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 @@ -434,12 +434,14 @@ fun NormalNote( channelNote = baseNote, showVideo = !makeItShort, showBottomDiviser = true, + sendToChannel = true, accountViewModel = accountViewModel, nav = nav ) is CommunityDefinitionEvent -> CommunityHeader( baseNote = baseNote, showBottomDiviser = true, + sendToCommunity = true, accountViewModel = accountViewModel, nav = nav ) @@ -471,6 +473,7 @@ fun NormalNote( fun CommunityHeader( baseNote: Note, showBottomDiviser: Boolean, + sendToCommunity: Boolean, modifier: Modifier = StdPadding, accountViewModel: AccountViewModel, nav: (String) -> Unit @@ -479,7 +482,13 @@ fun CommunityHeader( Column( modifier = modifier.clickable { - expanded.value = !expanded.value + if (sendToCommunity) { + routeFor(baseNote, accountViewModel.userProfile())?.let { + nav(it) + } + } else { + expanded.value = !expanded.value + } } ) { ShortCommunityHeader(baseNote, expanded, accountViewModel, nav) @@ -1149,6 +1158,10 @@ fun routeFor(note: Note, loggedIn: User): String? { return null } +fun routeFor(note: Channel): String { + return "Channel/${note.idHex}" +} + fun routeFor(user: User): String { return "User/${user.pubkeyHex}" } @@ -2303,6 +2316,7 @@ private fun ReplyRow( channelHex = channelHex, showVideo = false, showBottomDiviser = false, + sendToChannel = true, modifier = remember { Modifier.padding(vertical = 5.dp) }, accountViewModel = accountViewModel, nav = nav 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 fdeb1c7ab..1d7cb9141 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 @@ -366,6 +366,7 @@ fun NoteMaster( channelHex = note.channelHex()!!, showVideo = true, showBottomDiviser = false, + sendToChannel = true, accountViewModel = accountViewModel, nav = nav ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt index 9785ce4a4..b3cfe50ad 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt @@ -107,6 +107,7 @@ import com.vitorpamplona.amethyst.ui.note.ChatroomMessageCompose import com.vitorpamplona.amethyst.ui.note.ClickableUserPicture import com.vitorpamplona.amethyst.ui.note.DisplayUncitedHashtags import com.vitorpamplona.amethyst.ui.note.LikeReaction +import com.vitorpamplona.amethyst.ui.note.LoadChannel import com.vitorpamplona.amethyst.ui.note.MoreOptionsButton import com.vitorpamplona.amethyst.ui.note.NoteAuthorPicture import com.vitorpamplona.amethyst.ui.note.NoteUsernameDisplay @@ -114,6 +115,7 @@ import com.vitorpamplona.amethyst.ui.note.TimeAgo import com.vitorpamplona.amethyst.ui.note.UserPicture import com.vitorpamplona.amethyst.ui.note.UsernameDisplay import com.vitorpamplona.amethyst.ui.note.ZapReaction +import com.vitorpamplona.amethyst.ui.note.routeFor import com.vitorpamplona.amethyst.ui.note.timeAgo import com.vitorpamplona.amethyst.ui.screen.NostrChannelFeedViewModel import com.vitorpamplona.amethyst.ui.screen.RefreshingChatroomFeedView @@ -143,18 +145,7 @@ fun ChannelScreen( ) { if (channelId == null) return - var channelBase by remember { mutableStateOf(LocalCache.getChannelIfExists(channelId)) } - - LaunchedEffect(channelId) { - withContext(Dispatchers.IO) { - val newChannelBase = LocalCache.checkGetOrCreateChannel(channelId) - if (newChannelBase != channelBase) { - channelBase = newChannelBase - } - } - } - - channelBase?.let { + LoadChannel(channelId) { PrepareChannelViewModels( baseChannel = it, accountViewModel = accountViewModel, @@ -516,6 +507,7 @@ fun ChannelHeader( channelNote: Note, showVideo: Boolean, showBottomDiviser: Boolean, + sendToChannel: Boolean, modifier: Modifier = StdPadding, accountViewModel: AccountViewModel, nav: (String) -> Unit @@ -530,6 +522,7 @@ fun ChannelHeader( channelHex = it, showVideo = showVideo, showBottomDiviser = showBottomDiviser, + sendToChannel = sendToChannel, accountViewModel = accountViewModel, nav = nav ) @@ -542,26 +535,18 @@ fun ChannelHeader( showVideo: Boolean, showBottomDiviser: Boolean, showFlag: Boolean = true, + sendToChannel: Boolean = false, modifier: Modifier = StdPadding, accountViewModel: AccountViewModel, nav: (String) -> Unit ) { - var baseChannel by remember { mutableStateOf(LocalCache.channels[channelHex]) } - - if (baseChannel == null) { - LaunchedEffect(key1 = channelHex) { - launch(Dispatchers.IO) { - baseChannel = LocalCache.checkGetOrCreateChannel(channelHex) - } - } - } - - baseChannel?.let { + LoadChannel(channelHex) { ChannelHeader( it, showVideo, showBottomDiviser, showFlag, + sendToChannel, modifier, accountViewModel, nav @@ -575,6 +560,7 @@ fun ChannelHeader( showVideo: Boolean, showBottomDiviser: Boolean, showFlag: Boolean = true, + sendToChannel: Boolean = false, modifier: Modifier = StdPadding, accountViewModel: AccountViewModel, nav: (String) -> Unit @@ -588,7 +574,11 @@ fun ChannelHeader( Column( modifier = modifier.clickable { - expanded.value = !expanded.value + if (sendToChannel) { + nav(routeFor(baseChannel)) + } else { + expanded.value = !expanded.value + } } ) { ShortChannelHeader(baseChannel, expanded, accountViewModel, nav, showFlag) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/CommunityScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/CommunityScreen.kt index 6a5519e7b..234e07599 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/CommunityScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/CommunityScreen.kt @@ -94,7 +94,13 @@ fun CommunityScreen(note: AddressableNote, feedViewModel: NostrCommunityFeedView } Column(Modifier.fillMaxSize()) { - CommunityHeader(baseNote = note, showBottomDiviser = true, accountViewModel = accountViewModel, nav = nav) + CommunityHeader( + baseNote = note, + showBottomDiviser = true, + sendToCommunity = false, + accountViewModel = accountViewModel, + nav = nav + ) RefresheableFeedView( feedViewModel, null,