From aa15da50abfb247e430e1421fb535f1d5696fab1 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 11 Jan 2025 14:09:42 -0500 Subject: [PATCH] ssb: Tried to do the right lit things to prevent unnecessary re-rendering. Ended up doing a lazy JSON thing. --- apps/ssb.json | 2 +- apps/ssb/tf-message.js | 6 ++++-- apps/ssb/tf-news.js | 6 ++++-- apps/ssb/tf-tab-news-feed.js | 9 +++++---- apps/ssb/tf-tab-news.js | 6 +++--- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/apps/ssb.json b/apps/ssb.json index 99196bfd..a69876fe 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🦀", - "previous": "&5YZ9ja1NymBZsDaHIrpgZCzn95R34Y1RQug6gy4EULU=.sha256" + "previous": "&caGw+RHTGO/WBWQDiRRv/9/SDZPS3w8U4xNafZEQrYw=.sha256" } diff --git a/apps/ssb/tf-message.js b/apps/ssb/tf-message.js index 90377e71..8fd7a204 100644 --- a/apps/ssb/tf-message.js +++ b/apps/ssb/tf-message.js @@ -1,4 +1,4 @@ -import {LitElement, html, render, unsafeHTML} from './lit-all.min.js'; +import {LitElement, html, repeat, render, unsafeHTML} from './lit-all.min.js'; import * as tfrpc from '/static/tfrpc.js'; import * as tfutils from './tf-utils.js'; import * as emojis from './emojis.js'; @@ -313,7 +313,9 @@ class TfMessageElement extends LitElement { @click=${() => self.set_expanded(false)} > Collapse${(this.message.child_messages || []).map( + >${repeat( + this.message.child_messages || [], + (x) => x.id, (x) => html` - ${final_messages.map( + ${repeat( + final_messages, + (x) => x.id, (x) => html` `; } - return html` + return cache(html` @@ -433,7 +434,7 @@ class TfTabNewsFeedElement extends LitElement { channel_unread=${this.channels_unread?.[this.channel()]} > ${more} - `; + `); } } diff --git a/apps/ssb/tf-tab-news.js b/apps/ssb/tf-tab-news.js index ef99fadd..d404eb7c 100644 --- a/apps/ssb/tf-tab-news.js +++ b/apps/ssb/tf-tab-news.js @@ -1,4 +1,4 @@ -import {LitElement, html, unsafeHTML, until} from './lit-all.min.js'; +import {LitElement, cache, html, unsafeHTML, until} from './lit-all.min.js'; import * as tfrpc from '/static/tfrpc.js'; import {styles} from './tf-styles.js'; @@ -238,7 +238,7 @@ class TfTabNewsElement extends LitElement { name. `; } - return html` + return cache(html` ${this.render_sidebar()}
- `; + `); } }