From 3eabe72299ea164baad85838020e0b220d6c4a09 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Mon, 3 Jan 2022 01:44:14 +0000 Subject: [PATCH] Slightly simplifying refresh(). git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3732 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/cory/index.json | 2 +- apps/cory/index/app.js | 61 ++++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/apps/cory/index.json b/apps/cory/index.json index 45fad757..b7d3e153 100644 --- a/apps/cory/index.json +++ b/apps/cory/index.json @@ -1 +1 @@ -{"type":"tildefriends-app","files":{"app.js":"&kDS3+lAYQ3lTn9BExKQnXooSEb8AEFKv0r3ioKx6N7Y=.sha256","index.html":"&dyJyLJJqx+qcGXY9CYLY6Jxj/T/ZK+Z8ARa8MhLVhJI=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&EuejzX/iNHsGkscTHJHeJ8YXukGb31KE8YGUMonXJB0=.sha256","tf-message.js":"&oQggZN26PtRi4Ce9HY8TKVJ9jRrYWLRE5tN+3yHwEJE=.sha256","tf.js":"&xNEPeISBMcsMcE7o1XFrj5JT5z+UMEGPajLQYZYfh2k=.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":"&og7bNeqxTfUqVTdtPsrJTjirJxyE3xDQYp0Pj7KmL2U=.sha256","index.html":"&dyJyLJJqx+qcGXY9CYLY6Jxj/T/ZK+Z8ARa8MhLVhJI=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&EuejzX/iNHsGkscTHJHeJ8YXukGb31KE8YGUMonXJB0=.sha256","tf-message.js":"&oQggZN26PtRi4Ce9HY8TKVJ9jRrYWLRE5tN+3yHwEJE=.sha256","tf.js":"&xNEPeISBMcsMcE7o1XFrj5JT5z+UMEGPajLQYZYfh2k=.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 48a3a315..73c64185 100644 --- a/apps/cory/index/app.js +++ b/apps/cory/index/app.js @@ -257,39 +257,36 @@ async function refresh() { app.postMessage({apps: await core.apps()}), followingDeep(db, [whoami], 2).then(function(f) { return getRecentPostIds(db, whoami, [].concat([whoami], f), k_posts_max).then(async function(ids) { - return getPosts(db, ids); - }).then(async function(posts) { - var roots = posts.map(function(x) { - try { - return JSON.parse(x.content).root; - } catch { - return null; - } - }); - roots = roots.filter(function(root) { - return root && posts.every(post => post.id != root); - }); - return [].concat(posts, await getPosts(db, roots)); - }).then(function(posts) { - return Promise.all(posts.map(x => app.postMessage({message: x}))); - }).then(function() { - return Promise.all(f.map(function(id) { - return Promise.all([ - getVotes(db, id).then(function(votes) { - return app.postMessage({votes: votes}); - }), - getAbout(db, id).then(function(user) { - return app.postMessage({user: {user: id, about: user}}); - }), - following(db, id).then(function(following) { - return app.postMessage({following: {id: id, users: following}}); - }), - followers(db, id).then(function(followers) { - return app.postMessage({followers: {id: id, users: followers}}); - }), - ]); - })); + var posts = await getPosts(db, ids); + var roots = posts.map(function(x) { + try { + return JSON.parse(x.content).root; + } catch { + return null; + } }); + roots = roots.filter(function(root) { + return root && posts.every(post => post.id != root); + }); + var all_posts = [].concat(posts, await getPosts(db, roots)); + await Promise.all(all_posts.map(x => app.postMessage({message: x}))); + return Promise.all([].concat(f.map(function(id) { + return [ + getVotes(db, id).then(function(votes) { + return app.postMessage({votes: votes}); + }), + getAbout(db, id).then(function(user) { + return app.postMessage({user: {user: id, about: user}}); + }), + following(db, id).then(function(following) { + return app.postMessage({following: {id: id, users: following}}); + }), + followers(db, id).then(function(followers) { + return app.postMessage({followers: {id: id, users: followers}}); + }), + ]; + }))); + }); }), ]); }