mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-20 02:00:57 +02:00
fix zap splits and show message if user uninstall amber
This commit is contained in:
@@ -450,7 +450,8 @@ class Account(
|
||||
userProfile().latestContactList?.relays()?.keys?.ifEmpty { null }
|
||||
?: localRelays.map { it.url }.toSet(),
|
||||
pollOption,
|
||||
message
|
||||
message,
|
||||
toUser?.pubkeyHex
|
||||
)
|
||||
}
|
||||
LnZapEvent.ZapType.PUBLIC -> {
|
||||
@@ -460,7 +461,8 @@ class Account(
|
||||
?: localRelays.map { it.url }.toSet(),
|
||||
keyPair.pubKey.toHexKey(),
|
||||
pollOption,
|
||||
message
|
||||
message,
|
||||
toUser?.pubkeyHex
|
||||
)
|
||||
AmberUtils.openAmber(unsignedEvent)
|
||||
val content = AmberUtils.content[unsignedEvent.id] ?: ""
|
||||
@@ -479,7 +481,8 @@ class Account(
|
||||
?: localRelays.map { it.url }.toSet(),
|
||||
keyPair.pubKey.toHexKey(),
|
||||
pollOption,
|
||||
message
|
||||
message,
|
||||
toUser?.pubkeyHex
|
||||
)
|
||||
AmberUtils.openAmber(unsignedEvent, "event")
|
||||
val content = AmberUtils.content[unsignedEvent.id] ?: ""
|
||||
|
@@ -3,11 +3,13 @@ package com.vitorpamplona.amethyst.service
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import android.util.LruCache
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import com.vitorpamplona.amethyst.Amethyst
|
||||
import com.vitorpamplona.amethyst.R
|
||||
import com.vitorpamplona.amethyst.ServiceManager
|
||||
import com.vitorpamplona.amethyst.model.Account
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
@@ -49,7 +51,7 @@ object AmberUtils {
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
Toast.makeText(
|
||||
Amethyst.instance,
|
||||
"Sign request rejected",
|
||||
Amethyst.instance.getString(R.string.sign_request_rejected),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
@@ -133,6 +135,7 @@ object AmberUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
fun openAmber(
|
||||
data: String,
|
||||
type: SignerType,
|
||||
@@ -140,6 +143,7 @@ object AmberUtils {
|
||||
pubKey: HexKey,
|
||||
id: String
|
||||
) {
|
||||
try {
|
||||
ServiceManager.shouldPauseService = false
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$data"))
|
||||
val signerType = when (type) {
|
||||
@@ -159,6 +163,16 @@ object AmberUtils {
|
||||
}
|
||||
intent.`package` = "com.greenart7c3.nostrsigner"
|
||||
intentResult.launch(intent)
|
||||
} catch (e: Exception) {
|
||||
Log.e("Amber", "Error opening amber", e)
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
Toast.makeText(
|
||||
Amethyst.instance,
|
||||
Amethyst.instance.getString(R.string.error_opening_amber),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun openAmber(event: EventInterface, columnName: String = "signature") {
|
||||
|
@@ -14,11 +14,7 @@ import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.fonfon.kgeohash.toGeoHash
|
||||
import com.vitorpamplona.amethyst.model.Account
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.model.Note
|
||||
import com.vitorpamplona.amethyst.model.ServersAvailable
|
||||
import com.vitorpamplona.amethyst.model.User
|
||||
import com.vitorpamplona.amethyst.model.*
|
||||
import com.vitorpamplona.amethyst.service.FileHeader
|
||||
import com.vitorpamplona.amethyst.service.LocationUtil
|
||||
import com.vitorpamplona.amethyst.service.NostrSearchEventOrUserDataSource
|
||||
@@ -168,7 +164,6 @@ open class NewPostViewModel() : ViewModel() {
|
||||
}
|
||||
|
||||
fun sendPost(relayList: List<Relay>? = null) {
|
||||
try {
|
||||
val tagger = NewMessageTagger(message.text, mentions, replyTos, originalNote?.channelHex())
|
||||
tagger.run()
|
||||
|
||||
@@ -185,6 +180,9 @@ open class NewPostViewModel() : ViewModel() {
|
||||
isLnAddress = false
|
||||
)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
val geoLocation = locUtil?.locationStateFlow?.value
|
||||
val geoHash = if (wantsToAddGeoHash && geoLocation != null) {
|
||||
@@ -283,19 +281,11 @@ open class NewPostViewModel() : ViewModel() {
|
||||
)
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
cancel()
|
||||
}
|
||||
}
|
||||
|
||||
fun upload(
|
||||
galleryUri: Uri,
|
||||
description: String,
|
||||
sensitiveContent: Boolean,
|
||||
server: ServersAvailable,
|
||||
context: Context,
|
||||
relayList: List<Relay>? = null
|
||||
) {
|
||||
fun upload(galleryUri: Uri, description: String, sensitiveContent: Boolean, server: ServersAvailable, context: Context, relayList: List<Relay>? = null) {
|
||||
isUploadingImage = true
|
||||
contentToAddUrl = null
|
||||
|
||||
@@ -313,7 +303,6 @@ open class NewPostViewModel() : ViewModel() {
|
||||
createNIP95Record(it.readBytes(), contentType, description, sensitiveContent, relayList = relayList)
|
||||
}
|
||||
} else {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
ImageUploader.uploadImage(
|
||||
uri = fileUri,
|
||||
contentType = contentType,
|
||||
@@ -322,12 +311,7 @@ open class NewPostViewModel() : ViewModel() {
|
||||
contentResolver = contentResolver,
|
||||
onSuccess = { imageUrl, mimeType ->
|
||||
if (isNIP94Server(server)) {
|
||||
createNIP94Record(
|
||||
imageUrl,
|
||||
mimeType,
|
||||
description,
|
||||
sensitiveContent
|
||||
)
|
||||
createNIP94Record(imageUrl, mimeType, description, sensitiveContent)
|
||||
} else {
|
||||
isUploadingImage = false
|
||||
message = TextFieldValue(message.text + "\n\n" + imageUrl)
|
||||
@@ -342,7 +326,6 @@ open class NewPostViewModel() : ViewModel() {
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
onError = {
|
||||
isUploadingImage = false
|
||||
|
@@ -588,4 +588,6 @@
|
||||
<string name="lightning_wallets_not_found2">Lightning wallets not found</string>
|
||||
<string name="paid">Paid</string>
|
||||
<string name="wallet_number">Wallet %1$s</string>
|
||||
<string name="error_opening_amber">Error opening Amber</string>
|
||||
<string name="sign_request_rejected">Sign request rejected</string>
|
||||
</resources>
|
||||
|
@@ -113,11 +113,12 @@ class LnZapRequestEvent(
|
||||
pubKey: HexKey,
|
||||
pollOption: Int?,
|
||||
message: String,
|
||||
toUserPubHex: String?, // Overrides in case of Zap Splits
|
||||
createdAt: Long = TimeUtils.now()
|
||||
): LnZapRequestEvent {
|
||||
var tags = listOf(
|
||||
listOf("e", originalNote.id()),
|
||||
listOf("p", originalNote.pubKey()),
|
||||
listOf("p", toUserPubHex ?: originalNote.pubKey()),
|
||||
listOf("relays") + relays
|
||||
)
|
||||
if (originalNote is AddressableEvent) {
|
||||
@@ -137,12 +138,13 @@ class LnZapRequestEvent(
|
||||
pubKey: HexKey,
|
||||
pollOption: Int?,
|
||||
message: String,
|
||||
toUserPubHex: String?,
|
||||
createdAt: Long = TimeUtils.now()
|
||||
): LnZapRequestEvent {
|
||||
val content = message
|
||||
var tags = listOf(
|
||||
listOf("e", originalNote.id()),
|
||||
listOf("p", originalNote.pubKey()),
|
||||
listOf("p", toUserPubHex ?: originalNote.pubKey()),
|
||||
listOf("relays") + relays
|
||||
)
|
||||
if (originalNote is AddressableEvent) {
|
||||
@@ -162,11 +164,12 @@ class LnZapRequestEvent(
|
||||
relays: Set<String>,
|
||||
pollOption: Int?,
|
||||
message: String,
|
||||
toUserPubHex: String?, // Overrides in case of Zap Splits
|
||||
createdAt: Long = TimeUtils.now()
|
||||
): LnZapRequestEvent {
|
||||
var tags = listOf(
|
||||
listOf("e", originalNote.id()),
|
||||
listOf("p", originalNote.pubKey()),
|
||||
listOf("p", toUserPubHex ?: originalNote.pubKey()),
|
||||
listOf("relays") + relays
|
||||
)
|
||||
if (originalNote is AddressableEvent) {
|
||||
|
Reference in New Issue
Block a user