From 54df8629985038672ffd3e8beca47d7a00087a7d Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 1 Jan 2025 16:44:16 -0500 Subject: [PATCH] ssb: Continuing to untangle message CSS. --- apps/ssb.json | 2 +- apps/ssb/tf-message.js | 351 ++++++++++++++++++----------------------- 2 files changed, 151 insertions(+), 202 deletions(-) diff --git a/apps/ssb.json b/apps/ssb.json index 4c02f371..bc733650 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🦀", - "previous": "&sPU6rF2WYaSdq1SBw5XyxOjiahAxtGUbeg0LOpkQ6Eg=.sha256" + "previous": "&LZizSyrgaKYbjRKj2FfmnCTnkB39ndQ9AVWVC4o3AQk=.sha256" } diff --git a/apps/ssb/tf-message.js b/apps/ssb/tf-message.js index a8071e12..c1db855e 100644 --- a/apps/ssb/tf-message.js +++ b/apps/ssb/tf-message.js @@ -368,21 +368,125 @@ class TfMessageElement extends LitElement { : 'w3-theme-d4'; } - render_small_frame(inner) { - let self = this; + get_content() { + let content = this.message?.content; + if (this.message?.decrypted?.type == 'post') { + content = this.message.decrypted; + } + return content; + } + + render_raw_button() { + let content = this.get_content(); + let raw_button; + switch (this.format) { + case 'raw': + if (content?.type == 'post' || content?.type == 'blog') { + raw_button = html``; + } else { + raw_button = html``; + } + break; + case 'md': + raw_button = html``; + break; + case 'decrypted': + raw_button = html``; + break; + default: + if (this.message.decrypted) { + raw_button = html``; + } else { + raw_button = html``; + } + break; + } + return raw_button; + } + + render_header() { + let is_encrypted = this.message?.decrypted + ? html`🔓` + : undefined; return html` -
- - + + + + ${is_encrypted} + ${this.render_raw_button()} + % - ${new Date(self.message.timestamp).toLocaleString()} - ${raw_button} ${self.format == 'raw' ? self.render_raw() : inner} + + `; + } + + render_frame(inner) { + return html` + +
+ ${inner} +
+ `; + } + + render_small_frame(inner) { + let self = this; + return this.render_frame(html` + ${self.render_header()} + ${self.format == 'raw' ? self.render_raw() : inner} ${self.render_votes()} ${(self.message.child_messages || []).map( (x) => html` @@ -397,11 +501,11 @@ class TfMessageElement extends LitElement { > ` )} -
- `; + `); } render_actions() { + let content = this.get_content(); let reply = this.drafts[this.message?.id] !== undefined ? html` @@ -421,7 +525,7 @@ class TfMessageElement extends LitElement { `; return html` -
+
${reply} `; - } else { - raw_button = html``; - } - break; - case 'md': - raw_button = html``; - break; - case 'decrypted': - raw_button = html``; - break; - default: - if (this.message.decrypted) { - raw_button = html``; - } else { - raw_button = html``; - } - break; - } if (this.message?.type === 'contact_group') { - return html`
+ return this.render_frame(html` ${this.message.messages.map( (x) => html`` - )} -
`; + )}`); } else if (this.message.placeholder) { - return html`
+ return this.render_frame(html` ${this.message.id} @@ -531,32 +575,31 @@ class TfMessageElement extends LitElement { channel_unread=${this.channel_unread} > ` - )} -
`; + )}`); } else if (typeof (content?.type === 'string')) { if (content.type == 'about') { let name; let image; let description; if (content.name !== undefined) { - name = html`
Name: ${content.name}
`; + name = html`
Name: ${content.name}
`; } if (content.image !== undefined) { image = html` -
+
`; } if (content.description !== undefined) { description = html` -
+
${unsafeHTML(tfutils.markdown(content.description))}
`; } let update = content.about == this.message.author - ? html`
Updated profile.
` - : html`
+ ? html`
Updated profile.
` + : html`
Updated profile for .
`; @@ -565,7 +608,7 @@ class TfMessageElement extends LitElement { `); } else if (content.type == 'contact') { return html` -
+
is ${content.blocking === true @@ -625,88 +668,26 @@ class TfMessageElement extends LitElement { let is_encrypted = this.message?.decrypted ? html`🔓` : undefined; - return html` - -
-
- - ${is_encrypted} - - % - ${new Date(this.message.timestamp).toLocaleString()} - ${raw_button} -
- ${payload} ${this.render_votes()} ${this.render_actions()} -
- `; + return this.render_frame(html` + ${this.render_header()} +
${payload}
+ ${this.render_votes()} ${this.render_actions()} +
+ `); } else if (content.type === 'issue') { let is_encrypted = this.message?.decrypted ? html`🔓` : undefined; - return html` - -
-
- - ${is_encrypted} - - % - ${new Date(this.message.timestamp).toLocaleString()} - ${raw_button} -
- ${content.text} ${this.render_votes()} -
- - ${this.render_children()} -
-
- `; + return this.render_frame(html` + ${this.render_header()} + ${content.text} ${this.render_votes()} +
+ + ${this.render_children()} +
+ `); } else if (content.type === 'blog') { let self = this; tfrpc.rpc.get_blob(content.blog).then(function (data) { @@ -742,44 +723,12 @@ class TfMessageElement extends LitElement { `; break; } - return html` - -
-
- - - % - ${new Date(this.message.timestamp).toLocaleString()} - ${raw_button} -
- -
${body}
- ${this.render_mentions()} ${this.render_votes()} - ${this.render_actions()} -
- `; + return this.render_frame(html` + ${this.render_header()} +
${body}
+ ${this.render_mentions()} ${this.render_votes()} + ${this.render_actions()} + `); } else if (content.type === 'pub') { return this.render_small_frame( html`