-
diff --git a/apps/ssb/tf-app.js b/apps/ssb/tf-app.js index a95842a4..521337c7 100644 --- a/apps/ssb/tf-app.js +++ b/apps/ssb/tf-app.js @@ -72,7 +72,8 @@ class TfElement extends LitElement { } async load_channels() { - let channels = await tfrpc.rpc.query(` + let channels = await tfrpc.rpc.query( + ` SELECT content ->> 'channel' AS channel, content ->> 'subscribed' AS subscribed @@ -82,7 +83,9 @@ class TfElement extends LitElement { author = ? AND content ->> 'type' = 'channel' ORDER BY sequence - `, [this.whoami]); + `, + [this.whoami] + ); let channel_map = {}; for (let row of channels) { if (row.subscribed) { @@ -243,7 +246,8 @@ class TfElement extends LitElement { }; by_count.push({count: v.of, id: id}); } - let channels = tfrpc.rpc.query(` + let channels = tfrpc.rpc.query( + ` SELECT channels.value AS channel, MAX(messages.rowid) AS rowid FROM messages JOIN json_each(?1) AS channels ON messages.content ->> 'channel' = channels.value JOIN json_each(?2) AS following ON messages.author = following.value @@ -257,12 +261,16 @@ class TfElement extends LitElement { SELECT '@' AS channel, MAX(messages.rowid) AS rowid FROM messages_fts(?3) JOIN messages ON messages.rowid = messages_fts.rowid JOIN json_each(?2) AS following ON messages.author = following.value - `, [ - JSON.stringify(this.channels), - JSON.stringify(Object.keys(following)), - '"' + this.whoami.replace('"', '""') + '"', - ]); - this.channels_unread = JSON.parse((await tfrpc.rpc.databaseGet('unread')) ?? '{}'); + `, + [ + JSON.stringify(this.channels), + JSON.stringify(Object.keys(following)), + '"' + this.whoami.replace('"', '""') + '"', + ] + ); + this.channels_unread = JSON.parse( + (await tfrpc.rpc.databaseGet('unread')) ?? '{}' + ); let start_time = new Date(); users = await this.fetch_about(Object.keys(following).sort(), users); console.log( @@ -275,7 +283,9 @@ class TfElement extends LitElement { start_time = new Date(); channels = await channels; console.log('channels took', (new Date() - start_time) / 1000.0); - this.channels_latest = Object.fromEntries(channels.map(x => [x.channel, x.rowid])); + this.channels_latest = Object.fromEntries( + channels.map((x) => [x.channel, x.rowid]) + ); this.following = Object.keys(following); this.users = users; console.log(`load finished ${whoami} => ${this.whoami}`); @@ -375,7 +385,10 @@ class TfElement extends LitElement { }; let tabs = html` -