mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-20 17:00:53 +02:00
fix decryption of dms whe new message is send
This commit is contained in:
@@ -30,6 +30,7 @@ object AmberUtils {
|
|||||||
val cachedDecryptedContent = mutableMapOf<HexKey, String>()
|
val cachedDecryptedContent = mutableMapOf<HexKey, String>()
|
||||||
lateinit var account: Account
|
lateinit var account: Account
|
||||||
lateinit var activityResultLauncher: ActivityResultLauncher<Intent>
|
lateinit var activityResultLauncher: ActivityResultLauncher<Intent>
|
||||||
|
lateinit var decryptResultLauncher: ActivityResultLauncher<Intent>
|
||||||
lateinit var blockListResultLauncher: ActivityResultLauncher<Intent>
|
lateinit var blockListResultLauncher: ActivityResultLauncher<Intent>
|
||||||
lateinit var signEventResultLauncher: ActivityResultLauncher<Intent>
|
lateinit var signEventResultLauncher: ActivityResultLauncher<Intent>
|
||||||
|
|
||||||
@@ -62,6 +63,32 @@ object AmberUtils {
|
|||||||
|
|
||||||
activityResultLauncher = activity.registerForActivityResult(
|
activityResultLauncher = activity.registerForActivityResult(
|
||||||
ActivityResultContracts.StartActivityForResult()
|
ActivityResultContracts.StartActivityForResult()
|
||||||
|
) {
|
||||||
|
if (it.resultCode != Activity.RESULT_OK) {
|
||||||
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
|
Toast.makeText(
|
||||||
|
Amethyst.instance,
|
||||||
|
"Sign request rejected",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val event = it.data?.getStringExtra("signature") ?: ""
|
||||||
|
val id = it.data?.getStringExtra("id") ?: ""
|
||||||
|
if (id.isNotBlank()) {
|
||||||
|
content.put(id, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isActivityRunning = false
|
||||||
|
ServiceManager.shouldPauseService = true
|
||||||
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
|
isActivityRunning = false
|
||||||
|
ServiceManager.shouldPauseService = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
decryptResultLauncher = activity.registerForActivityResult(
|
||||||
|
ActivityResultContracts.StartActivityForResult()
|
||||||
) {
|
) {
|
||||||
if (it.resultCode != Activity.RESULT_OK) {
|
if (it.resultCode != Activity.RESULT_OK) {
|
||||||
GlobalScope.launch(Dispatchers.Main) {
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
@@ -223,7 +250,7 @@ object AmberUtils {
|
|||||||
openAmber(
|
openAmber(
|
||||||
encryptedContent,
|
encryptedContent,
|
||||||
signerType,
|
signerType,
|
||||||
activityResultLauncher,
|
decryptResultLauncher,
|
||||||
pubKey,
|
pubKey,
|
||||||
id
|
id
|
||||||
)
|
)
|
||||||
@@ -242,7 +269,7 @@ object AmberUtils {
|
|||||||
openAmber(
|
openAmber(
|
||||||
encryptedContent,
|
encryptedContent,
|
||||||
signerType,
|
signerType,
|
||||||
activityResultLauncher,
|
decryptResultLauncher,
|
||||||
pubKey,
|
pubKey,
|
||||||
id
|
id
|
||||||
)
|
)
|
||||||
@@ -258,7 +285,7 @@ object AmberUtils {
|
|||||||
openAmber(
|
openAmber(
|
||||||
encryptedContent,
|
encryptedContent,
|
||||||
signerType,
|
signerType,
|
||||||
activityResultLauncher,
|
decryptResultLauncher,
|
||||||
pubKey,
|
pubKey,
|
||||||
id
|
id
|
||||||
)
|
)
|
||||||
@@ -277,7 +304,7 @@ object AmberUtils {
|
|||||||
signerType,
|
signerType,
|
||||||
activityResultLauncher,
|
activityResultLauncher,
|
||||||
pubKey,
|
pubKey,
|
||||||
"encrypt"
|
id
|
||||||
)
|
)
|
||||||
while (isActivityRunning) {
|
while (isActivityRunning) {
|
||||||
Thread.sleep(100)
|
Thread.sleep(100)
|
||||||
@@ -294,7 +321,7 @@ object AmberUtils {
|
|||||||
openAmber(
|
openAmber(
|
||||||
event.toJson(),
|
event.toJson(),
|
||||||
SignerType.DECRYPT_ZAP_EVENT,
|
SignerType.DECRYPT_ZAP_EVENT,
|
||||||
activityResultLauncher,
|
decryptResultLauncher,
|
||||||
event.pubKey,
|
event.pubKey,
|
||||||
event.id
|
event.id
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user