From 92c06b34a9cb0e194e8425b8784328aea3ba0f2a Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Tue, 12 Jan 2021 02:23:57 +0000 Subject: [PATCH] A few minor things. Fixed missing fields from app messages. Fixed some missing messages. Removed unnecessary asyncs. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3637 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/cory/index.json | 2 +- apps/cory/index/app.js | 17 +++--- apps/cory/index/index.html | 107 +++++++++++++++++++------------------ 3 files changed, 66 insertions(+), 60 deletions(-) diff --git a/apps/cory/index.json b/apps/cory/index.json index c1e723f25..16df43f7a 100644 --- a/apps/cory/index.json +++ b/apps/cory/index.json @@ -1 +1 @@ -{"type":"tildefriends-app","files":{"app.js":"&WiH+BcLge0Imgpcfo/lecF92raEkf2cLyxr+GQKM5DU=.sha256","index.html":"&z528csPu5+I+634DKxY3EBOQYAAVt1hLOQiWj+gW+qM=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256"}} \ No newline at end of file +{"type":"tildefriends-app","files":{"app.js":"&QC3jbGKlu7N1D7w6L64MUuT0EWf0MSew1gEg4LbaFcM=.sha256","index.html":"&eqLI+5Abbs4OEjIO7neOQFjhm/iknp6gi96RD2VTAR0=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256"}} \ No newline at end of file diff --git a/apps/cory/index/app.js b/apps/cory/index/app.js index 7e478c9ca..51ebe078e 100644 --- a/apps/cory/index/app.js +++ b/apps/cory/index/app.js @@ -5,7 +5,7 @@ const k_votes_max = 100; async function following(db, id) { var o = await db.get(id + ":following"); - const k_version = 4; + const k_version = 5; var f = o ? JSON.parse(o) : o; if (!f || f.version != k_version) { f = {users: [], sequence: 0, version: k_version}; @@ -24,7 +24,7 @@ async function following(db, id) { "UNION SELECT MAX(sequence) AS sequence, NULL, NULL FROM messages WHERE author = ?1 "+ "ORDER BY sequence", [id, f.sequence], - async function(row) { + function(row) { if (row.following) { f.users.add(row.contact); } else { @@ -53,7 +53,7 @@ async function followingDeep(db, seed_ids, depth) { async function followers(db, id) { var o = await db.get(id + ":followers"); - const k_version = 2; + const k_version = 3; var f = o ? JSON.parse(o) : o; if (!f || f.version != k_version) { f = {users: [], rowid: 0, version: k_version}; @@ -72,7 +72,7 @@ async function followers(db, id) { "UNION SELECT MAX(rowid) as rowid, NULL, NULL FROM messages "+ "ORDER BY rowid", [f.rowid, id], - async function(row) { + function(row) { if (row.following) { f.users.add(row.contact); } else { @@ -101,7 +101,7 @@ async function sendUser(db, id) { async function pubsByUser(db, id) { var o = await db.get(id + ":pubs"); - const k_version = 2; + const k_version = 3; var f = o ? JSON.parse(o) : o; if (!f || f.version != k_version) { f = {pubs: [], sequence: 0, version: k_version}; @@ -121,7 +121,7 @@ async function pubsByUser(db, id) { "UNION SELECT MAX(sequence) as sequence, NULL, NULL, NULL FROM messages WHERE author = ?2 "+ "ORDER BY sequence", [f.sequence, id], - async function(row) { + function(row) { f.sequence = row.sequence; if (row.host) { row = {host: row.host, port: row.port, key: row.key}; @@ -237,7 +237,7 @@ async function getRecentPostIds(db, id, ids, limit) { async function getVotes(db, id) { var o = await db.get(id + ":votes"); - const k_version = 2; + const k_version = 3; var votes = []; var f = o ? JSON.parse(o) : o; if (!f || f.version != k_version) { @@ -259,7 +259,7 @@ async function getVotes(db, id) { "UNION SELECT MAX(rowid) as rowid, NULL, NULL AS id, NULL, NULL, NULL FROM messages "+ "ORDER BY rowid DESC LIMIT ?", [f.rowid, id, k_votes_max], - async function(row) { + function(row) { if (row.id) { votes.push(row); } else { @@ -363,6 +363,7 @@ core.register('message', async function(m) { 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); diff --git a/apps/cory/index/index.html b/apps/cory/index/index.html index 1ad2fc49f..70a3eea58 100644 --- a/apps/cory/index/index.html +++ b/apps/cory/index/index.html @@ -84,29 +84,29 @@ }, template: ` {{users[id] && users[id].name ? users[id].name : id}} - {{id}} - - {{users[id] && users[id].name ? users[id].name : id}} - -
-
{{id}}
-
{{users[id].description}}
-
Following
- - Followers - - - - Following - - - + {{id}} + + {{users[id] && users[id].name ? users[id].name : id}} + +
+
{{id}}
+
{{users[id].description}}
+
Following
+ + Followers + + + + Following + + + -
- - Close - -
+
+ + Close + +
`, }); Vue.component('tf-message', { @@ -162,36 +162,40 @@ }, template: ` -

- -

-
{{new Date(message.timestamp)}}
-
- -more_vert - -View Raw -View Message +

+ +

+
{{new Date(message.timestamp)}}
+
+ + more_vert + + View Raw + View Message - -
- +
+
+
-
{{message.content}}
-
-
-
- -
-
{{content_json.following ? '==>' : '=/=>'}}
-
{{message.content}}
-
- - -{{vote + (votes[vote].length > 1 ? ' (' + votes[vote].length + ')' : '')}} - -
-
`, +
{{message.content}}
+
+
+
+ +
+
+
+ {{content_json.name || 'tildefriends-app'}} +
+
{{content_json.following ? '==>' : '=/=>'}}
+
{{message.content}}
+
+ + + {{vote + (votes[vote].length > 1 ? ' (' + votes[vote].length + ')' : '')}} + + +`, }); function markdown(d) { return d; } Vue.config.performance = true; @@ -203,6 +207,7 @@ 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 { @@ -296,7 +301,7 @@ Submit Post - +