mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2024-09-29 08:20:51 +00:00
Migrates poll and invoice option availability to a mutable state
This commit is contained in:
parent
97490bb6ef
commit
03b76357ff
@ -270,13 +270,13 @@ fun NewPostView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n
|
||||
postViewModel.upload(it, context)
|
||||
}
|
||||
|
||||
if (postViewModel.canUsePoll()) {
|
||||
if (postViewModel.canUsePoll) {
|
||||
AddPollButton(postViewModel.wantsPoll) {
|
||||
postViewModel.wantsPoll = !postViewModel.wantsPoll
|
||||
}
|
||||
}
|
||||
|
||||
if (postViewModel.canAddLnInvoice()) {
|
||||
if (postViewModel.canAddInvoice) {
|
||||
AddLnInvoiceButton(postViewModel.wantsInvoice) {
|
||||
postViewModel.wantsInvoice = !postViewModel.wantsInvoice
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ open class NewPostViewModel : ViewModel() {
|
||||
var userSuggestionAnchor: TextRange? = null
|
||||
|
||||
// Polls
|
||||
var canUsePoll by mutableStateOf(false)
|
||||
var wantsPoll by mutableStateOf(false)
|
||||
var zapRecipients = mutableStateListOf<HexKey>()
|
||||
var pollOptions = newStateMapPollOptions()
|
||||
@ -53,6 +54,7 @@ open class NewPostViewModel : ViewModel() {
|
||||
var isValidClosedAt = mutableStateOf(true)
|
||||
|
||||
// Invoices
|
||||
var canAddInvoice by mutableStateOf(false)
|
||||
var wantsInvoice by mutableStateOf(false)
|
||||
|
||||
open fun load(account: Account, replyingTo: Note?, quote: Note?) {
|
||||
@ -79,6 +81,9 @@ open class NewPostViewModel : ViewModel() {
|
||||
message = TextFieldValue(message.text + "\n\n@${it.idNote()}")
|
||||
}
|
||||
|
||||
canAddInvoice = account.userProfile().info?.lnAddress() != null
|
||||
canUsePoll = originalNote?.event !is PrivateDmEvent && originalNote?.channel() == null
|
||||
|
||||
this.account = account
|
||||
}
|
||||
|
||||
@ -190,12 +195,4 @@ open class NewPostViewModel : ViewModel() {
|
||||
return message.text.isNotBlank() && !isUploadingImage && !wantsInvoice &&
|
||||
(!wantsPoll || pollOptions.values.all { it.isNotEmpty() })
|
||||
}
|
||||
|
||||
fun canUsePoll(): Boolean {
|
||||
return originalNote?.event !is PrivateDmEvent && originalNote?.channel() == null
|
||||
}
|
||||
|
||||
fun canAddLnInvoice(): Boolean {
|
||||
return account?.userProfile()?.info?.lnAddress() != null
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user