From e0110203e711db14967d9ba586ed466b9d36e07f Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 2 Sep 2023 02:06:29 +0000 Subject: [PATCH] More reliable addition of encrypted messages. There's something I'm not understanding with lit. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4440 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/ssb/tf-message.js | 34 ++++++++-------------------------- apps/ssb/tf-tab-news-feed.js | 35 +++++++++++++++++++++++++++++++++-- apps/ssb/tf-tab-news.js | 2 +- 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/apps/ssb/tf-message.js b/apps/ssb/tf-message.js index dd6c6058..7b51da72 100644 --- a/apps/ssb/tf-message.js +++ b/apps/ssb/tf-message.js @@ -14,7 +14,6 @@ class TfMessageElement extends LitElement { format: {type: String}, blog_data: {type: String}, expanded: {type: Object}, - decrypted: {type: Object}, }; } @@ -29,7 +28,6 @@ class TfMessageElement extends LitElement { this.drafts = {}; this.format = 'message'; this.expanded = {}; - this.decrypted = undefined; } show_reply() { @@ -222,8 +220,8 @@ class TfMessageElement extends LitElement { render_channels() { let content = this.message?.content; - if (this.decrypted?.type == 'post') { - content = this.decrypted; + if (this?.messsage?.decrypted?.type == 'post') { + content = this.message.decrypted; } let channels = []; if (typeof content.channel === 'string') { @@ -240,23 +238,10 @@ class TfMessageElement extends LitElement { return channels.map(x => html``); } - async try_decrypt(content) { - let result = await tfrpc.rpc.try_decrypt(this.whoami, content); - if (result) { - try { - this.decrypted = JSON.parse(result); - } catch { - this.decrypted = result; - } - } else { - this.decrypted = false; - } - } - render() { let content = this.message?.content; - if (this.decrypted?.type == 'post') { - content = this.decrypted; + if (this.message?.decrypted?.type == 'post') { + content = this.message.decrypted; } let self = this; let raw_button; @@ -390,8 +375,8 @@ class TfMessageElement extends LitElement { ` : content_warning : content_html; - let is_encrypted = this.decrypted ? html`🔓` : undefined; - let style_background = this.decrypted ? 'rgba(255, 0, 0, 0.2)' : 'rgba(255, 255, 255, 0.1)'; + let is_encrypted = this.message?.decrypted ? html`🔓` : undefined; + let style_background = this.message?.decrypted ? 'rgba(255, 0, 0, 0.2)' : 'rgba(255, 255, 255, 0.1)'; return html`