diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt index 24a294e32..cd31fc111 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt @@ -146,11 +146,32 @@ fun AppNavigation( composableFromEndArgs { ChatroomScreen(it.toKey(), it.message, it.replyId, it.draftId, accountViewModel, nav) } composableFromEndArgs { ChatroomByAuthorScreen(it.id, null, accountViewModel, nav) } - composableFromEndArgs { PublicChatChannelScreen(it.id, accountViewModel, nav) } - composableFromEndArgs { LiveActivityChannelScreen(Address(it.kind, it.pubKeyHex, it.dTag), accountViewModel, nav) } + composableFromEndArgs { + PublicChatChannelScreen( + it.id, + it.draftId?.let { hex -> accountViewModel.getNoteIfExists(hex) }, + accountViewModel, + nav, + ) + } + + composableFromEndArgs { + LiveActivityChannelScreen( + Address(it.kind, it.pubKeyHex, it.dTag), + draft = it.draftId?.let { hex -> accountViewModel.getNoteIfExists(hex) }, + accountViewModel, + nav, + ) + } + composableFromEndArgs { RelayUrlNormalizer.normalizeOrNull(it.relayUrl)?.let { relay -> - EphemeralChatScreen(RoomId(it.id, relay), accountViewModel, nav) + EphemeralChatScreen( + channelId = RoomId(it.id, relay), + draft = it.draftId?.let { hex -> accountViewModel.getNoteIfExists(hex) }, + accountViewModel = accountViewModel, + nav = nav, + ) } } @@ -177,6 +198,7 @@ fun AppNavigation( NewPublicMessageScreen( to = it.toKey(), reply = it.replyId?.let { hex -> accountViewModel.getNoteIfExists(hex) }, + draft = it.draftId?.let { hex -> accountViewModel.getNoteIfExists(hex) }, accountViewModel = accountViewModel, nav = nav, ) @@ -218,7 +240,7 @@ fun AppNavigation( ) } - composableFromBottomArgs { + composableFromBottomArgs { ShortNotePostScreen( message = it.message, attachment = it.attachment?.ifBlank { null }?.toUri(), @@ -259,7 +281,7 @@ private fun NavigateIfIntentRequested( if (activity.intent.action == Intent.ACTION_SEND) { // avoids restarting the new Post screen when the intent is for the screen. // Microsoft's swift key sends Gifs as new actions - if (isBaseRoute(nav.controller)) return + if (isBaseRoute(nav.controller)) return // saves the intent to avoid processing again var message by remember { @@ -276,7 +298,7 @@ private fun NavigateIfIntentRequested( ) } - nav.newStack(Route.NewPost(message = message, attachment = media.toString())) + nav.newStack(Route.NewShortNote(message = message, attachment = media.toString())) } else { var newAccount by remember { mutableStateOf(null) } @@ -335,13 +357,13 @@ private fun NavigateIfIntentRequested( if (intent.action == Intent.ACTION_SEND) { // avoids restarting the new Post screen when the intent is for the screen. // Microsoft's swift key sends Gifs as new actions - if (!isBaseRoute(nav.controller)) { + if (!isBaseRoute(nav.controller)) { intent.getStringExtra(Intent.EXTRA_TEXT)?.let { - nav.newStack(Route.NewPost(message = it)) + nav.newStack(Route.NewShortNote(message = it)) } (intent.getParcelableExtra(Intent.EXTRA_STREAM) as? Uri)?.let { - nav.newStack(Route.NewPost(attachment = it.toString())) + nav.newStack(Route.NewShortNote(attachment = it.toString())) } } } else { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt index d6df69fd7..d62bdc771 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt @@ -28,6 +28,7 @@ import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel import com.vitorpamplona.amethyst.model.nip28PublicChats.PublicChatChannel import com.vitorpamplona.amethyst.model.nip53LiveActivities.LiveActivitiesChannel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.quartz.experimental.ephemChat.chat.EphemeralChatEvent import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId import com.vitorpamplona.quartz.experimental.publicMessages.PublicMessageEvent import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent @@ -40,6 +41,7 @@ import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.base.IsInPublicChatChannel +import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent @@ -49,6 +51,7 @@ import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefiniti import com.vitorpamplona.quartz.nip73ExternalIds.location.isGeohashedScoped import com.vitorpamplona.quartz.nip73ExternalIds.topics.isHashtagScoped import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent +import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent fun routeFor( note: Note, @@ -78,6 +81,10 @@ fun routeFor( innerEvent.activityAddress()?.let { return Route.LiveActivityChannel(it.kind, it.pubKeyHex, it.dTag) } + } else if (innerEvent is EphemeralChatEvent) { + innerEvent.roomId()?.let { + return Route.EphemeralChat(it.id, it.relayUrl.url) + } } else if (innerEvent is ChatroomKeyable) { val room = innerEvent.chatroomKey(loggedIn.userProfile().pubkeyHex) loggedIn.chatroomList.getOrCreatePrivateChatroom(room) @@ -206,7 +213,7 @@ fun routeReplyTo( users = noteEvent.groupKeySet() - account.userProfile().pubkeyHex, parentId = noteEvent.id, ) - is TextNoteEvent -> Route.NewPost(baseReplyTo = note.idHex) + is TextNoteEvent -> Route.NewShortNote(baseReplyTo = note.idHex) is PrivateDmEvent -> routeToMessage( room = noteEvent.chatroomKey(account.userProfile().pubkeyHex), @@ -236,3 +243,49 @@ fun routeReplyTo( else -> Route.GenericCommentPost(replyTo = note.idHex) } } + +suspend fun routeEditDraftTo( + note: Note, + account: Account, +): Route? { + val noteEvent = note.event as DraftWrapEvent + val draft = account.draftsDecryptionCache.cachedDraft(noteEvent) + + return when (draft) { + is ChannelMessageEvent -> draft.channelId()?.let { Route.PublicChatChannel(it, draftId = note.idHex) } + is LiveActivitiesChatMessageEvent -> { + draft.activityAddress()?.let { Route.LiveActivityChannel(it.kind, it.pubKeyHex, it.dTag, draftId = note.idHex) } + } + is EphemeralChatEvent -> { + draft.roomId()?.let { Route.EphemeralChat(it.id, it.relayUrl.url, draftId = note.idHex) } + } + + is ChatroomKeyable -> { + val room = draft.chatroomKey(account.userProfile().pubkeyHex) + account.chatroomList.getOrCreatePrivateChatroom(room) + return Route.Room(room, draftId = note.idHex) + } + + is TextNoteEvent -> Route.NewShortNote(draft = note.idHex) + is ClassifiedsEvent -> Route.NewProduct(draft = note.idHex) + + is PublicMessageEvent -> + Route.NewPublicMessage( + users = draft.groupKeySet() - account.userProfile().pubkeyHex, + parentId = noteEvent.id, + draftId = note.idHex, + ) + + is CommentEvent -> { + if (draft.isGeohashedScoped()) { + Route.GeoPost(draft = note.idHex) + } else if (draft.isHashtagScoped()) { + Route.HashtagPost(draft = note.idHex) + } else { + Route.GenericCommentPost(draft = note.idHex) + } + } + + else -> null + } +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt index 5364b57b7..3f75e4e1a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt @@ -90,16 +90,14 @@ sealed class Route { @Serializable data class PublicChatChannel( val id: String, + val draftId: HexKey? = null, ) : Route() @Serializable data class LiveActivityChannel( val kind: Int, val pubKeyHex: HexKey, val dTag: String, - ) : Route() - - @Serializable data class EphemeralChatChannel( - val id: String, + val draftId: HexKey? = null, ) : Route() @Serializable data class RelayInfo( @@ -109,6 +107,7 @@ sealed class Route { @Serializable data class EphemeralChat( val id: String, val relayUrl: String, + val draftId: HexKey? = null, ) : Route() @Serializable object NewEphemeralChat : Route() @@ -141,10 +140,12 @@ sealed class Route { @Serializable data class NewPublicMessage( val to: String, val replyId: HexKey? = null, + val draftId: HexKey? = null, ) : Route() { - constructor(users: Set, parentId: HexKey) : this( + constructor(users: Set, parentId: HexKey, draftId: HexKey? = null) : this( to = users.joinToString(","), replyId = parentId, + draftId = draftId, ) fun toKey(): Set = to.split(",").toSet() @@ -196,7 +197,7 @@ sealed class Route { ) : Route() @Serializable - data class NewPost( + data class NewShortNote( val message: String? = null, val attachment: String? = null, val baseReplyTo: String? = null, @@ -248,7 +249,7 @@ fun getRouteWithArguments(navController: NavHostController): Route? { dest.hasRoute() -> entry.toRoute() dest.hasRoute() -> entry.toRoute() dest.hasRoute() -> entry.toRoute() - dest.hasRoute() -> entry.toRoute() + dest.hasRoute() -> entry.toRoute() dest.hasRoute() -> entry.toRoute() dest.hasRoute() -> entry.toRoute() dest.hasRoute() -> entry.toRoute() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt index 84339a6af..698f43491 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt @@ -84,7 +84,7 @@ import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.User import com.vitorpamplona.amethyst.ui.navigation.navs.EmptyNav import com.vitorpamplona.amethyst.ui.navigation.navs.INav -import com.vitorpamplona.amethyst.ui.navigation.routes.Route +import com.vitorpamplona.amethyst.ui.navigation.routes.routeEditDraftTo import com.vitorpamplona.amethyst.ui.painterRes import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.report.ReportNoteDialog @@ -169,11 +169,9 @@ fun NoteQuickActionMenu( note = note, onDismiss = onDismiss, onWantsToEditDraft = { - nav.nav( - Route.NewPost( - draft = note.idHex, - ), - ) + nav.nav { + routeEditDraftTo(note, accountViewModel.account) + } }, accountViewModel = accountViewModel, nav = nav, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt index aa410cad6..24a9b4f15 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt @@ -48,7 +48,6 @@ import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.CardDefaults @@ -155,7 +154,6 @@ import com.vitorpamplona.amethyst.ui.theme.placeholderText import com.vitorpamplona.amethyst.ui.theme.reactionBox import com.vitorpamplona.amethyst.ui.theme.ripple24dp import com.vitorpamplona.amethyst.ui.theme.selectedReactionBoxModifier -import com.vitorpamplona.quartz.nip01Core.relay.client.listeners.EmptyClientListener.onError import com.vitorpamplona.quartz.nip10Notes.BaseThreadedEvent import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable import com.vitorpamplona.quartz.nip30CustomEmoji.CustomEmoji @@ -541,7 +539,7 @@ private fun BoostWithDialog( accountViewModel, onQuotePress = { nav.nav { - Route.NewPost( + Route.NewShortNote( quote = baseNote.idHex, version = (editState.value as? GenericLoadable.Loaded) @@ -562,7 +560,7 @@ private fun BoostWithDialog( null } - Route.NewPost( + Route.NewShortNote( baseReplyTo = replyTo?.idHex, fork = baseNote.idHex, version = diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DropDownMenu.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DropDownMenu.kt index ef1a11556..5ff25dc23 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DropDownMenu.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DropDownMenu.kt @@ -47,7 +47,7 @@ import com.vitorpamplona.amethyst.ui.actions.EditPostView import com.vitorpamplona.amethyst.ui.components.ClickableBox import com.vitorpamplona.amethyst.ui.components.GenericLoadable import com.vitorpamplona.amethyst.ui.navigation.navs.INav -import com.vitorpamplona.amethyst.ui.navigation.routes.Route +import com.vitorpamplona.amethyst.ui.navigation.routes.routeEditDraftTo import com.vitorpamplona.amethyst.ui.note.VerticalDotsIcon import com.vitorpamplona.amethyst.ui.note.externalLinkForNote import com.vitorpamplona.amethyst.ui.note.types.EditState @@ -240,11 +240,9 @@ fun NoteDropDownMenu( DropdownMenuItem( text = { Text(stringRes(R.string.edit_draft)) }, onClick = { - val route = - Route.NewPost( - draft = note.idHex, - ) - nav.nav(route) + nav.nav { + routeEditDraftTo(note, accountViewModel.account) + } }, ) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index f1d17eff5..fa3fa2a02 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -1691,7 +1691,7 @@ class AccountViewModel( class CachedDraftNotes( val accountViewModel: AccountViewModel, - ) : GenericBaseCacheAsync(20) { + ) : GenericBaseCacheAsync(100) { override suspend fun compute(key: DraftWrapEvent): Note? = withContext(Dispatchers.IO) { val decrypted = accountViewModel.account.draftsDecryptionCache.cachedDraft(key) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/ephemChat/ChannelView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/ephemChat/ChannelView.kt index daa967c5d..dcce16c5c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/ephemChat/ChannelView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/ephemChat/ChannelView.kt @@ -25,10 +25,12 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel +import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel import com.vitorpamplona.amethyst.ui.feeds.WatchLifecycleAndUpdateModel import com.vitorpamplona.amethyst.ui.navigation.navs.INav @@ -44,6 +46,7 @@ import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId @Composable fun EphemeralChatChannelView( channelId: RoomId?, + draft: Note? = null, accountViewModel: AccountViewModel, nav: INav, ) { @@ -52,6 +55,7 @@ fun EphemeralChatChannelView( LoadEphemeralChatChannel(channelId, accountViewModel) { ephem -> PrepareChannelViewModels( baseChannel = ephem, + draft = draft, accountViewModel = accountViewModel, nav = nav, ) @@ -61,6 +65,7 @@ fun EphemeralChatChannelView( @Composable private fun PrepareChannelViewModels( baseChannel: EphemeralChatChannel, + draft: Note? = null, accountViewModel: AccountViewModel, nav: INav, ) { @@ -78,6 +83,12 @@ private fun PrepareChannelViewModels( channelScreenModel.init(accountViewModel) channelScreenModel.load(baseChannel) + if (draft != null) { + LaunchedEffect(draft, channelScreenModel, accountViewModel) { + channelScreenModel.editFromDraft(draft) + } + } + ChannelView( channel = baseChannel, feedViewModel = feedViewModel, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/ephemChat/EphemeralChatScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/ephemChat/EphemeralChatScreen.kt index a281a077f..49144b988 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/ephemChat/EphemeralChatScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/ephemChat/EphemeralChatScreen.kt @@ -22,8 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.ephem import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @@ -33,6 +35,7 @@ import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId @Composable fun EphemeralChatScreen( channelId: RoomId, + draft: Note? = null, accountViewModel: AccountViewModel, nav: INav, ) { @@ -45,8 +48,8 @@ fun EphemeralChatScreen( }, accountViewModel = accountViewModel, ) { - Column(Modifier.padding(it)) { - EphemeralChatChannelView(channelId, accountViewModel, nav) + Column(Modifier.padding(it).statusBarsPadding()) { + EphemeralChatChannelView(channelId, draft, accountViewModel, nav) } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip28PublicChat/ChannelView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip28PublicChat/ChannelView.kt index 896c357a1..aa0371fdc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip28PublicChat/ChannelView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip28PublicChat/ChannelView.kt @@ -25,10 +25,12 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel +import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.nip28PublicChats.PublicChatChannel import com.vitorpamplona.amethyst.ui.feeds.WatchLifecycleAndUpdateModel import com.vitorpamplona.amethyst.ui.navigation.navs.INav @@ -44,6 +46,7 @@ import com.vitorpamplona.amethyst.ui.theme.DoubleVertSpacer @Composable fun PublicChatChannelView( channelId: String?, + draft: Note? = null, accountViewModel: AccountViewModel, nav: INav, ) { @@ -52,6 +55,7 @@ fun PublicChatChannelView( LoadPublicChatChannel(channelId, accountViewModel) { PrepareChannelViewModels( baseChannel = it, + draft = draft, accountViewModel = accountViewModel, nav = nav, ) @@ -61,6 +65,7 @@ fun PublicChatChannelView( @Composable fun PrepareChannelViewModels( baseChannel: PublicChatChannel, + draft: Note? = null, accountViewModel: AccountViewModel, nav: INav, ) { @@ -78,6 +83,12 @@ fun PrepareChannelViewModels( channelScreenModel.init(accountViewModel) channelScreenModel.load(baseChannel) + if (draft != null) { + LaunchedEffect(draft, channelScreenModel, accountViewModel) { + channelScreenModel.editFromDraft(draft) + } + } + ChannelView( channel = baseChannel, feedViewModel = feedViewModel, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip28PublicChat/PublicChatChannelScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip28PublicChat/PublicChatChannelScreen.kt index 8c7cd6b93..1a08e226f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip28PublicChat/PublicChatChannelScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip28PublicChat/PublicChatChannelScreen.kt @@ -22,8 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.nip28 import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.note.LoadPublicChatChannel @@ -34,6 +36,7 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey @Composable fun PublicChatChannelScreen( channelId: HexKey?, + draft: Note?, accountViewModel: AccountViewModel, nav: INav, ) { @@ -48,8 +51,8 @@ fun PublicChatChannelScreen( }, accountViewModel = accountViewModel, ) { - Column(Modifier.padding(it)) { - PublicChatChannelView(channelId, accountViewModel, nav) + Column(Modifier.padding(it).statusBarsPadding()) { + PublicChatChannelView(channelId, draft, accountViewModel, nav) } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/ChannelView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/ChannelView.kt index d986e092c..2e09c9d64 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/ChannelView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/ChannelView.kt @@ -25,10 +25,12 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel +import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.nip53LiveActivities.LiveActivitiesChannel import com.vitorpamplona.amethyst.ui.feeds.WatchLifecycleAndUpdateModel import com.vitorpamplona.amethyst.ui.navigation.navs.INav @@ -45,6 +47,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.addressables.Address @Composable fun LiveActivityChannelView( channelId: Address?, + draft: Note? = null, accountViewModel: AccountViewModel, nav: INav, ) { @@ -53,6 +56,7 @@ fun LiveActivityChannelView( LoadLiveActivityChannel(channelId, accountViewModel) { PrepareChannelViewModels( baseChannel = it, + draft = draft, accountViewModel = accountViewModel, nav = nav, ) @@ -62,6 +66,7 @@ fun LiveActivityChannelView( @Composable fun PrepareChannelViewModels( baseChannel: LiveActivitiesChannel, + draft: Note? = null, accountViewModel: AccountViewModel, nav: INav, ) { @@ -79,6 +84,12 @@ fun PrepareChannelViewModels( channelScreenModel.init(accountViewModel) channelScreenModel.load(baseChannel) + if (draft != null) { + LaunchedEffect(draft, channelScreenModel, accountViewModel) { + channelScreenModel.editFromDraft(draft) + } + } + LiveActivityChannelView( channel = baseChannel, feedViewModel = feedViewModel, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/LiveActivityChannelScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/LiveActivityChannelScreen.kt index 4136ed19d..f078f7ece 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/LiveActivityChannelScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/LiveActivityChannelScreen.kt @@ -22,8 +22,10 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.nip53 import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.note.LoadLiveActivityChannel @@ -34,6 +36,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.addressables.Address @Composable fun LiveActivityChannelScreen( channelId: Address?, + draft: Note? = null, accountViewModel: AccountViewModel, nav: INav, ) { @@ -48,8 +51,8 @@ fun LiveActivityChannelScreen( }, accountViewModel = accountViewModel, ) { - Column(Modifier.padding(it)) { - LiveActivityChannelView(channelId, accountViewModel, nav) + Column(Modifier.padding(it).statusBarsPadding()) { + LiveActivityChannelView(channelId, draft, accountViewModel, nav) } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt index f63406ba2..61fb907dd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt @@ -207,10 +207,10 @@ open class ChannelNewMessageViewModel : private fun loadFromDraft(draft: Note) { val draftEvent = draft.event ?: return - val localfowardZapTo = draftEvent.tags.zapSplitSetup() - val totalWeight = localfowardZapTo.sumOf { it.weight } + val localForwardZapTo = draftEvent.tags.zapSplitSetup() + val totalWeight = localForwardZapTo.sumOf { it.weight } forwardZapTo = SplitBuilder() - localfowardZapTo.forEach { + localForwardZapTo.forEach { if (it is ZapSplitSetup) { val user = LocalCache.getOrCreateUser(it.pubKeyHex) forwardZapTo.addItem(user, (it.weight / totalWeight).toFloat()) @@ -218,7 +218,7 @@ open class ChannelNewMessageViewModel : // don't support edditing old-style splits. } forwardZapToEditting = TextFieldValue("") - wantsForwardZapTo = localfowardZapTo.isNotEmpty() + wantsForwardZapTo = localForwardZapTo.isNotEmpty() wantsToMarkAsSensitive = draftEvent.isSensitive() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/NewCommunityNoteButton.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/NewCommunityNoteButton.kt index 158eab186..dcf84afab 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/NewCommunityNoteButton.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/NewCommunityNoteButton.kt @@ -57,7 +57,7 @@ fun NewCommunityNoteButton( FloatingActionButton( onClick = { val route = - Route.NewPost( + Route.NewShortNote( baseReplyTo = note.idHex, ) nav.nav(route) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/NewNoteButton.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/NewNoteButton.kt index cc87c14c6..6823cf817 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/NewNoteButton.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/NewNoteButton.kt @@ -38,7 +38,7 @@ import com.vitorpamplona.amethyst.ui.theme.Size55Modifier fun NewNoteButton(nav: INav) { FloatingActionButton( onClick = { - nav.nav(Route.NewPost()) + nav.nav(Route.NewShortNote()) }, modifier = Size55Modifier, shape = CircleShape, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt index 59d03e1c8..dd280e785 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt @@ -105,6 +105,7 @@ import kotlinx.coroutines.withContext fun NewPublicMessageScreen( to: Set? = null, reply: Note? = null, + draft: Note? = null, accountViewModel: AccountViewModel, nav: Nav, ) { @@ -119,6 +120,9 @@ fun NewPublicMessageScreen( reply?.let { postViewModel.reply(it) } + draft?.let { + postViewModel.editFromDraft(it) + } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt index e23281965..6628b659a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt @@ -431,7 +431,7 @@ fun ReactionsColumn( iconSize = Size40dp, onQuotePress = { nav.nav( - Route.NewPost( + Route.NewShortNote( quote = baseNote.idHex, ), )