From b980bb494690dec71a111bf5c3c0117ac6f2024a Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Fri, 31 Dec 2021 15:12:46 +0000 Subject: [PATCH] Redo sharing apps so that they can be mentioned from regular posts. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3723 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/cory/index.json | 2 +- apps/cory/index/app.js | 9 --------- apps/cory/index/index.html | 6 +++--- apps/cory/index/tf-message.js | 5 ++++- apps/cory/index/tf.js | 28 +++++++++++++++++++--------- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/apps/cory/index.json b/apps/cory/index.json index e24d0182..49ba647d 100644 --- a/apps/cory/index.json +++ b/apps/cory/index.json @@ -1 +1 @@ -{"type":"tildefriends-app","files":{"app.js":"&bbZBdFOrGh6o0X+ypAaRhfAls89Ir/IICcUN3xlO02w=.sha256","index.html":"&zwiRwroNQ1SnCsq97zB8dRiGwY4H+ii4ZtuKR385zdI=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&KmUw2D8yehJU95RQ+8DWP69w/5wK7yWR6fUc5/LIpio=.sha256","tf-message.js":"&KjVh7zASx0TZtZTsS6lJ7T70K9tyXcf+ink4vK7gSWI=.sha256","tf.js":"&u6n7Eqa1ryFuL9AhlYeJ/WzXYh6zxECKVfhG8/ecRM8=.sha256","commonmark.min.js":"&5x6ek3tFrKTZX6hXNNyFsjmhvrjmWpUkwuuaiyVV1Us=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256"}} \ No newline at end of file +{"type":"tildefriends-app","files":{"app.js":"&Y/WR3FLnC1qV+3WGFKEaIZ4nrgKIa/flClu4wUI50R8=.sha256","index.html":"&mQ2fDeVm6D6+pwmF/6K04H1q5saq/Fl6Cq23UKlvJls=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&KmUw2D8yehJU95RQ+8DWP69w/5wK7yWR6fUc5/LIpio=.sha256","tf-message.js":"&c7NMlMBi2UZE7ChUXd3h4ih0q2myuHhp3PpNUfBRvHM=.sha256","tf.js":"&I45p0703bQNAWq/5wFHdVrwM3z+5FL4K8QmDTfSnBAU=.sha256","commonmark.min.js":"&5x6ek3tFrKTZX6hXNNyFsjmhvrjmWpUkwuuaiyVV1Us=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256"}} \ No newline at end of file diff --git a/apps/cory/index/app.js b/apps/cory/index/app.js index ff1ea8b8..b68feaba 100644 --- a/apps/cory/index/app.js +++ b/apps/cory/index/app.js @@ -325,17 +325,8 @@ core.register('message', async function(m) { } else if (m.message) { if (m.message.connect) { await ssb.connect(m.message.connect); - } else if (m.message.post) { - await ssb.post(m.message.post); } else if (m.message.appendMessage) { await ssb.appendMessage(m.message.appendMessage); - } else if (m.message.share_app) { - var app = await ssb.blobGet(m.message.share_app.app); - app = JSON.parse(utf8Decode(app)); - app.type = 'tildefriends-app'; - app.name = m.message.share_app.name; - app.text = m.message.share_app.text; - await ssb.appendMessage(app); } else if (m.message.user) { await sendUser(await database("ssb"), m.message.user); } else if (m.message.refresh) { diff --git a/apps/cory/index/index.html b/apps/cory/index/index.html index edea18fd..a4acc173 100644 --- a/apps/cory/index/index.html +++ b/apps/cory/index/index.html @@ -53,8 +53,8 @@
What's up?
- - {{share_app}}: {{apps[share_app]}} + + {{mentions[link].name}}: {{link}} @@ -65,7 +65,7 @@ Share App - + {{app}} diff --git a/apps/cory/index/tf-message.js b/apps/cory/index/tf-message.js index a0a1d770..bc1cfa3f 100644 --- a/apps/cory/index/tf-message.js +++ b/apps/cory/index/tf-message.js @@ -39,7 +39,10 @@ Vue.component('tf-message', {
- +
diff --git a/apps/cory/index/tf.js b/apps/cory/index/tf.js index e8c8b580..58265676 100644 --- a/apps/cory/index/tf.js +++ b/apps/cory/index/tf.js @@ -11,7 +11,7 @@ var g_data = { pubs: [], votes: {}, apps: {}, - share_app: null, + mentions: {}, unread: 0, }; @@ -117,16 +117,16 @@ window.addEventListener('load', function() { data: g_data, methods: { post_message: function() { - if (g_data.share_app) { - window.parent.postMessage({share_app: { - app: g_data.apps[g_data.share_app], - name: g_data.share_app, - text: document.getElementById('post_text').value, - }}, '*'); - } else { - window.parent.postMessage({post: document.getElementById('post_text').value}, '*'); + var message = { + type: 'post', + text: document.getElementById('post_text').value, + }; + if (Object.keys(g_data.mentions).length) { + message.mentions = Object.values(g_data.mentions); } + window.parent.postMessage({appendMessage: message}, '*'); document.getElementById('post_text').value = ''; + Vue.set(g_data, mentions, {}); }, ssb_connect: function(connection) { window.parent.postMessage({connect: connection}, '*'); @@ -141,6 +141,16 @@ window.addEventListener('load', function() { refresh: function() { window.parent.postMessage({refresh: true}, '*'); }, + add_app_to_mentions: function(app) { + Vue.set(g_data.mentions, g_data.apps[app], { + link: g_data.apps[app], + name: app, + type: 'application/tildefriends', + }); + }, + remove_from_mentions: function(link) { + Vue.delete(g_data.mentions, link); + }, } }); window.parent.postMessage('ready', '*');