From 799f22e9897b4a579497bc33f5a468593ba6d92a Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 11 May 2025 21:42:48 -0400 Subject: [PATCH] ssb: The updated fetch_abouts means that image JSON is now a string we need to handle in tf-user / tf-profile. --- apps/ssb.json | 2 +- apps/ssb/tf-app.js | 23 ++++++++--------------- apps/ssb/tf-profile.js | 9 +++++++-- apps/ssb/tf-user.js | 8 ++++++-- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/apps/ssb.json b/apps/ssb.json index f873b906..546c5778 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🦀", - "previous": "&VQsPosjAfr008a6UMb8vKmKxE/WS4DRKEspJL8Lewjw=.sha256" + "previous": "&Omm/IjiQ9yXgJrDUtXp3q+Qdu9qDLfi05FXI5JtP5Qo=.sha256" } diff --git a/apps/ssb/tf-app.js b/apps/ssb/tf-app.js index 0b84ee24..a424aadf 100644 --- a/apps/ssb/tf-app.js +++ b/apps/ssb/tf-app.js @@ -167,23 +167,16 @@ class TfElement extends LitElement { if (ids.indexOf(id) == -1) { delete cache.about[id]; } else { - users[id] = Object.assign(users[id] || {}, cache.about[id]); + users[id] = Object.assign( + users[id] || {}, + cache.about[id] + ); } } - let ids_out_of_date = ids.filter( - (x) => - cache.about[x]?.seq === undefined || - (users[x]?.seq && users[x]?.seq > cache.about[x].seq) - ); + let ids_out_of_date = ids.filter(x => cache.about[x]?.seq === undefined || (users[x]?.seq && users[x]?.seq > cache.about[x].seq)); - console.log( - 'loading about for', - ids.length, - 'accounts', - ids_out_of_date.length, - 'out of date' - ); + console.log('loading about for', ids.length, 'accounts', ids_out_of_date.length, 'out of date'); if (ids_out_of_date.length) { try { let rows = await tfrpc.rpc.query( @@ -226,12 +219,12 @@ class TfElement extends LitElement { if (!cache.about[id]?.seq) { cache.about[id] = {seq: users[id]?.seq ?? 0}; } - } + }; let new_cache = JSON.stringify(cache); if (new_cache != original_cache) { let start_time = new Date(); - tfrpc.rpc.databaseSet('about', new_cache).then(function () { + tfrpc.rpc.databaseSet('about', new_cache).then(function() { console.log('saving about took', (new Date() - start_time) / 1000); }); } diff --git a/apps/ssb/tf-profile.js b/apps/ssb/tf-profile.js index d5466b68..a2528bf7 100644 --- a/apps/ssb/tf-profile.js +++ b/apps/ssb/tf-profile.js @@ -242,8 +242,13 @@ class TfProfileElement extends LitElement { ` : null; - let image = - typeof profile.image == 'string' ? profile.image : profile.image?.link; + let image =profile.image; + if (typeof image == 'string' && !image.startsWith('&')) { + try { + image = JSON.parse(image)?.link; + } catch { + } + } image = this.editing?.image ?? image; let description = this.editing?.description ?? profile.description; return html`
diff --git a/apps/ssb/tf-user.js b/apps/ssb/tf-user.js index 335c91b2..f4d51608 100644 --- a/apps/ssb/tf-user.js +++ b/apps/ssb/tf-user.js @@ -38,8 +38,12 @@ class TfUserElement extends LitElement { if (user) { let image_link = user.image; - image_link = - typeof image_link == 'string' ? image_link : image_link?.link; + if (typeof image_link == 'string' && !image_link.startsWith('&')) { + try { + image_link = JSON.parse(image_link)?.link; + } catch { + } + } if (image_link !== undefined) { image = html`