Adding Zaps to the profile
This commit is contained in:
@@ -137,9 +137,12 @@ class Account(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun createZapRequestFor(user: User): LnZapRequestEvent? {
|
fun createZapRequestFor(user: User): LnZapRequestEvent? {
|
||||||
|
return createZapRequestFor(user.pubkeyHex)
|
||||||
|
}
|
||||||
|
fun createZapRequestFor(userPubKeyHex: String): LnZapRequestEvent? {
|
||||||
if (!isWriteable()) return null
|
if (!isWriteable()) return null
|
||||||
|
|
||||||
return LnZapRequestEvent.create(user.pubkeyHex, userProfile().relays?.keys ?: localRelays.map { it.url }.toSet(), loggedIn.privKey!!)
|
return LnZapRequestEvent.create(userPubKeyHex, userProfile().relays?.keys ?: localRelays.map { it.url }.toSet(), loggedIn.privKey!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun report(note: Note, type: ReportEvent.ReportType) {
|
fun report(note: Note, type: ReportEvent.ReportType) {
|
||||||
|
|||||||
@@ -38,10 +38,11 @@ import androidx.compose.ui.unit.sp
|
|||||||
import androidx.core.content.ContextCompat.startActivity
|
import androidx.core.content.ContextCompat.startActivity
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.lnurl.LightningAddressResolver
|
import com.vitorpamplona.amethyst.lnurl.LightningAddressResolver
|
||||||
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun InvoiceRequest(lud16: String, onClose: () -> Unit ) {
|
fun InvoiceRequest(lud16: String, toUserPubKeyHex: String, account: Account, onClose: () -> Unit ) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
@@ -128,7 +129,9 @@ fun InvoiceRequest(lud16: String, onClose: () -> Unit ) {
|
|||||||
Button(
|
Button(
|
||||||
modifier = Modifier.fillMaxWidth().padding(vertical = 10.dp),
|
modifier = Modifier.fillMaxWidth().padding(vertical = 10.dp),
|
||||||
onClick = {
|
onClick = {
|
||||||
LightningAddressResolver().lnAddressInvoice(lud16, amount * 1000, message,
|
val zapRequest = account.createZapRequestFor(toUserPubKeyHex)
|
||||||
|
|
||||||
|
LightningAddressResolver().lnAddressInvoice(lud16, amount * 1000, message, zapRequest?.toJson(),
|
||||||
onSuccess = {
|
onSuccess = {
|
||||||
runCatching {
|
runCatching {
|
||||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("lightning:$it"))
|
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("lightning:$it"))
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ private fun ProfileHeader(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawAdditionalInfo(baseUser)
|
DrawAdditionalInfo(baseUser, account)
|
||||||
|
|
||||||
Divider(modifier = Modifier.padding(top = 6.dp))
|
Divider(modifier = Modifier.padding(top = 6.dp))
|
||||||
}
|
}
|
||||||
@@ -340,7 +340,7 @@ private fun ProfileHeader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DrawAdditionalInfo(baseUser: User) {
|
private fun DrawAdditionalInfo(baseUser: User, account: Account) {
|
||||||
val userState by baseUser.liveMetadata.observeAsState()
|
val userState by baseUser.liveMetadata.observeAsState()
|
||||||
val user = userState?.user ?: return
|
val user = userState?.user ?: return
|
||||||
|
|
||||||
@@ -400,7 +400,7 @@ private fun DrawAdditionalInfo(baseUser: User) {
|
|||||||
|
|
||||||
if (ZapExpanded) {
|
if (ZapExpanded) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(vertical = 5.dp)) {
|
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(vertical = 5.dp)) {
|
||||||
InvoiceRequest(lud16) {
|
InvoiceRequest(lud16, baseUser.pubkeyHex, account) {
|
||||||
ZapExpanded = false
|
ZapExpanded = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user