From 1c3e004d3d3344f2a7c4017e802d3ed3925ced3b Mon Sep 17 00:00:00 2001 From: adgohar <114059470+adgohar@users.noreply.github.com> Date: Sun, 23 Feb 2025 02:09:44 +0100 Subject: [PATCH] Fix Delete Button Freeze Add check for type of the decoded entry to fix a bug where the delete button freezes when the program is checking if a contact has been deleted --- .../scuttlebutt/tremolavossbol/WebAppInterface.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/WebAppInterface.kt b/android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/WebAppInterface.kt index f87890c3..4fb7540b 100644 --- a/android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/WebAppInterface.kt +++ b/android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/WebAppInterface.kt @@ -624,15 +624,15 @@ class WebAppInterface(val act: MainActivity, val webView: WebView) { //decode the entry using Bipf decode val decodedEntry = entry?.let { Bipf.decode(it) } - //get bytes from the decoded entry - val entryBytes = decodedEntry?.let {it.getBytes()} + if (decodedEntry != null && decodedEntry.typ == BIPF_BYTES) { + //get bytes from the decoded entry + val entryBytes = decodedEntry.getBytes() - //decrypt the bytes to get the clear text - val clear = entryBytes?.let { act.idStore.identity.decryptPrivateMessage(it) } + //decrypt the bytes to get the clear text + val clear = entryBytes.let { act.idStore.identity.decryptPrivateMessage(it) } - val entryType = clear?.let { getFromEntry(it, 0) } - if (entryType == "DEL") { - if (clear is ByteArray) { + val entryType = clear?.let { getFromEntry(it, 0) } + if (entryType == "DEL") { val contactID = getFromEntry(clear, 1) val deleted = getFromEntry(clear, 2) Log.d("readContactDeleted", "Contact ID: $contactID, Deleted: $deleted")