Fixes not being able to create an invoice because of an old cache of the lud16
Fixes inserting invoice in the cursor.
This commit is contained in:
@@ -475,34 +475,32 @@ fun NewPostView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val user = postViewModel.account?.userProfile()
|
if (postViewModel.wantsInvoice) {
|
||||||
val lud16 = user?.info?.lnAddress()
|
postViewModel.lnAddress()?.let { lud16 ->
|
||||||
|
Row(
|
||||||
if (lud16 != null && postViewModel.wantsInvoice) {
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
Row(
|
modifier = Modifier.padding(vertical = Size5dp, horizontal = Size10dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
) {
|
||||||
modifier = Modifier.padding(vertical = Size5dp, horizontal = Size10dp),
|
Column(Modifier.fillMaxWidth()) {
|
||||||
) {
|
InvoiceRequest(
|
||||||
Column(Modifier.fillMaxWidth()) {
|
lud16,
|
||||||
InvoiceRequest(
|
accountViewModel.account.userProfile().pubkeyHex,
|
||||||
lud16,
|
accountViewModel.account,
|
||||||
user.pubkeyHex,
|
stringResource(id = R.string.lightning_invoice),
|
||||||
accountViewModel.account,
|
stringResource(id = R.string.lightning_create_and_add_invoice),
|
||||||
stringResource(id = R.string.lightning_invoice),
|
onSuccess = {
|
||||||
stringResource(id = R.string.lightning_create_and_add_invoice),
|
postViewModel.insertAtCursor(it)
|
||||||
onSuccess = {
|
postViewModel.wantsInvoice = false
|
||||||
postViewModel.message =
|
},
|
||||||
TextFieldValue(postViewModel.message.text + "\n\n" + it)
|
onClose = { postViewModel.wantsInvoice = false },
|
||||||
postViewModel.wantsInvoice = false
|
onError = { title, message -> accountViewModel.toast(title, message) },
|
||||||
},
|
)
|
||||||
onClose = { postViewModel.wantsInvoice = false },
|
}
|
||||||
onError = { title, message -> accountViewModel.toast(title, message) },
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lud16 != null && postViewModel.wantsZapraiser) {
|
if (postViewModel.wantsZapraiser && postViewModel.hasLnAddress()) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = Modifier.padding(vertical = Size5dp, horizontal = Size10dp),
|
modifier = Modifier.padding(vertical = Size5dp, horizontal = Size10dp),
|
||||||
@@ -569,7 +567,7 @@ private fun BottomRowActions(postViewModel: NewPostViewModel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (postViewModel.canAddInvoice) {
|
if (postViewModel.canAddInvoice && postViewModel.hasLnAddress()) {
|
||||||
AddLnInvoiceButton(postViewModel.wantsInvoice) {
|
AddLnInvoiceButton(postViewModel.wantsInvoice) {
|
||||||
postViewModel.wantsInvoice = !postViewModel.wantsInvoice
|
postViewModel.wantsInvoice = !postViewModel.wantsInvoice
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,6 +163,18 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
// NIP24 Wrapped DMs / Group messages
|
// NIP24 Wrapped DMs / Group messages
|
||||||
var nip24 by mutableStateOf(false)
|
var nip24 by mutableStateOf(false)
|
||||||
|
|
||||||
|
fun lnAddress(): String? {
|
||||||
|
return account?.userProfile()?.info?.lnAddress()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hasLnAddress(): Boolean {
|
||||||
|
return account?.userProfile()?.info?.lnAddress() != null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun user(): User? {
|
||||||
|
return account?.userProfile()
|
||||||
|
}
|
||||||
|
|
||||||
open fun load(
|
open fun load(
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
replyingTo: Note?,
|
replyingTo: Note?,
|
||||||
@@ -819,6 +831,10 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun insertAtCursor(newElement: String) {
|
||||||
|
message = message.insertUrlAtCursor(newElement)
|
||||||
|
}
|
||||||
|
|
||||||
fun createNIP95Record(
|
fun createNIP95Record(
|
||||||
bytes: ByteArray,
|
bytes: ByteArray,
|
||||||
mimeType: String?,
|
mimeType: String?,
|
||||||
|
|||||||
Reference in New Issue
Block a user