Clicks on Community and Channel headers now take you to the community instead of expanding

This commit is contained in:
Vitor Pamplona
2023-07-14 09:22:56 -04:00
parent 640b0d3174
commit 6905e1b47f
5 changed files with 38 additions and 26 deletions

View File

@@ -492,6 +492,7 @@ fun RenderLiveActivityThumb(
showVideo = false, showVideo = false,
showBottomDiviser = false, showBottomDiviser = false,
showFlag = false, showFlag = false,
sendToChannel = true,
modifier = remember { modifier = remember {
Modifier.padding(start = 0.dp, end = 0.dp, top = 5.dp, bottom = 5.dp) Modifier.padding(start = 0.dp, end = 0.dp, top = 5.dp, bottom = 5.dp)
}, },

View File

@@ -434,12 +434,14 @@ fun NormalNote(
channelNote = baseNote, channelNote = baseNote,
showVideo = !makeItShort, showVideo = !makeItShort,
showBottomDiviser = true, showBottomDiviser = true,
sendToChannel = true,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav nav = nav
) )
is CommunityDefinitionEvent -> CommunityHeader( is CommunityDefinitionEvent -> CommunityHeader(
baseNote = baseNote, baseNote = baseNote,
showBottomDiviser = true, showBottomDiviser = true,
sendToCommunity = true,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav nav = nav
) )
@@ -471,6 +473,7 @@ fun NormalNote(
fun CommunityHeader( fun CommunityHeader(
baseNote: Note, baseNote: Note,
showBottomDiviser: Boolean, showBottomDiviser: Boolean,
sendToCommunity: Boolean,
modifier: Modifier = StdPadding, modifier: Modifier = StdPadding,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: (String) -> Unit nav: (String) -> Unit
@@ -479,7 +482,13 @@ fun CommunityHeader(
Column( Column(
modifier = modifier.clickable { 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) ShortCommunityHeader(baseNote, expanded, accountViewModel, nav)
@@ -1149,6 +1158,10 @@ fun routeFor(note: Note, loggedIn: User): String? {
return null return null
} }
fun routeFor(note: Channel): String {
return "Channel/${note.idHex}"
}
fun routeFor(user: User): String { fun routeFor(user: User): String {
return "User/${user.pubkeyHex}" return "User/${user.pubkeyHex}"
} }
@@ -2303,6 +2316,7 @@ private fun ReplyRow(
channelHex = channelHex, channelHex = channelHex,
showVideo = false, showVideo = false,
showBottomDiviser = false, showBottomDiviser = false,
sendToChannel = true,
modifier = remember { Modifier.padding(vertical = 5.dp) }, modifier = remember { Modifier.padding(vertical = 5.dp) },
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav nav = nav

View File

@@ -366,6 +366,7 @@ fun NoteMaster(
channelHex = note.channelHex()!!, channelHex = note.channelHex()!!,
showVideo = true, showVideo = true,
showBottomDiviser = false, showBottomDiviser = false,
sendToChannel = true,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav nav = nav
) )

View File

@@ -107,6 +107,7 @@ import com.vitorpamplona.amethyst.ui.note.ChatroomMessageCompose
import com.vitorpamplona.amethyst.ui.note.ClickableUserPicture import com.vitorpamplona.amethyst.ui.note.ClickableUserPicture
import com.vitorpamplona.amethyst.ui.note.DisplayUncitedHashtags import com.vitorpamplona.amethyst.ui.note.DisplayUncitedHashtags
import com.vitorpamplona.amethyst.ui.note.LikeReaction 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.MoreOptionsButton
import com.vitorpamplona.amethyst.ui.note.NoteAuthorPicture import com.vitorpamplona.amethyst.ui.note.NoteAuthorPicture
import com.vitorpamplona.amethyst.ui.note.NoteUsernameDisplay 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.UserPicture
import com.vitorpamplona.amethyst.ui.note.UsernameDisplay import com.vitorpamplona.amethyst.ui.note.UsernameDisplay
import com.vitorpamplona.amethyst.ui.note.ZapReaction 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.note.timeAgo
import com.vitorpamplona.amethyst.ui.screen.NostrChannelFeedViewModel import com.vitorpamplona.amethyst.ui.screen.NostrChannelFeedViewModel
import com.vitorpamplona.amethyst.ui.screen.RefreshingChatroomFeedView import com.vitorpamplona.amethyst.ui.screen.RefreshingChatroomFeedView
@@ -143,18 +145,7 @@ fun ChannelScreen(
) { ) {
if (channelId == null) return if (channelId == null) return
var channelBase by remember { mutableStateOf<Channel?>(LocalCache.getChannelIfExists(channelId)) } LoadChannel(channelId) {
LaunchedEffect(channelId) {
withContext(Dispatchers.IO) {
val newChannelBase = LocalCache.checkGetOrCreateChannel(channelId)
if (newChannelBase != channelBase) {
channelBase = newChannelBase
}
}
}
channelBase?.let {
PrepareChannelViewModels( PrepareChannelViewModels(
baseChannel = it, baseChannel = it,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
@@ -516,6 +507,7 @@ fun ChannelHeader(
channelNote: Note, channelNote: Note,
showVideo: Boolean, showVideo: Boolean,
showBottomDiviser: Boolean, showBottomDiviser: Boolean,
sendToChannel: Boolean,
modifier: Modifier = StdPadding, modifier: Modifier = StdPadding,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: (String) -> Unit nav: (String) -> Unit
@@ -530,6 +522,7 @@ fun ChannelHeader(
channelHex = it, channelHex = it,
showVideo = showVideo, showVideo = showVideo,
showBottomDiviser = showBottomDiviser, showBottomDiviser = showBottomDiviser,
sendToChannel = sendToChannel,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav nav = nav
) )
@@ -542,26 +535,18 @@ fun ChannelHeader(
showVideo: Boolean, showVideo: Boolean,
showBottomDiviser: Boolean, showBottomDiviser: Boolean,
showFlag: Boolean = true, showFlag: Boolean = true,
sendToChannel: Boolean = false,
modifier: Modifier = StdPadding, modifier: Modifier = StdPadding,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: (String) -> Unit nav: (String) -> Unit
) { ) {
var baseChannel by remember { mutableStateOf(LocalCache.channels[channelHex]) } LoadChannel(channelHex) {
if (baseChannel == null) {
LaunchedEffect(key1 = channelHex) {
launch(Dispatchers.IO) {
baseChannel = LocalCache.checkGetOrCreateChannel(channelHex)
}
}
}
baseChannel?.let {
ChannelHeader( ChannelHeader(
it, it,
showVideo, showVideo,
showBottomDiviser, showBottomDiviser,
showFlag, showFlag,
sendToChannel,
modifier, modifier,
accountViewModel, accountViewModel,
nav nav
@@ -575,6 +560,7 @@ fun ChannelHeader(
showVideo: Boolean, showVideo: Boolean,
showBottomDiviser: Boolean, showBottomDiviser: Boolean,
showFlag: Boolean = true, showFlag: Boolean = true,
sendToChannel: Boolean = false,
modifier: Modifier = StdPadding, modifier: Modifier = StdPadding,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: (String) -> Unit nav: (String) -> Unit
@@ -588,7 +574,11 @@ fun ChannelHeader(
Column( Column(
modifier = modifier.clickable { modifier = modifier.clickable {
expanded.value = !expanded.value if (sendToChannel) {
nav(routeFor(baseChannel))
} else {
expanded.value = !expanded.value
}
} }
) { ) {
ShortChannelHeader(baseChannel, expanded, accountViewModel, nav, showFlag) ShortChannelHeader(baseChannel, expanded, accountViewModel, nav, showFlag)

View File

@@ -94,7 +94,13 @@ fun CommunityScreen(note: AddressableNote, feedViewModel: NostrCommunityFeedView
} }
Column(Modifier.fillMaxSize()) { Column(Modifier.fillMaxSize()) {
CommunityHeader(baseNote = note, showBottomDiviser = true, accountViewModel = accountViewModel, nav = nav) CommunityHeader(
baseNote = note,
showBottomDiviser = true,
sendToCommunity = false,
accountViewModel = accountViewModel,
nav = nav
)
RefresheableFeedView( RefresheableFeedView(
feedViewModel, feedViewModel,
null, null,