From 1abc611e54ebf55668c9dc94ec0afdf0a28e2d25 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Fri, 21 Oct 2022 23:31:32 +0000 Subject: [PATCH] Trying to do mentions and refs betters. Questionable success. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4016 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/cory/ssblit.json | 2 +- apps/cory/ssblit/tf-message.js | 8 +++++--- apps/cory/ssblit/tf-tab-news.js | 29 ++++++++++++++++++++++------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/apps/cory/ssblit.json b/apps/cory/ssblit.json index b34e176f..6cc32b31 100644 --- a/apps/cory/ssblit.json +++ b/apps/cory/ssblit.json @@ -1 +1 @@ -{"type":"tildefriends-app","files":{"app.js":"&0pjNvkWm12JIkr7z9az5bdGjrM1VhEiQawf7hnMhvwA=.sha256","lit-all.min.js":"&N4A12AsifdQgwdpII0SFtG513BfoLpmPjdJ9VTDftpg=.sha256","index.html":"&Vpp3ezlQiD5guf1P6yZhpcNMnO0u+uQoil3hNkwiIp4=.sha256","script.js":"&G8puK9Q4MngHy3D4ppcKyT49WKbHD2OCeUcAw2ghTDE=.sha256","lit-all.min.js.map":"&oFY9wO4MnujgfGNGv4VggHc5V5JwX4C8csqKZ6KJYbE=.sha256","tf-id-picker.js":"&9BDffV4HY9FqhL7XI4it+UQJB4cYwbDNsY3S1cxy2vw=.sha256","tf-app.js":"&qqpOZHnkJQevhLGPUEJ7br2S/LNH+nQtC91vz3CrYrE=.sha256","tf-message.js":"&yo0PiAQLZ2NlYjwCm2VwWH4BZx71TsAQjpJ02RGNnf4=.sha256","tf-user.js":"&bXTedgBudTQLXEBPY9R8OLfQ/ZLpo8YRU9Oq/wuGG3Y=.sha256","tf-utils.js":"&N2yKZwFnb2GbPeipgQtu6xFvezENNOgud9G7EhCQ/K0=.sha256","commonmark.min.js":"&bfBaMLU19d1p/vPBF9hlARqDX002KXG/UOfxOahZhe4=.sha256","tf-compose.js":"&oM+e4/FIA7X6bkap7m9XmO+tbUljHJxlXpJjnM9veG8=.sha256","emojis.json":"&h3P4pez+AI4aYdsN0dJ3pbUEFR0276t9AM20caj/W/s=.sha256","emojis.js":"&pqYLDE/13PyEt2ceeFqvnwZ8NqWfPfpDBt4vP8SeHbs=.sha256","tf-styles.js":"&Zw90HptAvGwX/vBnEhRVfNrYjMSssFnnKpp8bzwXQH0=.sha256","tf-profile.js":"&vRKjsnYvOiHCQahzEfznCvP5YDwUPtltlpWf+pxwZ1Y=.sha256","commonmark-linkify.js":"&X+hNNkmSRvKY86khyAun+cXksquXbMakZdINbGbx30g=.sha256","tf-tab-search.js":"&ESt2vMG19sH5j6ungKua/ZuvIGslyuWyb3juXdOCecg=.sha256","tf-tab-news.js":"&6ialbh/M2eBCDH6wFyoOHyDqG9QHbyIrzvRK+CgeyRc=.sha256","tf-tab-connections.js":"&jSnF/5NmgqxRze1XQAEGOW5mPzOV1/8aCyrDRZu34IQ=.sha256","tf-news.js":"&p9jlv5IEBe6Vi6cT/jAZ+GxOABqZue4DinCLiqN/V9I=.sha256","tribute.css":"&9FogMzZHKXCfGb7mlh7z+/wiNZzBsOB/tKoh6MfYJno=.sha256","tribute.esm.js":"&P1wKqCfYULpR/ahSB98JP8xaxfikuZwwtT6I/SAo7/Y=.sha256"}} \ No newline at end of file +{"type":"tildefriends-app","files":{"app.js":"&0pjNvkWm12JIkr7z9az5bdGjrM1VhEiQawf7hnMhvwA=.sha256","lit-all.min.js":"&N4A12AsifdQgwdpII0SFtG513BfoLpmPjdJ9VTDftpg=.sha256","index.html":"&Vpp3ezlQiD5guf1P6yZhpcNMnO0u+uQoil3hNkwiIp4=.sha256","script.js":"&G8puK9Q4MngHy3D4ppcKyT49WKbHD2OCeUcAw2ghTDE=.sha256","lit-all.min.js.map":"&oFY9wO4MnujgfGNGv4VggHc5V5JwX4C8csqKZ6KJYbE=.sha256","tf-id-picker.js":"&9BDffV4HY9FqhL7XI4it+UQJB4cYwbDNsY3S1cxy2vw=.sha256","tf-app.js":"&qqpOZHnkJQevhLGPUEJ7br2S/LNH+nQtC91vz3CrYrE=.sha256","tf-message.js":"&VuxfyhBr0YLYydk+7Ivpr99VCJdiU0KHcN6xus0AxwU=.sha256","tf-user.js":"&bXTedgBudTQLXEBPY9R8OLfQ/ZLpo8YRU9Oq/wuGG3Y=.sha256","tf-utils.js":"&N2yKZwFnb2GbPeipgQtu6xFvezENNOgud9G7EhCQ/K0=.sha256","commonmark.min.js":"&bfBaMLU19d1p/vPBF9hlARqDX002KXG/UOfxOahZhe4=.sha256","tf-compose.js":"&oM+e4/FIA7X6bkap7m9XmO+tbUljHJxlXpJjnM9veG8=.sha256","emojis.json":"&h3P4pez+AI4aYdsN0dJ3pbUEFR0276t9AM20caj/W/s=.sha256","emojis.js":"&pqYLDE/13PyEt2ceeFqvnwZ8NqWfPfpDBt4vP8SeHbs=.sha256","tf-styles.js":"&Zw90HptAvGwX/vBnEhRVfNrYjMSssFnnKpp8bzwXQH0=.sha256","tf-profile.js":"&vRKjsnYvOiHCQahzEfznCvP5YDwUPtltlpWf+pxwZ1Y=.sha256","commonmark-linkify.js":"&X+hNNkmSRvKY86khyAun+cXksquXbMakZdINbGbx30g=.sha256","tf-tab-search.js":"&ESt2vMG19sH5j6ungKua/ZuvIGslyuWyb3juXdOCecg=.sha256","tf-tab-news.js":"&FYyP6gPLawdUqmBuX+IOoQPLySmA8IMzEZOOHvsSRfE=.sha256","tf-tab-connections.js":"&jSnF/5NmgqxRze1XQAEGOW5mPzOV1/8aCyrDRZu34IQ=.sha256","tf-news.js":"&p9jlv5IEBe6Vi6cT/jAZ+GxOABqZue4DinCLiqN/V9I=.sha256","tribute.css":"&9FogMzZHKXCfGb7mlh7z+/wiNZzBsOB/tKoh6MfYJno=.sha256","tribute.esm.js":"&P1wKqCfYULpR/ahSB98JP8xaxfikuZwwtT6I/SAo7/Y=.sha256"}} \ No newline at end of file diff --git a/apps/cory/ssblit/tf-message.js b/apps/cory/ssblit/tf-message.js index 5c76b83f..1721cc3d 100644 --- a/apps/cory/ssblit/tf-message.js +++ b/apps/cory/ssblit/tf-message.js @@ -126,7 +126,7 @@ class TfMessageElement extends LitElement { render_mention(mention) { if (!mention?.link || typeof(mention.link) != 'string') { - return html`
${JSON.stringify(mention)}
`; + return html`
${JSON.stringify(mention)}
`; } else if (mention?.link?.startsWith('&') && mention?.type?.startsWith('image/')) { return html` @@ -141,13 +141,15 @@ class TfMessageElement extends LitElement { `; } else if (mention.link?.startsWith('&') && mention?.type === 'application/tildefriends') { - return html`😎 ${mention.name}`; + return html` 😎 ${mention.name}`; } else if (mention.link?.startsWith('%') || mention.link?.startsWith('@')) { return html` ${mention.name}`; } else if (mention.link?.startsWith('#')) { return html` ${mention.link}`; + } else if (Object.keys(mention).length == 2 && mention.link && mention.name) { + return html` ${mention.name}`; } else { - return html`
${JSON.stringify(mention, null, 2)}
`; + return html`
${JSON.stringify(mention, null, 2)}
`; } } diff --git a/apps/cory/ssblit/tf-tab-news.js b/apps/cory/ssblit/tf-tab-news.js index 5084b142..c339516d 100644 --- a/apps/cory/ssblit/tf-tab-news.js +++ b/apps/cory/ssblit/tf-tab-news.js @@ -26,17 +26,24 @@ class TfTabNewsFeedElement extends LitElement { async fetch_messages() { if (this.hash.startsWith('#@')) { - return await tfrpc.rpc.query( + let r = await tfrpc.rpc.query( ` + WITH mine AS (SELECT messages.* + FROM messages + WHERE messages.author = ? + ORDER BY sequence DESC + LIMIT 20) SELECT messages.* - FROM messages - WHERE messages.author = ? - ORDER BY sequence DESC - LIMIT 20 + FROM mine + JOIN messages_refs ON mine.id = messages_refs.ref + JOIN messages ON messages_refs.message = messages.id + UNION + SELECT * FROM mine `, [ this.hash.substring(1), ]); + return r; } else if (this.hash.startsWith('#%')) { return await tfrpc.rpc.query( ` @@ -55,11 +62,17 @@ class TfTabNewsFeedElement extends LitElement { } else { return await tfrpc.rpc.query( ` - SELECT messages.* + WITH news AS (SELECT messages.* FROM messages JOIN json_each(?) AS following ON messages.author = following.value WHERE messages.timestamp > ? - ORDER BY messages.timestamp DESC + ORDER BY messages.timestamp DESC) + SELECT messages.* + FROM news + JOIN messages_refs ON news.id = messages_refs.ref + JOIN messages ON messages_refs.message = messages.id + UNION + SELECT * FROM news `, [ JSON.stringify(this.following), @@ -79,6 +92,8 @@ class TfTabNewsFeedElement extends LitElement { this._messages_following = this.following; this.fetch_messages().then(function(messages) { self.messages = messages; + }).catch(function(error) { + alert(JSON.stringify(error, null, 2)); }); } return html``;