support for dms, streams and communities
This commit is contained in:
@@ -1756,6 +1756,7 @@ class Account(
|
|||||||
zapRaiserAmount: Long? = null,
|
zapRaiserAmount: Long? = null,
|
||||||
geohash: String? = null,
|
geohash: String? = null,
|
||||||
nip94attachments: List<FileHeaderEvent>? = null,
|
nip94attachments: List<FileHeaderEvent>? = null,
|
||||||
|
draftTag: String? = null,
|
||||||
) {
|
) {
|
||||||
if (!isWriteable()) return
|
if (!isWriteable()) return
|
||||||
|
|
||||||
@@ -1773,9 +1774,19 @@ class Account(
|
|||||||
zapRaiserAmount = zapRaiserAmount,
|
zapRaiserAmount = zapRaiserAmount,
|
||||||
geohash = geohash,
|
geohash = geohash,
|
||||||
nip94attachments = nip94attachments,
|
nip94attachments = nip94attachments,
|
||||||
|
draftTag = draftTag,
|
||||||
signer = signer,
|
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 =
|
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])
|
val note = LocalCache.checkGetOrCreateNote(it[1])
|
||||||
note
|
note
|
||||||
}
|
}
|
||||||
@@ -349,13 +349,13 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
LocalCache.getOrCreateUser(it[1])
|
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])
|
val note = LocalCache.checkGetOrCreateNote(it[1])
|
||||||
forkedFromNote = note
|
forkedFromNote = note
|
||||||
}
|
}
|
||||||
|
|
||||||
originalNote =
|
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])
|
LocalCache.checkGetOrCreateNote(it[1])
|
||||||
}?.firstOrNull()
|
}?.firstOrNull()
|
||||||
|
|
||||||
@@ -529,6 +529,7 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
zapRaiserAmount = localZapRaiserAmount,
|
zapRaiserAmount = localZapRaiserAmount,
|
||||||
geohash = geoHash,
|
geohash = geoHash,
|
||||||
nip94attachments = usedAttachments,
|
nip94attachments = usedAttachments,
|
||||||
|
draftTag = localDraft,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
account?.sendPrivateMessage(
|
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.StdPadding
|
||||||
import com.vitorpamplona.amethyst.ui.theme.ZeroPadding
|
import com.vitorpamplona.amethyst.ui.theme.ZeroPadding
|
||||||
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
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.ChatMessageEvent
|
||||||
import com.vitorpamplona.quartz.events.ChatroomKey
|
import com.vitorpamplona.quartz.events.ChatroomKey
|
||||||
import com.vitorpamplona.quartz.events.findURLs
|
import com.vitorpamplona.quartz.events.findURLs
|
||||||
@@ -230,6 +232,9 @@ fun PrepareChatroomViewModels(
|
|||||||
if (newPostModel.requiresNIP24) {
|
if (newPostModel.requiresNIP24) {
|
||||||
newPostModel.nip24 = true
|
newPostModel.nip24 = true
|
||||||
}
|
}
|
||||||
|
room.users.forEach {
|
||||||
|
newPostModel.toUsers = TextFieldValue(newPostModel.toUsers.text + " @${Hex.decode(it).toNpub()}")
|
||||||
|
}
|
||||||
|
|
||||||
LaunchedEffect(key1 = newPostModel) {
|
LaunchedEffect(key1 = newPostModel) {
|
||||||
launch(Dispatchers.IO) {
|
launch(Dispatchers.IO) {
|
||||||
@@ -315,7 +320,10 @@ fun ChatroomScreen(
|
|||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
routeForLastRead = "Room/${room.hashCode()}",
|
routeForLastRead = "Room/${room.hashCode()}",
|
||||||
onWantsToReply = { replyTo.value = it },
|
onWantsToReply = {
|
||||||
|
replyTo.value = it
|
||||||
|
newPostModel.originalNote = it
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ class ChatMessageEvent(
|
|||||||
signer: NostrSigner,
|
signer: NostrSigner,
|
||||||
createdAt: Long = TimeUtils.now(),
|
createdAt: Long = TimeUtils.now(),
|
||||||
nip94attachments: List<FileHeaderEvent>? = null,
|
nip94attachments: List<FileHeaderEvent>? = null,
|
||||||
|
isDraft: Boolean,
|
||||||
onReady: (ChatMessageEvent) -> Unit,
|
onReady: (ChatMessageEvent) -> Unit,
|
||||||
) {
|
) {
|
||||||
val tags = mutableListOf<Array<String>>()
|
val tags = mutableListOf<Array<String>>()
|
||||||
@@ -106,7 +107,7 @@ class ChatMessageEvent(
|
|||||||
}
|
}
|
||||||
// tags.add(arrayOf("alt", alt))
|
// tags.add(arrayOf("alt", alt))
|
||||||
|
|
||||||
signer.sign(createdAt, KIND, tags.toTypedArray(), msg, onReady)
|
signer.sign(createdAt, KIND, tags.toTypedArray(), msg, onReady, isDraft)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ class NIP24Factory {
|
|||||||
zapRaiserAmount: Long? = null,
|
zapRaiserAmount: Long? = null,
|
||||||
geohash: String? = null,
|
geohash: String? = null,
|
||||||
nip94attachments: List<FileHeaderEvent>? = null,
|
nip94attachments: List<FileHeaderEvent>? = null,
|
||||||
|
draftTag: String? = null,
|
||||||
onReady: (Result) -> Unit,
|
onReady: (Result) -> Unit,
|
||||||
) {
|
) {
|
||||||
val senderPublicKey = signer.pubKey
|
val senderPublicKey = signer.pubKey
|
||||||
@@ -92,15 +93,25 @@ class NIP24Factory {
|
|||||||
markAsSensitive = markAsSensitive,
|
markAsSensitive = markAsSensitive,
|
||||||
zapRaiserAmount = zapRaiserAmount,
|
zapRaiserAmount = zapRaiserAmount,
|
||||||
geohash = geohash,
|
geohash = geohash,
|
||||||
|
isDraft = draftTag != null,
|
||||||
nip94attachments = nip94attachments,
|
nip94attachments = nip94attachments,
|
||||||
) { senderMessage ->
|
) { senderMessage ->
|
||||||
createWraps(senderMessage, to.plus(senderPublicKey).toSet(), signer) { wraps ->
|
if (draftTag != null) {
|
||||||
onReady(
|
onReady(
|
||||||
Result(
|
Result(
|
||||||
msg = senderMessage,
|
msg = senderMessage,
|
||||||
wraps = wraps,
|
wraps = listOf(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
createWraps(senderMessage, to.plus(senderPublicKey).toSet(), signer) { wraps ->
|
||||||
|
onReady(
|
||||||
|
Result(
|
||||||
|
msg = senderMessage,
|
||||||
|
wraps = wraps,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user