refactor default values in signEvent variables

This commit is contained in:
greenart7c3
2023-09-01 10:18:49 -03:00
parent f76ab01c11
commit 46effa572c
12 changed files with 123 additions and 55 deletions
@@ -264,7 +264,7 @@ class Account(
return note.hasReacted(userProfile(), reaction) return note.hasReacted(userProfile(), reaction)
} }
fun reactTo(note: Note, reaction: String, signEvent: Boolean = true): ReactionEvent? { fun reactTo(note: Note, reaction: String, signEvent: Boolean): ReactionEvent? {
if (!isWriteable() && signEvent) return null if (!isWriteable() && signEvent) return null
if (hasReacted(note, reaction)) { if (hasReacted(note, reaction)) {
@@ -465,11 +465,11 @@ class Account(
LocalCache.consume(event, null) LocalCache.consume(event, null)
} }
fun delete(note: Note, signEvent: Boolean = true): DeletionEvent? { fun delete(note: Note, signEvent: Boolean): DeletionEvent? {
return delete(listOf(note), signEvent) return delete(listOf(note), signEvent)
} }
fun delete(notes: List<Note>, signEvent: Boolean = true): DeletionEvent? { fun delete(notes: List<Note>, signEvent: Boolean): DeletionEvent? {
if (!isWriteable() && signEvent) return null if (!isWriteable() && signEvent) return null
val myNotes = notes.filter { it.author == userProfile() }.map { it.idHex } val myNotes = notes.filter { it.author == userProfile() }.map { it.idHex }
@@ -491,7 +491,7 @@ class Account(
return HTTPAuthorizationEvent.create(url, method, body, keyPair.privKey!!) return HTTPAuthorizationEvent.create(url, method, body, keyPair.privKey!!)
} }
fun boost(note: Note, signEvent: Boolean = true): Event? { fun boost(note: Note, signEvent: Boolean): Event? {
if (!isWriteable() && signEvent) return null if (!isWriteable() && signEvent) return null
if (note.hasBoostedInTheLast5Minutes(userProfile())) { if (note.hasBoostedInTheLast5Minutes(userProfile())) {
@@ -558,7 +558,7 @@ class Account(
return returningContactList return returningContactList
} }
fun follow(user: User, signEvent: Boolean = true): ContactListEvent? { fun follow(user: User, signEvent: Boolean): ContactListEvent? {
if (!isWriteable() && signEvent) return null if (!isWriteable() && signEvent) return null
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList) val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -643,7 +643,7 @@ class Account(
return null return null
} }
fun followHashtag(tag: String, signEvent: Boolean = true): ContactListEvent? { fun followHashtag(tag: String, signEvent: Boolean): ContactListEvent? {
if (!isWriteable() && signEvent) return null if (!isWriteable() && signEvent) return null
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList) val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -707,7 +707,7 @@ class Account(
return null return null
} }
fun unfollow(user: User, signEvent: Boolean = true): ContactListEvent? { fun unfollow(user: User, signEvent: Boolean): ContactListEvent? {
if (!isWriteable() && signEvent) return null if (!isWriteable() && signEvent) return null
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList) val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -730,7 +730,7 @@ class Account(
return null return null
} }
fun unfollowHashtag(tag: String, signEvent: Boolean = true): ContactListEvent? { fun unfollowHashtag(tag: String, signEvent: Boolean): ContactListEvent? {
if (!isWriteable() && signEvent) return null if (!isWriteable() && signEvent) return null
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList) val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -936,7 +936,7 @@ class Account(
directMentions: Set<HexKey>, directMentions: Set<HexKey>,
relayList: List<Relay>? = null, relayList: List<Relay>? = null,
geohash: String? = null, geohash: String? = null,
signEvent: Boolean = true signEvent: Boolean
): TextNoteEvent? { ): TextNoteEvent? {
if (!isWriteable() && signEvent) return null if (!isWriteable() && signEvent) return null
@@ -1000,7 +1000,7 @@ class Account(
zapRaiserAmount: Long? = null, zapRaiserAmount: Long? = null,
relayList: List<Relay>? = null, relayList: List<Relay>? = null,
geohash: String? = null, geohash: String? = null,
signEvent: Boolean = true signEvent: Boolean
): PollNoteEvent? { ): PollNoteEvent? {
if (!isWriteable() && signEvent) return null if (!isWriteable() && signEvent) return null
@@ -1056,7 +1056,7 @@ class Account(
wantsToMarkAsSensitive: Boolean, wantsToMarkAsSensitive: Boolean,
zapRaiserAmount: Long? = null, zapRaiserAmount: Long? = null,
geohash: String? = null, geohash: String? = null,
signEvent: Boolean = true signEvent: Boolean
): ChannelMessageEvent? { ): ChannelMessageEvent? {
if (!isWriteable() && signEvent) return null if (!isWriteable() && signEvent) return null
@@ -1095,7 +1095,7 @@ class Account(
wantsToMarkAsSensitive: Boolean, wantsToMarkAsSensitive: Boolean,
zapRaiserAmount: Long? = null, zapRaiserAmount: Long? = null,
geohash: String? = null, geohash: String? = null,
signEvent: Boolean = true signEvent: Boolean
): LiveActivitiesChatMessageEvent? { ): LiveActivitiesChatMessageEvent? {
if (!isWriteable() && signEvent) return null if (!isWriteable() && signEvent) return null
@@ -1126,7 +1126,7 @@ class Account(
} }
fun sendPrivateMessage(message: String, toUser: User, replyingTo: Note? = null, mentions: List<User>?, zapReceiver: String? = null, wantsToMarkAsSensitive: Boolean, zapRaiserAmount: Long? = null, geohash: String? = null): PrivateDmEvent? { fun sendPrivateMessage(message: String, toUser: User, replyingTo: Note? = null, mentions: List<User>?, zapReceiver: String? = null, wantsToMarkAsSensitive: Boolean, zapRaiserAmount: Long? = null, geohash: String? = null): PrivateDmEvent? {
return sendPrivateMessage(message, toUser.pubkeyHex, replyingTo, mentions, zapReceiver, wantsToMarkAsSensitive, zapRaiserAmount, geohash) return sendPrivateMessage(message, toUser.pubkeyHex, replyingTo, mentions, zapReceiver, wantsToMarkAsSensitive, zapRaiserAmount, geohash, true)
} }
fun sendPrivateMessage( fun sendPrivateMessage(
@@ -1138,7 +1138,7 @@ class Account(
wantsToMarkAsSensitive: Boolean, wantsToMarkAsSensitive: Boolean,
zapRaiserAmount: Long? = null, zapRaiserAmount: Long? = null,
geohash: String? = null, geohash: String? = null,
signEvent: Boolean = true signEvent: Boolean
): PrivateDmEvent? { ): PrivateDmEvent? {
if (!isWriteable() && signEvent) return null if (!isWriteable() && signEvent) return null
@@ -1179,7 +1179,7 @@ class Account(
wantsToMarkAsSensitive: Boolean, wantsToMarkAsSensitive: Boolean,
zapRaiserAmount: Long? = null, zapRaiserAmount: Long? = null,
geohash: String? = null, geohash: String? = null,
signEvent: Boolean = true signEvent: Boolean
): List<GiftWrapEvent>? { ): List<GiftWrapEvent>? {
if (!isWriteable() && signEvent) return null if (!isWriteable() && signEvent) return null
@@ -43,7 +43,7 @@ object AmberUtils {
"" ""
) )
while (isActivityRunning) { while (isActivityRunning) {
Thread.sleep(250) // do nothing
} }
} }
@@ -57,7 +57,7 @@ object AmberUtils {
pubKey pubKey
) )
while (isActivityRunning) { while (isActivityRunning) {
Thread.sleep(250) // do nothing
} }
} }
} }
@@ -72,7 +72,7 @@ object AmberUtils {
pubKey pubKey
) )
while (isActivityRunning) { while (isActivityRunning) {
Thread.sleep(250) // do nothing
} }
} }
} }
@@ -158,7 +158,7 @@ open class NewPostViewModel() : ViewModel() {
this.account = account this.account = account
} }
fun sendPost(relayList: List<Relay>? = null, signEvent: Boolean = true): Event? { fun sendPost(relayList: List<Relay>? = null, signEvent: Boolean): Event? {
try { try {
val tagger = NewMessageTagger(message.text, mentions, replyTos, originalNote?.channelHex()) val tagger = NewMessageTagger(message.text, mentions, replyTos, originalNote?.channelHex())
tagger.run() tagger.run()
@@ -207,7 +207,8 @@ open class NewPostViewModel() : ViewModel() {
wantsToMarkAsSensitive = wantsToMarkAsSensitive, wantsToMarkAsSensitive = wantsToMarkAsSensitive,
zapReceiver = zapReceiver, zapReceiver = zapReceiver,
zapRaiserAmount = localZapRaiserAmount, zapRaiserAmount = localZapRaiserAmount,
geohash = geoHash geohash = geoHash,
signEvent = signEvent
) )
return null return null
} else if (!dmUsers.isNullOrEmpty()) { } else if (!dmUsers.isNullOrEmpty()) {
@@ -221,7 +222,8 @@ open class NewPostViewModel() : ViewModel() {
wantsToMarkAsSensitive = wantsToMarkAsSensitive, wantsToMarkAsSensitive = wantsToMarkAsSensitive,
zapReceiver = zapReceiver, zapReceiver = zapReceiver,
zapRaiserAmount = localZapRaiserAmount, zapRaiserAmount = localZapRaiserAmount,
geohash = geoHash geohash = geoHash,
signEvent = signEvent
) )
return null return null
} else { } else {
@@ -233,7 +235,8 @@ open class NewPostViewModel() : ViewModel() {
wantsToMarkAsSensitive = wantsToMarkAsSensitive, wantsToMarkAsSensitive = wantsToMarkAsSensitive,
zapReceiver = zapReceiver, zapReceiver = zapReceiver,
zapRaiserAmount = localZapRaiserAmount, zapRaiserAmount = localZapRaiserAmount,
geohash = geoHash geohash = geoHash,
signEvent = signEvent
) )
return null return null
} }
@@ -17,6 +17,8 @@ import androidx.compose.material.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@@ -31,11 +33,18 @@ import androidx.lifecycle.ViewModel
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.Account import com.vitorpamplona.amethyst.model.Account
import com.vitorpamplona.amethyst.model.LocalCache
import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.Note
import com.vitorpamplona.amethyst.service.relays.Client
import com.vitorpamplona.amethyst.ui.actions.CloseButton import com.vitorpamplona.amethyst.ui.actions.CloseButton
import com.vitorpamplona.amethyst.ui.actions.PostButton import com.vitorpamplona.amethyst.ui.actions.PostButton
import com.vitorpamplona.amethyst.ui.actions.SignerDialog
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.theme.placeholderText import com.vitorpamplona.amethyst.ui.theme.placeholderText
import com.vitorpamplona.quartz.events.Event
import com.vitorpamplona.quartz.events.TextNoteEvent
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class AddBountyAmountViewModel : ViewModel() { class AddBountyAmountViewModel : ViewModel() {
private var account: Account? = null private var account: Account? = null
@@ -48,11 +57,11 @@ class AddBountyAmountViewModel : ViewModel() {
this.bounty = bounty this.bounty = bounty
} }
fun sendPost() { fun sendPost(signEvent: Boolean): TextNoteEvent? {
val newValue = nextAmount.text.trim().toLongOrNull() val newValue = nextAmount.text.trim().toLongOrNull()
if (newValue != null) { if (newValue != null) {
account?.sendPost( val event = account?.sendPost(
message = newValue.toString(), message = newValue.toString(),
replyTo = listOfNotNull(bounty), replyTo = listOfNotNull(bounty),
mentions = listOfNotNull(bounty?.author), mentions = listOfNotNull(bounty?.author),
@@ -60,11 +69,14 @@ class AddBountyAmountViewModel : ViewModel() {
wantsToMarkAsSensitive = false, wantsToMarkAsSensitive = false,
replyingTo = null, replyingTo = null,
root = null, root = null,
directMentions = setOf() directMentions = setOf(),
signEvent = signEvent
) )
nextAmount = TextFieldValue("") nextAmount = TextFieldValue("")
return event
} }
return null
} }
fun cancel() { fun cancel() {
@@ -80,6 +92,26 @@ class AddBountyAmountViewModel : ViewModel() {
fun AddBountyAmountDialog(bounty: Note, accountViewModel: AccountViewModel, onClose: () -> Unit) { fun AddBountyAmountDialog(bounty: Note, accountViewModel: AccountViewModel, onClose: () -> Unit) {
val postViewModel: AddBountyAmountViewModel = viewModel() val postViewModel: AddBountyAmountViewModel = viewModel()
postViewModel.load(accountViewModel.account, bounty) postViewModel.load(accountViewModel.account, bounty)
val scope = rememberCoroutineScope()
var event by remember { mutableStateOf<Event?>(null) }
if (event != null) {
SignerDialog(
onClose = {
event = null
},
onPost = {
scope.launch(Dispatchers.IO) {
val signedEvent = Event.fromJson(it)
Client.send(signedEvent)
LocalCache.verifyAndConsume(signedEvent, null)
event = null
onClose()
}
},
data = event!!.toJson()
)
}
Dialog( Dialog(
onDismissRequest = { onClose() }, onDismissRequest = { onClose() },
@@ -89,7 +121,11 @@ fun AddBountyAmountDialog(bounty: Note, accountViewModel: AccountViewModel, onCl
) )
) { ) {
Surface() { Surface() {
Column(modifier = Modifier.padding(10.dp).width(IntrinsicSize.Min)) { Column(
modifier = Modifier
.padding(10.dp)
.width(IntrinsicSize.Min)
) {
Row( Row(
horizontalArrangement = Arrangement.SpaceBetween, horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
@@ -102,8 +138,10 @@ fun AddBountyAmountDialog(bounty: Note, accountViewModel: AccountViewModel, onCl
PostButton( PostButton(
onPost = { onPost = {
postViewModel.sendPost() event = postViewModel.sendPost(!accountViewModel.loggedInWithAmber())
if (!accountViewModel.loggedInWithAmber()) {
onClose() onClose()
}
}, },
isActive = postViewModel.hasChanged() isActive = postViewModel.hasChanged()
) )
@@ -315,10 +315,12 @@ private fun RenderMainPopup(
stringResource(R.string.quick_action_unfollow) stringResource(R.string.quick_action_unfollow)
) { ) {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
accountViewModel.unfollow(note.author!!) event = accountViewModel.unfollow(note.author!!, !accountViewModel.loggedInWithAmber())
if (!accountViewModel.loggedInWithAmber()) {
onDismiss() onDismiss()
} }
} }
}
} else { } else {
NoteQuickActionItem( NoteQuickActionItem(
Icons.Default.PersonAdd, Icons.Default.PersonAdd,
@@ -674,7 +674,7 @@ fun BoostReaction(
if (accountViewModel.isWriteable()) { if (accountViewModel.isWriteable()) {
if (accountViewModel.hasBoosted(baseNote)) { if (accountViewModel.hasBoosted(baseNote)) {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
accountViewModel.deleteBoostsTo(baseNote) accountViewModel.deleteBoostsTo(baseNote, true)
} }
} else { } else {
wantsToBoost = true wantsToBoost = true
@@ -961,9 +961,9 @@ private fun likeClick(
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
val reaction = accountViewModel.account.reactionChoices.first() val reaction = accountViewModel.account.reactionChoices.first()
if (accountViewModel.hasReactedTo(baseNote, reaction)) { if (accountViewModel.hasReactedTo(baseNote, reaction)) {
accountViewModel.deleteReactionTo(baseNote, reaction) accountViewModel.deleteReactionTo(baseNote, reaction, true)
} else { } else {
accountViewModel.reactTo(baseNote, reaction) accountViewModel.reactTo(baseNote, reaction, true)
} }
} }
} else if (accountViewModel.account.reactionChoices.size > 1) { } else if (accountViewModel.account.reactionChoices.size > 1) {
@@ -1273,7 +1273,7 @@ private fun BoostTypeChoicePopup(baseNote: Note, iconSize: Dp, accountViewModel:
onClick = { onClick = {
if (accountViewModel.isWriteable()) { if (accountViewModel.isWriteable()) {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
accountViewModel.boost(baseNote) accountViewModel.boost(baseNote, true)
onDismiss() onDismiss()
} }
} else { } else {
@@ -344,7 +344,7 @@ fun ShowFollowingOrUnfollowingButton(
UnfollowButton { UnfollowButton {
if (!accountViewModel.isWriteable()) { if (!accountViewModel.isWriteable()) {
if (accountViewModel.loggedInWithAmber()) { if (accountViewModel.loggedInWithAmber()) {
event = accountViewModel.account.unfollow(baseAuthor, false) event = accountViewModel.unfollow(baseAuthor, false)
} else { } else {
scope.launch { scope.launch {
Toast Toast
@@ -358,7 +358,7 @@ fun ShowFollowingOrUnfollowingButton(
} }
} else { } else {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
accountViewModel.unfollow(baseAuthor) accountViewModel.unfollow(baseAuthor, true)
} }
} }
} }
@@ -112,11 +112,11 @@ class AccountViewModel(val account: Account) : ViewModel() {
return account.userProfile() return account.userProfile()
} }
fun reactTo(note: Note, reaction: String, signEvent: Boolean = true): ReactionEvent? { fun reactTo(note: Note, reaction: String, signEvent: Boolean): ReactionEvent? {
return account.reactTo(note, reaction, signEvent) return account.reactTo(note, reaction, signEvent)
} }
fun reactToOrDelete(note: Note, reaction: String, signEvent: Boolean = true): Event? { fun reactToOrDelete(note: Note, reaction: String, signEvent: Boolean): Event? {
val currentReactions = account.reactionTo(note, reaction) val currentReactions = account.reactionTo(note, reaction)
if (currentReactions.isNotEmpty()) { if (currentReactions.isNotEmpty()) {
return account.delete(currentReactions, signEvent) return account.delete(currentReactions, signEvent)
@@ -134,7 +134,7 @@ class AccountViewModel(val account: Account) : ViewModel() {
return account.hasReacted(baseNote, reaction) return account.hasReacted(baseNote, reaction)
} }
fun deleteReactionTo(note: Note, reaction: String, signEvent: Boolean = true): DeletionEvent? { fun deleteReactionTo(note: Note, reaction: String, signEvent: Boolean): DeletionEvent? {
return account.delete(account.reactionTo(note, reaction), signEvent) return account.delete(account.reactionTo(note, reaction), signEvent)
} }
@@ -142,7 +142,7 @@ class AccountViewModel(val account: Account) : ViewModel() {
return account.hasBoosted(baseNote) return account.hasBoosted(baseNote)
} }
fun deleteBoostsTo(note: Note, signEvent: Boolean = true): DeletionEvent? { fun deleteBoostsTo(note: Note, signEvent: Boolean): DeletionEvent? {
return account.delete(account.boostsTo(note), signEvent) return account.delete(account.boostsTo(note), signEvent)
} }
@@ -302,7 +302,7 @@ class AccountViewModel(val account: Account) : ViewModel() {
} }
} }
fun boost(note: Note, signEvent: Boolean = true): Event? { fun boost(note: Note, signEvent: Boolean): Event? {
return account.boost(note, signEvent) return account.boost(note, signEvent)
} }
@@ -386,8 +386,8 @@ class AccountViewModel(val account: Account) : ViewModel() {
return account.follow(user, signEvent) return account.follow(user, signEvent)
} }
fun unfollow(user: User) { fun unfollow(user: User, signEvent: Boolean): ContactListEvent? {
account.unfollow(user) return account.unfollow(user, signEvent)
} }
fun isLoggedUser(user: User?): Boolean { fun isLoggedUser(user: User?): Boolean {
@@ -263,6 +263,24 @@ fun ChannelScreen(
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
var event by remember { mutableStateOf<Event?>(null) }
if (event != null) {
SignerDialog(
onClose = {
event = null
},
onPost = {
scope.launch(Dispatchers.IO) {
val signedEvent = Event.fromJson(it)
Client.send(signedEvent)
LocalCache.verifyAndConsume(signedEvent, null)
event = null
}
},
data = event!!.toJson()
)
}
// LAST ROW // LAST ROW
EditFieldRow(newPostModel, isPrivate = false, accountViewModel = accountViewModel) { EditFieldRow(newPostModel, isPrivate = false, accountViewModel = accountViewModel) {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
@@ -274,20 +292,22 @@ fun ChannelScreen(
) )
tagger.run() tagger.run()
if (channel is PublicChatChannel) { if (channel is PublicChatChannel) {
accountViewModel.account.sendChannelMessage( event = accountViewModel.account.sendChannelMessage(
message = tagger.message, message = tagger.message,
toChannel = channel.idHex, toChannel = channel.idHex,
replyTo = tagger.replyTos, replyTo = tagger.replyTos,
mentions = tagger.mentions, mentions = tagger.mentions,
wantsToMarkAsSensitive = false wantsToMarkAsSensitive = false,
signEvent = !accountViewModel.loggedInWithAmber()
) )
} else if (channel is LiveActivitiesChannel) { } else if (channel is LiveActivitiesChannel) {
accountViewModel.account.sendLiveMessage( event = accountViewModel.account.sendLiveMessage(
message = tagger.message, message = tagger.message,
toChannel = channel.address, toChannel = channel.address,
replyTo = tagger.replyTos, replyTo = tagger.replyTos,
mentions = tagger.mentions, mentions = tagger.mentions,
wantsToMarkAsSensitive = false wantsToMarkAsSensitive = false,
signEvent = !accountViewModel.loggedInWithAmber()
) )
} }
newPostModel.message = TextFieldValue("") newPostModel.message = TextFieldValue("")
@@ -344,12 +344,14 @@ fun ChatroomScreen(
PrivateMessageEditFieldRow(newPostModel, isPrivate = true, accountViewModel) { PrivateMessageEditFieldRow(newPostModel, isPrivate = true, accountViewModel) {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
if (newPostModel.nip24 || room.users.size > 1 || replyTo.value?.event is ChatMessageEvent) { if (newPostModel.nip24 || room.users.size > 1 || replyTo.value?.event is ChatMessageEvent) {
// TODO: add support for amber
accountViewModel.account.sendNIP24PrivateMessage( accountViewModel.account.sendNIP24PrivateMessage(
message = newPostModel.message.text, message = newPostModel.message.text,
toUsers = room.users.toList(), toUsers = room.users.toList(),
replyingTo = replyTo.value, replyingTo = replyTo.value,
mentions = null, mentions = null,
wantsToMarkAsSensitive = false wantsToMarkAsSensitive = false,
signEvent = true
) )
} else { } else {
if (!accountViewModel.isWriteable() && accountViewModel.loggedInWithAmber()) { if (!accountViewModel.isWriteable() && accountViewModel.loggedInWithAmber()) {
@@ -360,7 +362,8 @@ fun ChatroomScreen(
toUser = room.users.first(), toUser = room.users.first(),
replyingTo = replyTo.value, replyingTo = replyTo.value,
mentions = null, mentions = null,
wantsToMarkAsSensitive = false wantsToMarkAsSensitive = false,
signEvent = true
) )
} }
} }
@@ -690,13 +693,15 @@ fun NewSubjectView(onClose: () -> Unit, accountViewModel: AccountViewModel, room
PostButton( PostButton(
onPost = { onPost = {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
// TODO: add support for amber
accountViewModel.account.sendNIP24PrivateMessage( accountViewModel.account.sendNIP24PrivateMessage(
message = message.value, message = message.value,
toUsers = room.users.toList(), toUsers = room.users.toList(),
subject = groupName.value.ifBlank { null }, subject = groupName.value.ifBlank { null },
replyingTo = null, replyingTo = null,
mentions = null, mentions = null,
wantsToMarkAsSensitive = false wantsToMarkAsSensitive = false,
signEvent = true
) )
} }
@@ -186,7 +186,7 @@ fun HashtagActionOptions(
} }
} else { } else {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
accountViewModel.account.unfollowHashtag(tag) accountViewModel.account.unfollowHashtag(tag, true)
} }
} }
} }
@@ -208,7 +208,7 @@ fun HashtagActionOptions(
} }
} else { } else {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
accountViewModel.account.followHashtag(tag) accountViewModel.account.followHashtag(tag, true)
} }
} }
} }
@@ -895,7 +895,7 @@ private fun DisplayFollowUnfollowButton(
} }
} else { } else {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
accountViewModel.account.unfollow(baseUser) accountViewModel.account.unfollow(baseUser, true)
} }
} }
} }
@@ -918,7 +918,7 @@ private fun DisplayFollowUnfollowButton(
} }
} else { } else {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
accountViewModel.account.follow(baseUser) accountViewModel.account.follow(baseUser, true)
} }
} }
} }
@@ -940,7 +940,7 @@ private fun DisplayFollowUnfollowButton(
} }
} else { } else {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
accountViewModel.account.follow(baseUser) accountViewModel.account.follow(baseUser, true)
} }
} }
} }