From bf9ff088fde2c66272cd5bb9d4138e0a3bec3563 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 17 May 2023 16:57:43 +0000 Subject: [PATCH] Handle unsuccessfully decrypted messages, too. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4301 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/ssb/tf-message.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/ssb/tf-message.js b/apps/ssb/tf-message.js index 92e26514..e7c372cc 100644 --- a/apps/ssb/tf-message.js +++ b/apps/ssb/tf-message.js @@ -221,7 +221,12 @@ class TfMessageElement extends LitElement { } async try_decrypt(content) { - this.decrypted = JSON.parse(await tfrpc.rpc.try_decrypt(this.whoami, content)); + let result = await tfrpc.rpc.try_decrypt(this.whoami, content); + if (result) { + this.decrypted = JSON.parse(result); + } else { + this.decrypted = false; + } } render() { @@ -442,11 +447,13 @@ class TfMessageElement extends LitElement { `); } else if (typeof(this.message.content) == 'string') { - if (this.decrypted !== undefined) { + if (this.decrypted) { return small_frame(html`🔓
${JSON.stringify(this.decrypted, null, 2)}
`); + } else if (this.decrypted === undefined) { + this.try_decrypt(content); + return small_frame(html`🔐`); } else { - this.try_decrypt(content); - return small_frame(html`🔐`); + return small_frame(html`🔒`); } } else { return small_frame(html`
type: ${content.type}
`);