fix freeze when going to dms screen

This commit is contained in:
greenart7c3
2023-09-13 10:08:43 -03:00
parent de5c0d4681
commit 58cf0d9f5d
3 changed files with 14 additions and 2 deletions
@@ -2570,7 +2570,8 @@ class Account(
return when (event) {
is PrivateDmEvent -> {
if (AmberUtils.cachedDecryptedContent[event.id] == null) {
AmberUtils.decrypt(
AmberUtils.content = ""
AmberUtils.decryptDM(
event.content,
event.talkingWith(userProfile().pubkeyHex),
event.id
@@ -96,6 +96,16 @@ object AmberUtils {
}
}
fun decryptDM(encryptedContent: String, pubKey: HexKey, id: String, signerType: SignerType = SignerType.NIP04_DECRYPT) {
openAmber(
encryptedContent,
signerType,
IntentUtils.activityResultLauncher,
pubKey,
id
)
}
fun decryptBookmark(encryptedContent: String, pubKey: HexKey, id: String, signerType: SignerType = SignerType.NIP04_DECRYPT) {
openAmber(
encryptedContent,
@@ -1262,7 +1262,8 @@ fun RenderTextEvent(
) {
val eventContent = remember(note.event) {
val subject = (note.event as? TextNoteEvent)?.subject()?.ifEmpty { null }
val body = accountViewModel.decrypt(note)
val decryptedContent = if (note.event == null) null else AmberUtils.cachedDecryptedContent[note.event!!.id()]
val body = decryptedContent ?: accountViewModel.decrypt(note)
if (!subject.isNullOrBlank() && body?.split("\n")?.get(0)?.contains(subject) == false) {
"## $subject\n$body"