support for dms, streams and communities

This commit is contained in:
greenart7c3
2024-03-18 16:18:12 -03:00
parent 8b3e3e7af8
commit f6e5af3e98
5 changed files with 40 additions and 8 deletions
@@ -1756,6 +1756,7 @@ class Account(
zapRaiserAmount: Long? = null,
geohash: String? = null,
nip94attachments: List<FileHeaderEvent>? = null,
draftTag: String? = null,
) {
if (!isWriteable()) return
@@ -1773,9 +1774,19 @@ class Account(
zapRaiserAmount = zapRaiserAmount,
geohash = geohash,
nip94attachments = nip94attachments,
draftTag = draftTag,
signer = signer,
) {
broadcastPrivately(it)
if (draftTag != null) {
DraftEvent.create(draftTag, it.msg, signer) { draftEvent ->
Client.send(draftEvent)
LocalCache.justConsume(draftEvent, null)
LocalCache.justConsume(it.msg, null)
LocalCache.addDraft(draftTag, it.msg.id())
}
} else {
broadcastPrivately(it)
}
}
}
@@ -339,7 +339,7 @@ open class NewPostViewModel() : ViewModel() {
}
eTags =
draft.event?.tags()?.filter { it.size > 1 && it[0] == "e" && it.getOrNull(3) != "fork" }?.mapNotNull {
draft.event?.tags()?.filter { it.size > 1 && (it[0] == "e" || it[0] == "a") && it.getOrNull(3) != "fork" }?.mapNotNull {
val note = LocalCache.checkGetOrCreateNote(it[1])
note
}
@@ -349,13 +349,13 @@ open class NewPostViewModel() : ViewModel() {
LocalCache.getOrCreateUser(it[1])
}
draft.event?.tags()?.filter { it.size > 1 && it[0] == "e" && it.getOrNull(3) == "fork" }?.forEach {
draft.event?.tags()?.filter { it.size > 1 && (it[0] == "e" || it[0] == "a") && it.getOrNull(3) == "fork" }?.forEach {
val note = LocalCache.checkGetOrCreateNote(it[1])
forkedFromNote = note
}
originalNote =
draft.event?.tags()?.filter { it.size > 1 && it[0] == "e" && it.getOrNull(3) == "root" }?.map {
draft.event?.tags()?.filter { it.size > 1 && (it[0] == "e" || it[0] == "a") && it.getOrNull(3) == "root" }?.map {
LocalCache.checkGetOrCreateNote(it[1])
}?.firstOrNull()
@@ -529,6 +529,7 @@ open class NewPostViewModel() : ViewModel() {
zapRaiserAmount = localZapRaiserAmount,
geohash = geoHash,
nip94attachments = usedAttachments,
draftTag = localDraft,
)
} else {
account?.sendPrivateMessage(
@@ -116,6 +116,8 @@ import com.vitorpamplona.amethyst.ui.theme.Size34dp
import com.vitorpamplona.amethyst.ui.theme.StdPadding
import com.vitorpamplona.amethyst.ui.theme.ZeroPadding
import com.vitorpamplona.amethyst.ui.theme.placeholderText
import com.vitorpamplona.quartz.encoders.Hex
import com.vitorpamplona.quartz.encoders.toNpub
import com.vitorpamplona.quartz.events.ChatMessageEvent
import com.vitorpamplona.quartz.events.ChatroomKey
import com.vitorpamplona.quartz.events.findURLs
@@ -230,6 +232,9 @@ fun PrepareChatroomViewModels(
if (newPostModel.requiresNIP24) {
newPostModel.nip24 = true
}
room.users.forEach {
newPostModel.toUsers = TextFieldValue(newPostModel.toUsers.text + " @${Hex.decode(it).toNpub()}")
}
LaunchedEffect(key1 = newPostModel) {
launch(Dispatchers.IO) {
@@ -315,7 +320,10 @@ fun ChatroomScreen(
accountViewModel = accountViewModel,
nav = nav,
routeForLastRead = "Room/${room.hashCode()}",
onWantsToReply = { replyTo.value = it },
onWantsToReply = {
replyTo.value = it
newPostModel.originalNote = it
},
)
}