mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-19 22:00:35 +02:00
Fixes reply routes when clicking in the Conversations tab when the event is a PublicChat, LiveStream or Ephemeral Chat
This commit is contained in:
@@ -151,6 +151,7 @@ fun AppNavigation(
|
||||
PublicChatChannelScreen(
|
||||
it.id,
|
||||
it.draftId?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
||||
it.replyTo?.let { hex -> accountViewModel.checkGetOrCreateNote(hex) },
|
||||
accountViewModel,
|
||||
nav,
|
||||
)
|
||||
@@ -160,6 +161,7 @@ fun AppNavigation(
|
||||
LiveActivityChannelScreen(
|
||||
Address(it.kind, it.pubKeyHex, it.dTag),
|
||||
draft = it.draftId?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
||||
replyTo = it.replyTo?.let { hex -> accountViewModel.checkGetOrCreateNote(hex) },
|
||||
accountViewModel,
|
||||
nav,
|
||||
)
|
||||
@@ -170,6 +172,7 @@ fun AppNavigation(
|
||||
EphemeralChatScreen(
|
||||
channelId = RoomId(it.id, relay),
|
||||
draft = it.draftId?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
||||
replyTo = it.replyTo?.let { hex -> accountViewModel.checkGetOrCreateNote(hex) },
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav,
|
||||
)
|
||||
|
@@ -215,6 +215,21 @@ fun routeReplyTo(
|
||||
): Route? {
|
||||
val noteEvent = note.event
|
||||
return when (noteEvent) {
|
||||
is ChannelMessageEvent -> {
|
||||
noteEvent.channelId()?.let { channelId ->
|
||||
Route.PublicChatChannel(channelId, replyTo = note.idHex)
|
||||
}
|
||||
}
|
||||
is LiveActivitiesChatMessageEvent -> {
|
||||
noteEvent.activityAddress()?.let {
|
||||
Route.LiveActivityChannel(it.kind, it.pubKeyHex, it.dTag, replyTo = note.idHex)
|
||||
}
|
||||
}
|
||||
is EphemeralChatEvent -> {
|
||||
noteEvent.roomId()?.let {
|
||||
Route.EphemeralChat(it.id, it.relayUrl.url, replyTo = note.idHex)
|
||||
}
|
||||
}
|
||||
is PublicMessageEvent ->
|
||||
Route.NewPublicMessage(
|
||||
users = noteEvent.groupKeySet() - account.userProfile().pubkeyHex,
|
||||
|
@@ -91,6 +91,7 @@ sealed class Route {
|
||||
@Serializable data class PublicChatChannel(
|
||||
val id: String,
|
||||
val draftId: HexKey? = null,
|
||||
val replyTo: HexKey? = null,
|
||||
) : Route()
|
||||
|
||||
@Serializable data class LiveActivityChannel(
|
||||
@@ -98,6 +99,7 @@ sealed class Route {
|
||||
val pubKeyHex: HexKey,
|
||||
val dTag: String,
|
||||
val draftId: HexKey? = null,
|
||||
val replyTo: HexKey? = null,
|
||||
) : Route()
|
||||
|
||||
@Serializable data class RelayInfo(
|
||||
@@ -108,6 +110,7 @@ sealed class Route {
|
||||
val id: String,
|
||||
val relayUrl: String,
|
||||
val draftId: HexKey? = null,
|
||||
val replyTo: HexKey? = null,
|
||||
) : Route()
|
||||
|
||||
@Serializable object NewEphemeralChat : Route()
|
||||
|
@@ -967,7 +967,7 @@ class AccountViewModel(
|
||||
|
||||
fun getUserIfExists(hex: HexKey): User? = LocalCache.getUserIfExists(hex)
|
||||
|
||||
private fun checkGetOrCreateNote(key: HexKey): Note? = LocalCache.checkGetOrCreateNote(key)
|
||||
fun checkGetOrCreateNote(key: HexKey): Note? = LocalCache.checkGetOrCreateNote(key)
|
||||
|
||||
override suspend fun getOrCreateNote(key: HexKey): Note = LocalCache.getOrCreateNote(key)
|
||||
|
||||
|
@@ -47,6 +47,7 @@ import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId
|
||||
fun EphemeralChatChannelView(
|
||||
channelId: RoomId?,
|
||||
draft: Note? = null,
|
||||
replyTo: Note? = null,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: INav,
|
||||
) {
|
||||
@@ -56,6 +57,7 @@ fun EphemeralChatChannelView(
|
||||
PrepareChannelViewModels(
|
||||
baseChannel = ephem,
|
||||
draft = draft,
|
||||
replyTo = replyTo,
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav,
|
||||
)
|
||||
@@ -66,6 +68,7 @@ fun EphemeralChatChannelView(
|
||||
private fun PrepareChannelViewModels(
|
||||
baseChannel: EphemeralChatChannel,
|
||||
draft: Note? = null,
|
||||
replyTo: Note? = null,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: INav,
|
||||
) {
|
||||
@@ -89,6 +92,12 @@ private fun PrepareChannelViewModels(
|
||||
}
|
||||
}
|
||||
|
||||
if (replyTo != null) {
|
||||
LaunchedEffect(replyTo, channelScreenModel, accountViewModel) {
|
||||
channelScreenModel.reply(replyTo)
|
||||
}
|
||||
}
|
||||
|
||||
ChannelView(
|
||||
channel = baseChannel,
|
||||
feedViewModel = feedViewModel,
|
||||
|
@@ -36,6 +36,7 @@ import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId
|
||||
fun EphemeralChatScreen(
|
||||
channelId: RoomId,
|
||||
draft: Note? = null,
|
||||
replyTo: Note? = null,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: INav,
|
||||
) {
|
||||
@@ -49,7 +50,7 @@ fun EphemeralChatScreen(
|
||||
accountViewModel = accountViewModel,
|
||||
) {
|
||||
Column(Modifier.padding(it).statusBarsPadding()) {
|
||||
EphemeralChatChannelView(channelId, draft, accountViewModel, nav)
|
||||
EphemeralChatChannelView(channelId, draft, replyTo, accountViewModel, nav)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -47,6 +47,7 @@ import com.vitorpamplona.amethyst.ui.theme.DoubleVertSpacer
|
||||
fun PublicChatChannelView(
|
||||
channelId: String?,
|
||||
draft: Note? = null,
|
||||
replyTo: Note? = null,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: INav,
|
||||
) {
|
||||
@@ -56,6 +57,7 @@ fun PublicChatChannelView(
|
||||
PrepareChannelViewModels(
|
||||
baseChannel = it,
|
||||
draft = draft,
|
||||
replyTo = replyTo,
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav,
|
||||
)
|
||||
@@ -66,6 +68,7 @@ fun PublicChatChannelView(
|
||||
fun PrepareChannelViewModels(
|
||||
baseChannel: PublicChatChannel,
|
||||
draft: Note? = null,
|
||||
replyTo: Note? = null,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: INav,
|
||||
) {
|
||||
@@ -89,6 +92,12 @@ fun PrepareChannelViewModels(
|
||||
}
|
||||
}
|
||||
|
||||
if (replyTo != null) {
|
||||
LaunchedEffect(replyTo, channelScreenModel, accountViewModel) {
|
||||
channelScreenModel.reply(replyTo)
|
||||
}
|
||||
}
|
||||
|
||||
ChannelView(
|
||||
channel = baseChannel,
|
||||
feedViewModel = feedViewModel,
|
||||
|
@@ -37,6 +37,7 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
fun PublicChatChannelScreen(
|
||||
channelId: HexKey?,
|
||||
draft: Note?,
|
||||
replyTo: Note? = null,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: INav,
|
||||
) {
|
||||
@@ -52,7 +53,7 @@ fun PublicChatChannelScreen(
|
||||
accountViewModel = accountViewModel,
|
||||
) {
|
||||
Column(Modifier.padding(it).statusBarsPadding()) {
|
||||
PublicChatChannelView(channelId, draft, accountViewModel, nav)
|
||||
PublicChatChannelView(channelId, draft, replyTo, accountViewModel, nav)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -47,6 +47,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.addressables.Address
|
||||
fun LiveActivityChannelView(
|
||||
channelId: Address?,
|
||||
draft: Note? = null,
|
||||
replyTo: Note? = null,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: INav,
|
||||
) {
|
||||
@@ -56,6 +57,7 @@ fun LiveActivityChannelView(
|
||||
PrepareChannelViewModels(
|
||||
baseChannel = it,
|
||||
draft = draft,
|
||||
replyTo = replyTo,
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav,
|
||||
)
|
||||
@@ -66,6 +68,7 @@ fun LiveActivityChannelView(
|
||||
fun PrepareChannelViewModels(
|
||||
baseChannel: LiveActivitiesChannel,
|
||||
draft: Note? = null,
|
||||
replyTo: Note? = null,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: INav,
|
||||
) {
|
||||
@@ -89,6 +92,12 @@ fun PrepareChannelViewModels(
|
||||
}
|
||||
}
|
||||
|
||||
if (replyTo != null) {
|
||||
LaunchedEffect(replyTo, channelScreenModel, accountViewModel) {
|
||||
channelScreenModel.reply(replyTo)
|
||||
}
|
||||
}
|
||||
|
||||
LiveActivityChannelView(
|
||||
channel = baseChannel,
|
||||
feedViewModel = feedViewModel,
|
||||
|
@@ -38,6 +38,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.addressables.Address
|
||||
fun LiveActivityChannelScreen(
|
||||
channelId: Address?,
|
||||
draft: Note? = null,
|
||||
replyTo: Note? = null,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: INav,
|
||||
) {
|
||||
@@ -58,7 +59,7 @@ fun LiveActivityChannelScreen(
|
||||
accountViewModel = accountViewModel,
|
||||
) {
|
||||
Column(Modifier.padding(it)) {
|
||||
LiveActivityChannelView(channelId, draft, accountViewModel, nav)
|
||||
LiveActivityChannelView(channelId, draft, replyTo, accountViewModel, nav)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user