Passing the Note, not the event to the Nest viewmodel
This commit is contained in:
+3
-1
@@ -45,6 +45,7 @@ import androidx.compose.ui.platform.LocalContext
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.commons.viewmodels.NestViewModel
|
import com.vitorpamplona.amethyst.commons.viewmodels.NestViewModel
|
||||||
|
import com.vitorpamplona.amethyst.model.AddressableNote
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.navs.BouncingIntentNav
|
import com.vitorpamplona.amethyst.ui.navigation.navs.BouncingIntentNav
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
@@ -80,6 +81,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel as composeViewModel
|
|||||||
@Composable
|
@Composable
|
||||||
internal fun ColumnScope.NestChatPanel(
|
internal fun ColumnScope.NestChatPanel(
|
||||||
event: MeetingSpaceEvent,
|
event: MeetingSpaceEvent,
|
||||||
|
roomNote: AddressableNote,
|
||||||
viewModel: NestViewModel,
|
viewModel: NestViewModel,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
@@ -94,7 +96,7 @@ internal fun ColumnScope.NestChatPanel(
|
|||||||
val nestScreenModel: NestNewMessageViewModel =
|
val nestScreenModel: NestNewMessageViewModel =
|
||||||
composeViewModel(key = "Nest/${event.address().toValue()}")
|
composeViewModel(key = "Nest/${event.address().toValue()}")
|
||||||
nestScreenModel.init(accountViewModel)
|
nestScreenModel.init(accountViewModel)
|
||||||
nestScreenModel.load(event)
|
nestScreenModel.load(roomNote)
|
||||||
|
|
||||||
val listState = rememberLazyListState()
|
val listState = rememberLazyListState()
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -27,19 +27,18 @@ import androidx.compose.foundation.layout.height
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
||||||
import com.vitorpamplona.amethyst.ui.note.UserPicture
|
import com.vitorpamplona.amethyst.ui.note.UserPicture
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.utils.ChatFileUploadDialog
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.utils.ChatFileUploadDialog
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.utils.ChatFileUploadState
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.utils.ChatFileUploadState
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size34dp
|
import com.vitorpamplona.amethyst.ui.theme.Size34dp
|
||||||
|
import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mirror of `ChannelFileUploadDialog` for nest chat. Wraps the
|
* Mirror of `ChannelFileUploadDialog` for nest chat. Wraps the
|
||||||
@@ -59,8 +58,8 @@ fun NestFileUploadDialog(
|
|||||||
val room = nestScreenModel.room ?: return
|
val room = nestScreenModel.room ?: return
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
val host = remember(room.pubKey) { LocalCache.getOrCreateUser(room.pubKey) }
|
val host = room.author ?: return
|
||||||
val title = room.room().orEmpty()
|
val title = (room.event as? MeetingSpaceEvent)?.room().orEmpty()
|
||||||
|
|
||||||
ChatFileUploadDialog(
|
ChatFileUploadDialog(
|
||||||
state,
|
state,
|
||||||
|
|||||||
+5
-15
@@ -36,6 +36,7 @@ import com.vitorpamplona.amethyst.R
|
|||||||
import com.vitorpamplona.amethyst.commons.compose.currentWord
|
import com.vitorpamplona.amethyst.commons.compose.currentWord
|
||||||
import com.vitorpamplona.amethyst.commons.compose.insertUrlAtCursor
|
import com.vitorpamplona.amethyst.commons.compose.insertUrlAtCursor
|
||||||
import com.vitorpamplona.amethyst.commons.compose.replaceCurrentWord
|
import com.vitorpamplona.amethyst.commons.compose.replaceCurrentWord
|
||||||
|
import com.vitorpamplona.amethyst.commons.model.AddressableNote
|
||||||
import com.vitorpamplona.amethyst.commons.model.nip30CustomEmojis.EmojiPackState
|
import com.vitorpamplona.amethyst.commons.model.nip30CustomEmojis.EmojiPackState
|
||||||
import com.vitorpamplona.amethyst.commons.richtext.UrlParser
|
import com.vitorpamplona.amethyst.commons.richtext.UrlParser
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
@@ -65,7 +66,6 @@ import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent
|
|||||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||||
import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
|
import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
|
||||||
import com.vitorpamplona.quartz.nip01Core.signers.SignerExceptions
|
import com.vitorpamplona.quartz.nip01Core.signers.SignerExceptions
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.aTag.ATag
|
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohash
|
import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohash
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.geohash.getGeoHash
|
import com.vitorpamplona.quartz.nip01Core.tags.geohash.getGeoHash
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtags
|
import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtags
|
||||||
@@ -133,7 +133,7 @@ open class NestNewMessageViewModel :
|
|||||||
|
|
||||||
lateinit var accountViewModel: AccountViewModel
|
lateinit var accountViewModel: AccountViewModel
|
||||||
lateinit var account: Account
|
lateinit var account: Account
|
||||||
var room: MeetingSpaceEvent? = null
|
var room: AddressableNote? = null
|
||||||
|
|
||||||
val replyTo = mutableStateOf<Note?>(null)
|
val replyTo = mutableStateOf<Note?>(null)
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ open class NestNewMessageViewModel :
|
|||||||
this.uploadState = ChatFileUploadState(account.settings.defaultFileServer, account.settings.stripLocationOnUpload)
|
this.uploadState = ChatFileUploadState(account.settings.defaultFileServer, account.settings.stripLocationOnUpload)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun load(room: MeetingSpaceEvent) {
|
open fun load(room: AddressableNote) {
|
||||||
this.room = room
|
this.room = room
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,18 +397,8 @@ open class NestNewMessageViewModel :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun roomATag(): ATag? {
|
|
||||||
val r = room ?: return null
|
|
||||||
return ATag(
|
|
||||||
kind = r.kind,
|
|
||||||
pubKeyHex = r.pubKey,
|
|
||||||
dTag = r.dTag(),
|
|
||||||
relay = null,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun createTemplate(): EventTemplate<out Event>? {
|
private suspend fun createTemplate(): EventTemplate<out Event>? {
|
||||||
val activity = roomATag() ?: return null
|
val room = room?.toEventHint<MeetingSpaceEvent>() ?: return null
|
||||||
val messageText = message.text.toString()
|
val messageText = message.text.toString()
|
||||||
val tagger =
|
val tagger =
|
||||||
NewMessageTagger(
|
NewMessageTagger(
|
||||||
@@ -446,7 +436,7 @@ open class NestNewMessageViewModel :
|
|||||||
imetas(usedAttachments)
|
imetas(usedAttachments)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LiveActivitiesChatMessageEvent.message(tagger.message, activity) {
|
LiveActivitiesChatMessageEvent.roomMessage(tagger.message, room) {
|
||||||
hashtags(findHashtags(tagger.message))
|
hashtags(findHashtags(tagger.message))
|
||||||
references(findURLs(tagger.message))
|
references(findURLs(tagger.message))
|
||||||
quotes(findNostrUris(tagger.message))
|
quotes(findNostrUris(tagger.message))
|
||||||
|
|||||||
+1
-1
@@ -147,7 +147,7 @@ private fun NestLobbyContent(
|
|||||||
val nestScreenModel: NestNewMessageViewModel =
|
val nestScreenModel: NestNewMessageViewModel =
|
||||||
viewModel(key = "NestLobby/$roomATag")
|
viewModel(key = "NestLobby/$roomATag")
|
||||||
nestScreenModel.init(accountViewModel)
|
nestScreenModel.init(accountViewModel)
|
||||||
nestScreenModel.load(event)
|
nestScreenModel.load(addressableNote)
|
||||||
|
|
||||||
val messages by produceState(initialValue = emptyList<Note>(), roomATag) {
|
val messages by produceState(initialValue = emptyList<Note>(), roomATag) {
|
||||||
val filter =
|
val filter =
|
||||||
|
|||||||
+1
@@ -276,6 +276,7 @@ internal fun NestFullScreen(
|
|||||||
NestTab.Chat -> {
|
NestTab.Chat -> {
|
||||||
NestChatPanel(
|
NestChatPanel(
|
||||||
event = event,
|
event = event,
|
||||||
|
roomNote = roomNote,
|
||||||
viewModel = viewModel,
|
viewModel = viewModel,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
modifier =
|
modifier =
|
||||||
|
|||||||
+11
@@ -47,6 +47,7 @@ import com.vitorpamplona.quartz.nip19Bech32.pubKeyHints
|
|||||||
import com.vitorpamplona.quartz.nip19Bech32.pubKeys
|
import com.vitorpamplona.quartz.nip19Bech32.pubKeys
|
||||||
import com.vitorpamplona.quartz.nip37Drafts.ExposeInDraft
|
import com.vitorpamplona.quartz.nip37Drafts.ExposeInDraft
|
||||||
import com.vitorpamplona.quartz.nip50Search.SearchableEvent
|
import com.vitorpamplona.quartz.nip50Search.SearchableEvent
|
||||||
|
import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent
|
||||||
import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent
|
import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent
|
||||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||||
|
|
||||||
@@ -153,6 +154,16 @@ class LiveActivitiesChatMessageEvent(
|
|||||||
initializer()
|
initializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun roomMessage(
|
||||||
|
post: String,
|
||||||
|
room: EventHintBundle<MeetingSpaceEvent>,
|
||||||
|
createdAt: Long = TimeUtils.now(),
|
||||||
|
initializer: TagArrayBuilder<LiveActivitiesChatMessageEvent>.() -> Unit = {},
|
||||||
|
) = eventTemplate(KIND, post, createdAt) {
|
||||||
|
room(room)
|
||||||
|
initializer()
|
||||||
|
}
|
||||||
|
|
||||||
fun message(
|
fun message(
|
||||||
post: String,
|
post: String,
|
||||||
activity: ATag,
|
activity: ATag,
|
||||||
|
|||||||
+3
@@ -29,10 +29,13 @@ import com.vitorpamplona.quartz.nip01Core.tags.people.pTag
|
|||||||
import com.vitorpamplona.quartz.nip01Core.tags.people.pTags
|
import com.vitorpamplona.quartz.nip01Core.tags.people.pTags
|
||||||
import com.vitorpamplona.quartz.nip10Notes.tags.MarkedETag
|
import com.vitorpamplona.quartz.nip10Notes.tags.MarkedETag
|
||||||
import com.vitorpamplona.quartz.nip10Notes.tags.toMarkedETag
|
import com.vitorpamplona.quartz.nip10Notes.tags.toMarkedETag
|
||||||
|
import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent
|
||||||
import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent
|
import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent
|
||||||
|
|
||||||
fun TagArrayBuilder<LiveActivitiesChatMessageEvent>.activity(rep: ATag) = addUnique(rep.toATagArray())
|
fun TagArrayBuilder<LiveActivitiesChatMessageEvent>.activity(rep: ATag) = addUnique(rep.toATagArray())
|
||||||
|
|
||||||
|
fun TagArrayBuilder<LiveActivitiesChatMessageEvent>.room(rep: EventHintBundle<MeetingSpaceEvent>) = addUnique(rep.toATag().toATagArray())
|
||||||
|
|
||||||
fun TagArrayBuilder<LiveActivitiesChatMessageEvent>.activity(rep: EventHintBundle<LiveActivitiesEvent>) = addUnique(rep.toATag().toATagArray())
|
fun TagArrayBuilder<LiveActivitiesChatMessageEvent>.activity(rep: EventHintBundle<LiveActivitiesEvent>) = addUnique(rep.toATag().toATagArray())
|
||||||
|
|
||||||
fun TagArrayBuilder<LiveActivitiesChatMessageEvent>.reply(rep: EventHintBundle<LiveActivitiesChatMessageEvent>) = addUnique(rep.toMarkedETag(MarkedETag.MARKER.REPLY).toTagArray())
|
fun TagArrayBuilder<LiveActivitiesChatMessageEvent>.reply(rep: EventHintBundle<LiveActivitiesChatMessageEvent>) = addUnique(rep.toMarkedETag(MarkedETag.MARKER.REPLY).toTagArray())
|
||||||
|
|||||||
Reference in New Issue
Block a user