From 700d09c730ed914dcacf4c6884bc39d617f52d71 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 8 Jan 2022 20:54:02 +0000 Subject: [PATCH] Redid lots of things about viewing an invidual user's feed, their profile, and following users. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3740 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/cory/index.json | 2 +- apps/cory/index/app.js | 12 +++-- apps/cory/index/index.html | 56 +++++++++++++++++++++-- apps/cory/index/tf-message.js | 5 +- apps/cory/index/tf-user.js | 86 ++--------------------------------- apps/cory/index/tf.js | 46 ++++++++++++++++++- 6 files changed, 115 insertions(+), 92 deletions(-) diff --git a/apps/cory/index.json b/apps/cory/index.json index 4ffa7bcf..5491dfda 100644 --- a/apps/cory/index.json +++ b/apps/cory/index.json @@ -1 +1 @@ -{"type":"tildefriends-app","files":{"app.js":"&KdIfXHcm7xE6iBlJWoW8DixHbIPs+YPevJL+rF8eW4s=.sha256","index.html":"&ayK1muTik0h4UYNvT0QNm0WrygVrL8kxBoEyrQkHyHs=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&fXhPpneuYuseoaYk25ODN3QecFAeOfuMOZd98OgvjsQ=.sha256","tf-message.js":"&oQggZN26PtRi4Ce9HY8TKVJ9jRrYWLRE5tN+3yHwEJE=.sha256","tf.js":"&EgrrFfINhqFL/Kj8qkJwH/DHTLrZ8CxhHDBxZjcyjUY=.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":"&SJrK87ZgHkxZQDB1nm/Xej/bzajzWpiY9a384zqZVzE=.sha256","index.html":"&O8+Vr4YHP8NIORZzM3Ee9tyLXr2xCETT2Eva0rO5ebA=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&ox9wj2+P3BhqokfHPI3ZMpSYNpNhl91K5R6Z4GbWxCA=.sha256","tf.js":"&rUCI1QKOoyWcFegV72DfG/P7HykmkX4DcvWV87hCeBM=.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 5accf56e..5f6b1597 100644 --- a/apps/cory/index/app.js +++ b/apps/cory/index/app.js @@ -3,6 +3,7 @@ const k_posts_max = 20; const k_votes_max = 20; +var g_ready = false; var g_selected = null; var g_following_cache = {}; @@ -240,6 +241,7 @@ async function getPosts(db, ids) { } async function ready() { + g_ready = true; return refresh(g_selected); } @@ -267,6 +269,7 @@ async function refresh(selected) { } await Promise.all([ app.postMessage({whoami: whoami}), + app.postMessage({hash: selected && selected.length == 1 ? selected[0] : null}), ssb.getBroadcasts().then(broadcasts => app.postMessage({broadcasts: broadcasts})), ssb.connections().then(connections => app.postMessage({connections: connections})), core.apps().then(apps => app.postMessage({apps: apps})), @@ -293,6 +296,7 @@ async function refresh(selected) { ]; }))), ]); + await app.postMessage({ready: true}); } ssb.addEventListener('message', async function(id) { @@ -308,7 +312,6 @@ ssb.addEventListener('message', async function(id) { }); core.register('message', async function(m) { - print(JSON.stringify(m)); if (m.message == 'ready') { await ready(); } else if (m.message) { @@ -321,9 +324,12 @@ core.register('message', async function(m) { } } else if (m.event == 'hashChange') { if (m.hash.length > 1) { - refresh([m.hash.substring(1)]); + g_selected = [m.hash.substring(1)]; } else { - refresh(); + g_selected = null; + } + if (g_ready) { + await refresh(g_selected); } } else if (m.event == 'focus' || m.event == 'blur') { /* Shh. */ diff --git a/apps/cory/index/index.html b/apps/cory/index/index.html index 23c89748..e0f7bca7 100644 --- a/apps/cory/index/index.html +++ b/apps/cory/index/index.html @@ -7,10 +7,10 @@ + -
@@ -38,8 +38,6 @@ Connections Connect - Users - @@ -74,6 +72,58 @@ Submit Post + + + home Home + + + + + +
{{users[selected] && users[selected].name ? users[selected].name : selected}}
+
{{selected}}
+
+ +
+
+
+ +
+ + + + + + + + +
+ + + + {{Object.keys(users[selected].followers).length}} followers + + + + + + {{Object.keys(users[selected].following).length}} following + + + + + + Save Profile + +
+
+