Merge pull request #1933 from vitorpamplona/claude/improve-navhost-performance-AE9WZ
perf: move cache lookups from NavHost route lambdas into screen composables
This commit is contained in:
@@ -130,10 +130,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.wallet.WalletSendScreen
|
|||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.wallet.WalletTransactionsScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.wallet.WalletTransactionsScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedOff.AddAccountDialog
|
import com.vitorpamplona.amethyst.ui.screen.loggedOff.AddAccountDialog
|
||||||
import com.vitorpamplona.amethyst.ui.uriToRoute
|
import com.vitorpamplona.amethyst.ui.uriToRoute
|
||||||
import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId
|
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Address
|
import com.vitorpamplona.quartz.nip01Core.core.Address
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
|
|
||||||
import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent
|
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.Nip19Parser
|
import com.vitorpamplona.quartz.nip19Bech32.Nip19Parser
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -209,11 +206,7 @@ fun AppNavigation(
|
|||||||
composableFromEnd<Route.ReactionsSettings> { ReactionsSettingsScreen(accountViewModel, nav) }
|
composableFromEnd<Route.ReactionsSettings> { ReactionsSettingsScreen(accountViewModel, nav) }
|
||||||
composableFromEnd<Route.ImportFollowsSelectUser> { ImportFollowListSelectUserScreen(accountViewModel, nav) }
|
composableFromEnd<Route.ImportFollowsSelectUser> { ImportFollowListSelectUserScreen(accountViewModel, nav) }
|
||||||
composableFromEndArgs<Route.ImportFollowsPickFollows> {
|
composableFromEndArgs<Route.ImportFollowsPickFollows> {
|
||||||
ImportFollowListPickFollowsScreen(
|
ImportFollowListPickFollowsScreen(it.userHex, accountViewModel, nav)
|
||||||
accountViewModel.getOrCreateAddressableNote(ContactListEvent.createAddress(it.userHex)),
|
|
||||||
accountViewModel,
|
|
||||||
nav,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
composableFromEndArgs<Route.Nip47NWCSetup> { NIP47SetupScreen(accountViewModel, nav, it.nip47) }
|
composableFromEndArgs<Route.Nip47NWCSetup> { NIP47SetupScreen(accountViewModel, nav, it.nip47) }
|
||||||
@@ -238,35 +231,28 @@ fun AppNavigation(
|
|||||||
composableFromEndArgs<Route.RoomByAuthor> { ChatroomByAuthorScreen(it.id, null, accountViewModel, nav) }
|
composableFromEndArgs<Route.RoomByAuthor> { ChatroomByAuthorScreen(it.id, null, accountViewModel, nav) }
|
||||||
|
|
||||||
composableFromEndArgs<Route.PublicChatChannel> {
|
composableFromEndArgs<Route.PublicChatChannel> {
|
||||||
PublicChatChannelScreen(
|
PublicChatChannelScreen(it.id, it.draftId, it.replyTo, accountViewModel, nav)
|
||||||
it.id,
|
|
||||||
it.draftId?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
|
||||||
it.replyTo?.let { hex -> accountViewModel.checkGetOrCreateNote(hex) },
|
|
||||||
accountViewModel,
|
|
||||||
nav,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
composableFromEndArgs<Route.LiveActivityChannel> {
|
composableFromEndArgs<Route.LiveActivityChannel> {
|
||||||
LiveActivityChannelScreen(
|
LiveActivityChannelScreen(
|
||||||
Address(it.kind, it.pubKeyHex, it.dTag),
|
Address(it.kind, it.pubKeyHex, it.dTag),
|
||||||
draft = it.draftId?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
draftId = it.draftId,
|
||||||
replyTo = it.replyTo?.let { hex -> accountViewModel.checkGetOrCreateNote(hex) },
|
replyToId = it.replyTo,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
composableFromEndArgs<Route.EphemeralChat> {
|
composableFromEndArgs<Route.EphemeralChat> {
|
||||||
RelayUrlNormalizer.normalizeOrNull(it.relayUrl)?.let { relay ->
|
EphemeralChatScreen(
|
||||||
EphemeralChatScreen(
|
id = it.id,
|
||||||
channelId = RoomId(it.id, relay),
|
relayUrl = it.relayUrl,
|
||||||
draft = it.draftId?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
draftId = it.draftId,
|
||||||
replyTo = it.replyTo?.let { hex -> accountViewModel.checkGetOrCreateNote(hex) },
|
replyToId = it.replyTo,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
composableFromBottomArgs<Route.ChannelMetadataEdit> { ChannelMetadataScreen(it.id, accountViewModel, nav) }
|
composableFromBottomArgs<Route.ChannelMetadataEdit> { ChannelMetadataScreen(it.id, accountViewModel, nav) }
|
||||||
@@ -280,9 +266,9 @@ fun AppNavigation(
|
|||||||
geohash = it.geohash,
|
geohash = it.geohash,
|
||||||
message = it.message,
|
message = it.message,
|
||||||
attachment = it.attachment?.ifBlank { null }?.toUri(),
|
attachment = it.attachment?.ifBlank { null }?.toUri(),
|
||||||
reply = it.replyTo?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
replyId = it.replyTo,
|
||||||
quote = it.quote?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
quoteId = it.quote,
|
||||||
draft = it.draft?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
draftId = it.draft,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
@@ -291,8 +277,8 @@ fun AppNavigation(
|
|||||||
composableFromBottomArgs<Route.NewPublicMessage> {
|
composableFromBottomArgs<Route.NewPublicMessage> {
|
||||||
NewPublicMessageScreen(
|
NewPublicMessageScreen(
|
||||||
to = it.toKey(),
|
to = it.toKey(),
|
||||||
reply = it.replyId?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
replyId = it.replyId,
|
||||||
draft = it.draftId?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
draftId = it.draftId,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
@@ -303,9 +289,9 @@ fun AppNavigation(
|
|||||||
hashtag = it.hashtag,
|
hashtag = it.hashtag,
|
||||||
message = it.message,
|
message = it.message,
|
||||||
attachment = it.attachment?.ifBlank { null }?.toUri(),
|
attachment = it.attachment?.ifBlank { null }?.toUri(),
|
||||||
reply = it.replyTo?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
replyId = it.replyTo,
|
||||||
quote = it.quote?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
quoteId = it.quote,
|
||||||
draft = it.draft?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
draftId = it.draft,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
@@ -313,11 +299,11 @@ fun AppNavigation(
|
|||||||
|
|
||||||
composableFromBottomArgs<Route.GenericCommentPost> {
|
composableFromBottomArgs<Route.GenericCommentPost> {
|
||||||
ReplyCommentPostScreen(
|
ReplyCommentPostScreen(
|
||||||
reply = it.replyTo?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
replyId = it.replyTo,
|
||||||
message = it.message,
|
message = it.message,
|
||||||
attachment = it.attachment?.ifBlank { null }?.toUri(),
|
attachment = it.attachment?.ifBlank { null }?.toUri(),
|
||||||
quote = it.quote?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
quoteId = it.quote,
|
||||||
draft = it.draft?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
draftId = it.draft,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
@@ -327,8 +313,8 @@ fun AppNavigation(
|
|||||||
NewProductScreen(
|
NewProductScreen(
|
||||||
message = it.message,
|
message = it.message,
|
||||||
attachment = it.attachment?.ifBlank { null }?.toUri(),
|
attachment = it.attachment?.ifBlank { null }?.toUri(),
|
||||||
quote = it.quote?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
quoteId = it.quote,
|
||||||
draft = it.draft?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
draftId = it.draft,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
@@ -336,8 +322,8 @@ fun AppNavigation(
|
|||||||
|
|
||||||
composableFromBottomArgs<Route.NewLongFormPost> {
|
composableFromBottomArgs<Route.NewLongFormPost> {
|
||||||
LongFormPostScreen(
|
LongFormPostScreen(
|
||||||
draft = it.draft?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
draftId = it.draft,
|
||||||
version = it.version?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
versionId = it.version,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
@@ -347,11 +333,11 @@ fun AppNavigation(
|
|||||||
ShortNotePostScreen(
|
ShortNotePostScreen(
|
||||||
message = it.message,
|
message = it.message,
|
||||||
attachment = it.attachment?.ifBlank { null }?.toUri(),
|
attachment = it.attachment?.ifBlank { null }?.toUri(),
|
||||||
baseReplyTo = it.baseReplyTo?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
baseReplyToId = it.baseReplyTo,
|
||||||
quote = it.quote?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
quoteId = it.quote,
|
||||||
fork = it.fork?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
forkId = it.fork,
|
||||||
version = it.version?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
versionId = it.version,
|
||||||
draft = it.draft?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
draftId = it.draft,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
+7
-7
@@ -47,7 +47,6 @@ import androidx.compose.ui.text.input.TextFieldValue
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
|
||||||
import com.vitorpamplona.amethyst.ui.actions.StrippingFailureDialog
|
import com.vitorpamplona.amethyst.ui.actions.StrippingFailureDialog
|
||||||
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromFiles
|
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromFiles
|
||||||
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromGallery
|
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromGallery
|
||||||
@@ -87,6 +86,7 @@ import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
|
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
|
||||||
import com.vitorpamplona.amethyst.ui.theme.replyModifier
|
import com.vitorpamplona.amethyst.ui.theme.replyModifier
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -94,11 +94,11 @@ import kotlinx.coroutines.withContext
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ReplyCommentPostScreen(
|
fun ReplyCommentPostScreen(
|
||||||
reply: Note? = null,
|
replyId: HexKey? = null,
|
||||||
message: String? = null,
|
message: String? = null,
|
||||||
attachment: Uri? = null,
|
attachment: Uri? = null,
|
||||||
quote: Note? = null,
|
quoteId: HexKey? = null,
|
||||||
draft: Note? = null,
|
draftId: HexKey? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: Nav,
|
nav: Nav,
|
||||||
) {
|
) {
|
||||||
@@ -108,13 +108,13 @@ fun ReplyCommentPostScreen(
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
LaunchedEffect(postViewModel, accountViewModel) {
|
LaunchedEffect(postViewModel, accountViewModel) {
|
||||||
reply?.let {
|
replyId?.let { accountViewModel.getNoteIfExists(it) }?.let {
|
||||||
postViewModel.reply(it)
|
postViewModel.reply(it)
|
||||||
}
|
}
|
||||||
draft?.let {
|
draftId?.let { accountViewModel.getNoteIfExists(it) }?.let {
|
||||||
postViewModel.editFromDraft(it)
|
postViewModel.editFromDraft(it)
|
||||||
}
|
}
|
||||||
quote?.let {
|
quoteId?.let { accountViewModel.getNoteIfExists(it) }?.let {
|
||||||
postViewModel.quote(it)
|
postViewModel.quote(it)
|
||||||
}
|
}
|
||||||
message?.ifBlank { null }?.let {
|
message?.ifBlank { null }?.let {
|
||||||
|
|||||||
+12
-4
@@ -23,22 +23,30 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.ephem
|
|||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
|
||||||
import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold
|
import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.ephemChat.header.EphemeralChatTopBar
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.ephemChat.header.EphemeralChatTopBar
|
||||||
import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId
|
import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun EphemeralChatScreen(
|
fun EphemeralChatScreen(
|
||||||
channelId: RoomId,
|
id: HexKey,
|
||||||
draft: Note? = null,
|
relayUrl: String,
|
||||||
replyTo: Note? = null,
|
draftId: HexKey? = null,
|
||||||
|
replyToId: HexKey? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
|
val relay = remember(relayUrl) { RelayUrlNormalizer.normalizeOrNull(relayUrl) } ?: return
|
||||||
|
val channelId = remember(id, relay) { RoomId(id, relay) }
|
||||||
|
val draft = remember(draftId) { draftId?.let { accountViewModel.getNoteIfExists(it) } }
|
||||||
|
val replyTo = remember(replyToId) { replyToId?.let { accountViewModel.checkGetOrCreateNote(it) } }
|
||||||
|
|
||||||
DisappearingScaffold(
|
DisappearingScaffold(
|
||||||
isInvertedLayout = true,
|
isInvertedLayout = true,
|
||||||
topBar = {
|
topBar = {
|
||||||
|
|||||||
+6
-3
@@ -23,8 +23,8 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.nip28
|
|||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
|
||||||
import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold
|
import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
||||||
import com.vitorpamplona.amethyst.ui.note.LoadPublicChatChannel
|
import com.vitorpamplona.amethyst.ui.note.LoadPublicChatChannel
|
||||||
@@ -35,13 +35,16 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
|||||||
@Composable
|
@Composable
|
||||||
fun PublicChatChannelScreen(
|
fun PublicChatChannelScreen(
|
||||||
channelId: HexKey?,
|
channelId: HexKey?,
|
||||||
draft: Note?,
|
draftId: HexKey? = null,
|
||||||
replyTo: Note? = null,
|
replyToId: HexKey? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
if (channelId == null) return
|
if (channelId == null) return
|
||||||
|
|
||||||
|
val draft = remember(draftId) { draftId?.let { accountViewModel.getNoteIfExists(it) } }
|
||||||
|
val replyTo = remember(replyToId) { replyToId?.let { accountViewModel.checkGetOrCreateNote(it) } }
|
||||||
|
|
||||||
DisappearingScaffold(
|
DisappearingScaffold(
|
||||||
isInvertedLayout = true,
|
isInvertedLayout = true,
|
||||||
topBar = {
|
topBar = {
|
||||||
|
|||||||
+7
-3
@@ -24,8 +24,8 @@ import androidx.compose.foundation.layout.Column
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
|
||||||
import com.vitorpamplona.amethyst.service.OnlineChecker
|
import com.vitorpamplona.amethyst.service.OnlineChecker
|
||||||
import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold
|
import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
||||||
@@ -33,17 +33,21 @@ import com.vitorpamplona.amethyst.ui.note.LoadLiveActivityChannel
|
|||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.nip53LiveActivities.header.LiveActivityTopBar
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.nip53LiveActivities.header.LiveActivityTopBar
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Address
|
import com.vitorpamplona.quartz.nip01Core.core.Address
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LiveActivityChannelScreen(
|
fun LiveActivityChannelScreen(
|
||||||
channelId: Address?,
|
channelId: Address?,
|
||||||
draft: Note? = null,
|
draftId: HexKey? = null,
|
||||||
replyTo: Note? = null,
|
replyToId: HexKey? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
if (channelId == null) return
|
if (channelId == null) return
|
||||||
|
|
||||||
|
val draft = remember(draftId) { draftId?.let { accountViewModel.getNoteIfExists(it) } }
|
||||||
|
val replyTo = remember(replyToId) { replyToId?.let { accountViewModel.checkGetOrCreateNote(it) } }
|
||||||
|
|
||||||
DisappearingScaffold(
|
DisappearingScaffold(
|
||||||
isInvertedLayout = true,
|
isInvertedLayout = true,
|
||||||
topBar = {
|
topBar = {
|
||||||
|
|||||||
+5
-3
@@ -61,7 +61,6 @@ import androidx.compose.ui.unit.sp
|
|||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.commons.model.EmptyTagList
|
import com.vitorpamplona.amethyst.commons.model.EmptyTagList
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
|
||||||
import com.vitorpamplona.amethyst.ui.actions.StrippingFailureDialog
|
import com.vitorpamplona.amethyst.ui.actions.StrippingFailureDialog
|
||||||
import com.vitorpamplona.amethyst.ui.actions.UrlUserTagTransformation
|
import com.vitorpamplona.amethyst.ui.actions.UrlUserTagTransformation
|
||||||
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromFiles
|
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromFiles
|
||||||
@@ -98,12 +97,13 @@ import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
|
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
|
||||||
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun LongFormPostScreen(
|
fun LongFormPostScreen(
|
||||||
draft: Note? = null,
|
draftId: HexKey? = null,
|
||||||
version: Note? = null,
|
versionId: HexKey? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: Nav,
|
nav: Nav,
|
||||||
) {
|
) {
|
||||||
@@ -111,6 +111,8 @@ fun LongFormPostScreen(
|
|||||||
postViewModel.init(accountViewModel)
|
postViewModel.init(accountViewModel)
|
||||||
|
|
||||||
LaunchedEffect(postViewModel, accountViewModel) {
|
LaunchedEffect(postViewModel, accountViewModel) {
|
||||||
|
val draft = draftId?.let { accountViewModel.getNoteIfExists(it) }
|
||||||
|
val version = versionId?.let { accountViewModel.getNoteIfExists(it) }
|
||||||
postViewModel.load(draft, version)
|
postViewModel.load(draft, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -46,7 +46,6 @@ import androidx.compose.ui.text.input.TextFieldValue
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
|
||||||
import com.vitorpamplona.amethyst.ui.actions.StrippingFailureDialog
|
import com.vitorpamplona.amethyst.ui.actions.StrippingFailureDialog
|
||||||
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromFiles
|
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromFiles
|
||||||
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromGallery
|
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromGallery
|
||||||
@@ -83,6 +82,7 @@ import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
|
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.FlowPreview
|
import kotlinx.coroutines.FlowPreview
|
||||||
@@ -93,8 +93,8 @@ import kotlinx.coroutines.withContext
|
|||||||
fun NewProductScreen(
|
fun NewProductScreen(
|
||||||
message: String? = null,
|
message: String? = null,
|
||||||
attachment: Uri? = null,
|
attachment: Uri? = null,
|
||||||
quote: Note? = null,
|
quoteId: HexKey? = null,
|
||||||
draft: Note? = null,
|
draftId: HexKey? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: Nav,
|
nav: Nav,
|
||||||
) {
|
) {
|
||||||
@@ -105,10 +105,10 @@ fun NewProductScreen(
|
|||||||
|
|
||||||
LaunchedEffect(postViewModel, accountViewModel) {
|
LaunchedEffect(postViewModel, accountViewModel) {
|
||||||
postViewModel.reloadRelaySet()
|
postViewModel.reloadRelaySet()
|
||||||
draft?.let {
|
draftId?.let { accountViewModel.getNoteIfExists(it) }?.let {
|
||||||
postViewModel.editFromDraft(it)
|
postViewModel.editFromDraft(it)
|
||||||
}
|
}
|
||||||
quote?.let {
|
quoteId?.let { accountViewModel.getNoteIfExists(it) }?.let {
|
||||||
postViewModel.quote(it)
|
postViewModel.quote(it)
|
||||||
}
|
}
|
||||||
message?.ifBlank { null }?.let {
|
message?.ifBlank { null }?.let {
|
||||||
|
|||||||
+7
-7
@@ -26,12 +26,12 @@ import androidx.compose.runtime.LaunchedEffect
|
|||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.input.TextFieldValue
|
import androidx.compose.ui.text.input.TextFieldValue
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
|
||||||
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectedMedia
|
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectedMedia
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.navs.Nav
|
import com.vitorpamplona.amethyst.ui.navigation.navs.Nav
|
||||||
import com.vitorpamplona.amethyst.ui.note.nip22Comments.CommentPostViewModel
|
import com.vitorpamplona.amethyst.ui.note.nip22Comments.CommentPostViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.note.nip22Comments.GenericCommentPostScreen
|
import com.vitorpamplona.amethyst.ui.note.nip22Comments.GenericCommentPostScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
import com.vitorpamplona.quartz.nip73ExternalIds.location.GeohashId
|
import com.vitorpamplona.quartz.nip73ExternalIds.location.GeohashId
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -42,9 +42,9 @@ fun GeoHashPostScreen(
|
|||||||
geohash: String? = null,
|
geohash: String? = null,
|
||||||
message: String? = null,
|
message: String? = null,
|
||||||
attachment: Uri? = null,
|
attachment: Uri? = null,
|
||||||
reply: Note? = null,
|
replyId: HexKey? = null,
|
||||||
quote: Note? = null,
|
quoteId: HexKey? = null,
|
||||||
draft: Note? = null,
|
draftId: HexKey? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: Nav,
|
nav: Nav,
|
||||||
) {
|
) {
|
||||||
@@ -57,13 +57,13 @@ fun GeoHashPostScreen(
|
|||||||
geohash?.let {
|
geohash?.let {
|
||||||
postViewModel.newPostFor(GeohashId(it))
|
postViewModel.newPostFor(GeohashId(it))
|
||||||
}
|
}
|
||||||
reply?.let {
|
replyId?.let { accountViewModel.getNoteIfExists(it) }?.let {
|
||||||
postViewModel.reply(it)
|
postViewModel.reply(it)
|
||||||
}
|
}
|
||||||
draft?.let {
|
draftId?.let { accountViewModel.getNoteIfExists(it) }?.let {
|
||||||
postViewModel.editFromDraft(it)
|
postViewModel.editFromDraft(it)
|
||||||
}
|
}
|
||||||
quote?.let {
|
quoteId?.let { accountViewModel.getNoteIfExists(it) }?.let {
|
||||||
postViewModel.quote(it)
|
postViewModel.quote(it)
|
||||||
}
|
}
|
||||||
message?.ifBlank { null }?.let {
|
message?.ifBlank { null }?.let {
|
||||||
|
|||||||
+7
-7
@@ -26,12 +26,12 @@ import androidx.compose.runtime.LaunchedEffect
|
|||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.input.TextFieldValue
|
import androidx.compose.ui.text.input.TextFieldValue
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
|
||||||
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectedMedia
|
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectedMedia
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.navs.Nav
|
import com.vitorpamplona.amethyst.ui.navigation.navs.Nav
|
||||||
import com.vitorpamplona.amethyst.ui.note.nip22Comments.CommentPostViewModel
|
import com.vitorpamplona.amethyst.ui.note.nip22Comments.CommentPostViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.note.nip22Comments.GenericCommentPostScreen
|
import com.vitorpamplona.amethyst.ui.note.nip22Comments.GenericCommentPostScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
import com.vitorpamplona.quartz.nip73ExternalIds.topics.HashtagId
|
import com.vitorpamplona.quartz.nip73ExternalIds.topics.HashtagId
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -42,9 +42,9 @@ fun HashtagPostScreen(
|
|||||||
hashtag: String? = null,
|
hashtag: String? = null,
|
||||||
message: String? = null,
|
message: String? = null,
|
||||||
attachment: Uri? = null,
|
attachment: Uri? = null,
|
||||||
reply: Note? = null,
|
replyId: HexKey? = null,
|
||||||
quote: Note? = null,
|
quoteId: HexKey? = null,
|
||||||
draft: Note? = null,
|
draftId: HexKey? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: Nav,
|
nav: Nav,
|
||||||
) {
|
) {
|
||||||
@@ -57,13 +57,13 @@ fun HashtagPostScreen(
|
|||||||
hashtag?.let {
|
hashtag?.let {
|
||||||
postViewModel.newPostFor(HashtagId(it))
|
postViewModel.newPostFor(HashtagId(it))
|
||||||
}
|
}
|
||||||
reply?.let {
|
replyId?.let { accountViewModel.getNoteIfExists(it) }?.let {
|
||||||
postViewModel.reply(it)
|
postViewModel.reply(it)
|
||||||
}
|
}
|
||||||
draft?.let {
|
draftId?.let { accountViewModel.getNoteIfExists(it) }?.let {
|
||||||
postViewModel.editFromDraft(it)
|
postViewModel.editFromDraft(it)
|
||||||
}
|
}
|
||||||
quote?.let {
|
quoteId?.let { accountViewModel.getNoteIfExists(it) }?.let {
|
||||||
postViewModel.quote(it)
|
postViewModel.quote(it)
|
||||||
}
|
}
|
||||||
message?.ifBlank { null }?.let {
|
message?.ifBlank { null }?.let {
|
||||||
|
|||||||
+11
-6
@@ -59,7 +59,6 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.core.util.Consumer
|
import androidx.core.util.Consumer
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
|
||||||
import com.vitorpamplona.amethyst.ui.actions.StrippingFailureDialog
|
import com.vitorpamplona.amethyst.ui.actions.StrippingFailureDialog
|
||||||
import com.vitorpamplona.amethyst.ui.actions.mediaServers.FileServerSelectionRow
|
import com.vitorpamplona.amethyst.ui.actions.mediaServers.FileServerSelectionRow
|
||||||
import com.vitorpamplona.amethyst.ui.actions.uploads.MAX_VOICE_RECORD_SECONDS
|
import com.vitorpamplona.amethyst.ui.actions.uploads.MAX_VOICE_RECORD_SECONDS
|
||||||
@@ -112,6 +111,7 @@ import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
|
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
|
||||||
import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn
|
import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn
|
||||||
import com.vitorpamplona.amethyst.ui.theme.replyModifier
|
import com.vitorpamplona.amethyst.ui.theme.replyModifier
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -123,11 +123,11 @@ import kotlinx.coroutines.withContext
|
|||||||
fun ShortNotePostScreen(
|
fun ShortNotePostScreen(
|
||||||
message: String? = null,
|
message: String? = null,
|
||||||
attachment: Uri? = null,
|
attachment: Uri? = null,
|
||||||
baseReplyTo: Note? = null,
|
baseReplyToId: HexKey? = null,
|
||||||
quote: Note? = null,
|
quoteId: HexKey? = null,
|
||||||
fork: Note? = null,
|
forkId: HexKey? = null,
|
||||||
version: Note? = null,
|
versionId: HexKey? = null,
|
||||||
draft: Note? = null,
|
draftId: HexKey? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: Nav,
|
nav: Nav,
|
||||||
) {
|
) {
|
||||||
@@ -138,6 +138,11 @@ fun ShortNotePostScreen(
|
|||||||
val activity = context.getActivity()
|
val activity = context.getActivity()
|
||||||
|
|
||||||
LaunchedEffect(postViewModel, accountViewModel) {
|
LaunchedEffect(postViewModel, accountViewModel) {
|
||||||
|
val baseReplyTo = baseReplyToId?.let { accountViewModel.getNoteIfExists(it) }
|
||||||
|
val quote = quoteId?.let { accountViewModel.getNoteIfExists(it) }
|
||||||
|
val fork = forkId?.let { accountViewModel.getNoteIfExists(it) }
|
||||||
|
val version = versionId?.let { accountViewModel.getNoteIfExists(it) }
|
||||||
|
val draft = draftId?.let { accountViewModel.getNoteIfExists(it) }
|
||||||
postViewModel.load(baseReplyTo, quote, fork, version, draft)
|
postViewModel.load(baseReplyTo, quote, fork, version, draft)
|
||||||
message?.ifBlank { null }?.let {
|
message?.ifBlank { null }?.let {
|
||||||
postViewModel.updateMessage(TextFieldValue(it))
|
postViewModel.updateMessage(TextFieldValue(it))
|
||||||
|
|||||||
+7
-1
@@ -68,16 +68,22 @@ import com.vitorpamplona.amethyst.ui.note.creators.userSuggestions.UserLine
|
|||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayFollowList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayFollowList
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.stringRes
|
import com.vitorpamplona.amethyst.ui.stringRes
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent
|
import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
import kotlinx.collections.immutable.toPersistentList
|
import kotlinx.collections.immutable.toPersistentList
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ImportFollowListPickFollowsScreen(
|
fun ImportFollowListPickFollowsScreen(
|
||||||
contactListNote: AddressableNote,
|
userHex: HexKey,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
|
val contactListNote =
|
||||||
|
remember(userHex) {
|
||||||
|
accountViewModel.getOrCreateAddressableNote(ContactListEvent.createAddress(userHex))
|
||||||
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
topBar = {
|
topBar = {
|
||||||
|
|||||||
+4
-5
@@ -55,7 +55,6 @@ import androidx.compose.ui.text.font.FontWeight
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
|
||||||
import com.vitorpamplona.amethyst.ui.actions.StrippingFailureDialog
|
import com.vitorpamplona.amethyst.ui.actions.StrippingFailureDialog
|
||||||
import com.vitorpamplona.amethyst.ui.actions.UrlUserTagTransformation
|
import com.vitorpamplona.amethyst.ui.actions.UrlUserTagTransformation
|
||||||
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromFiles
|
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromFiles
|
||||||
@@ -108,8 +107,8 @@ import kotlinx.coroutines.withContext
|
|||||||
@Composable
|
@Composable
|
||||||
fun NewPublicMessageScreen(
|
fun NewPublicMessageScreen(
|
||||||
to: Set<HexKey>? = null,
|
to: Set<HexKey>? = null,
|
||||||
reply: Note? = null,
|
replyId: HexKey? = null,
|
||||||
draft: Note? = null,
|
draftId: HexKey? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: Nav,
|
nav: Nav,
|
||||||
) {
|
) {
|
||||||
@@ -121,10 +120,10 @@ fun NewPublicMessageScreen(
|
|||||||
to?.let {
|
to?.let {
|
||||||
postViewModel.load(it)
|
postViewModel.load(it)
|
||||||
}
|
}
|
||||||
reply?.let {
|
replyId?.let { accountViewModel.getNoteIfExists(it) }?.let {
|
||||||
postViewModel.reply(it)
|
postViewModel.reply(it)
|
||||||
}
|
}
|
||||||
draft?.let {
|
draftId?.let { accountViewModel.getNoteIfExists(it) }?.let {
|
||||||
postViewModel.editFromDraft(it)
|
postViewModel.editFromDraft(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user