diff --git a/apps/ssb.json b/apps/ssb.json index a4e01104..4c02f371 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🦀", - "previous": "&bBoMW+AjErDfa483Mg3+h1L25xfDDeVSpcfD9WAwL3U=.sha256" + "previous": "&sPU6rF2WYaSdq1SBw5XyxOjiahAxtGUbeg0LOpkQ6Eg=.sha256" } diff --git a/apps/ssb/tf-message.js b/apps/ssb/tf-message.js index b6e8c712..a8071e12 100644 --- a/apps/ssb/tf-message.js +++ b/apps/ssb/tf-message.js @@ -97,6 +97,13 @@ class TfMessageElement extends LitElement { } } + render_json(value) { + let json = JSON.stringify(value, null, 2); + return html` +
${json}
+ `; + } + render_raw() { let raw = { id: this.message?.id, @@ -108,9 +115,7 @@ class TfMessageElement extends LitElement { content: this.message?.content, signature: this.message?.signature, }; - return html`
- ${JSON.stringify(raw, null, 2)} -
`; + return this.render_json(raw); } vote(emoji) { @@ -190,7 +195,7 @@ class TfMessageElement extends LitElement { render_mention(mention) { if (!mention?.link || typeof mention.link != 'string') { - return html`
${JSON.stringify(mention)}
`; + return this.render_json(mention); } else if ( mention?.link?.startsWith('&') && mention?.type?.startsWith('image/') @@ -241,9 +246,7 @@ class TfMessageElement extends LitElement { ) { return html` ${mention.name}`; } else { - return html`
-${JSON.stringify(mention, null, 2)}
`; + return this.render_json(mention); } } @@ -357,16 +360,83 @@ ${JSON.stringify(mention, null, 2)} html``); } + class_background() { + return this.message?.decrypted + ? 'w3-pale-red' + : this.message?.rowid >= this.channel_unread + ? 'w3-theme-d2' + : 'w3-theme-d4'; + } + + render_small_frame(inner) { + let self = this; + return html` +
+ + % + ${new Date(self.message.timestamp).toLocaleString()} + ${raw_button} ${self.format == 'raw' ? self.render_raw() : inner} + ${self.render_votes()} + ${(self.message.child_messages || []).map( + (x) => html` + + ` + )} +
+ `; + } + + render_actions() { + let reply = + this.drafts[this.message?.id] !== undefined + ? html` + + ` + : html` + + `; + return html` +
+ ${reply} + + ${this.render_children()} +
+ `; + } + render() { let content = this.message?.content; if (this.message?.decrypted?.type == 'post') { content = this.message.decrypted; } - let class_background = this.message?.decrypted - ? 'w3-pale-red' - : this.message?.rowid >= this.channel_unread - ? 'w3-theme-d2' - : 'w3-theme-d4'; + let class_background = this.class_background(); let self = this; let raw_button; switch (this.format) { @@ -421,38 +491,6 @@ ${JSON.stringify(mention, null, 2)} - - % - ${new Date(self.message.timestamp).toLocaleString()} - ${raw_button} ${self.format == 'raw' ? self.render_raw() : inner} - ${self.render_votes()} - ${(self.message.child_messages || []).map( - (x) => html` - - ` - )} - - `; - } if (this.message?.type === 'contact_group') { return html`
.
`; - return small_frame(html` ${update} ${name} ${image} ${description} `); + return this.render_small_frame(html` + ${update} ${name} ${image} ${description} + `); } else if (content.type == 'contact') { return html`
@@ -544,24 +584,6 @@ ${JSON.stringify(mention, null, 2)} `; } else if (content.type == 'post') { - let reply = - this.drafts[this.message?.id] !== undefined - ? html` - - ` - : html` - - `; let self = this; let body; switch (this.format) { @@ -578,11 +600,7 @@ ${JSON.stringify(mention, null, 2)} -${JSON.stringify(content, null, 2)}`; + body = this.render_json(content); break; } let content_warning = html` @@ -640,24 +658,7 @@ ${JSON.stringify(content, null, 2)} ${raw_button}
- ${payload} ${this.render_votes()} - + ${payload} ${this.render_votes()} ${this.render_actions()} `; } else if (content.type === 'issue') { @@ -741,24 +742,6 @@ ${JSON.stringify(content, null, 2)} - ` - : html` - - `; return html`