From eb6753afe18d6505bd2ede695f4d224ab0ec2296 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Mon, 23 Dec 2024 11:08:27 -0500 Subject: [PATCH] ssb: prettier. --- apps/ssb/emojis.js | 10 ++++++-- apps/ssb/tf-app.js | 58 ++++++++++++++++++++++++--------------------- apps/ssb/tf-news.js | 47 ++++++++++++++++++------------------ 3 files changed, 62 insertions(+), 53 deletions(-) diff --git a/apps/ssb/emojis.js b/apps/ssb/emojis.js index a4d57f48..51dbf95e 100644 --- a/apps/ssb/emojis.js +++ b/apps/ssb/emojis.js @@ -155,9 +155,15 @@ export async function picker(callback, anchor, author) { -
+
-
+

Choose a Reaction

= 0) { - let messages = await tfrpc.rpc.query(` + let messages = await tfrpc.rpc.query( + ` SELECT messages.rowid, messages.id, previous, author, sequence, timestamp, hash, json(content) AS content, signature FROM messages JOIN json_each(?1) AS following ON messages.author = following.value @@ -284,17 +287,14 @@ class TfElement extends LitElement { json(messages.content) LIKE '"%' ORDER BY sequence DESC `, - [ - JSON.stringify(following), - latest - k_chunk_count, - latest, - ]); - messages = (await this.decrypt(messages)).filter(x => x.decrypted); + [JSON.stringify(following), latest - k_chunk_count, latest] + ); + messages = (await this.decrypt(messages)).filter((x) => x.decrypted); if (messages.length) { - return Math.max(...messages.map(x => x.rowid)); + return Math.max(...messages.map((x) => x.rowid)); } latest -= k_chunk_count; - }; + } return -1; } @@ -331,8 +331,10 @@ class TfElement extends LitElement { console.log('unread', this.channels_unread); console.log('channels took', (new Date() - start_time) / 1000.0); let self = this; - latest_private.then(function(latest) { - self.channels_latest = Object.assign({}, self.channels_latest, {'🔐': latest}); + latest_private.then(function (latest) { + self.channels_latest = Object.assign({}, self.channels_latest, { + '🔐': latest, + }); console.log('private took', (new Date() - start_time) / 1000.0); }); } finally { @@ -398,26 +400,28 @@ class TfElement extends LitElement { async decrypt(messages) { let whoami = this.whoami; - return Promise.all(messages.map(async function (message) { - let content; - try { - content = JSON.parse(message?.content); - } catch {} - if (typeof content === 'string') { - let decrypted; + return Promise.all( + messages.map(async function (message) { + let content; try { - decrypted = await tfrpc.rpc.try_decrypt(whoami, content); + content = JSON.parse(message?.content); } catch {} - if (decrypted) { + if (typeof content === 'string') { + let decrypted; try { - message.decrypted = JSON.parse(decrypted); - } catch { - message.decrypted = decrypted; + decrypted = await tfrpc.rpc.try_decrypt(whoami, content); + } catch {} + if (decrypted) { + try { + message.decrypted = JSON.parse(decrypted); + } catch { + message.decrypted = decrypted; + } } } - } - return message; - })); + return message; + }) + ); } render_tab() { diff --git a/apps/ssb/tf-news.js b/apps/ssb/tf-news.js index 41efb504..33ef0db7 100644 --- a/apps/ssb/tf-news.js +++ b/apps/ssb/tf-news.js @@ -199,30 +199,29 @@ class TfNewsElement extends LitElement { return html`
${final_messages.map( - (x) => - html` - - ${x.rowid == unread_rowid && x != final_messages[0] - ? html`
-
-
unread
-
-
` - : undefined} - ` + (x) => html` + + ${x.rowid == unread_rowid && x != final_messages[0] + ? html`
+
+
unread
+
+
` + : undefined} + ` )}
`;