forked from cory/tildefriends
Make the client figure out followers rather than going back to the database. Faster loads.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3790 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
d0c89991be
commit
ac92b5f8de
@ -1 +1 @@
|
|||||||
{"type":"tildefriends-app","files":{"app.js":"&uXK7Jr1DcwfxabWjUOHVsElPbSyBB35bSrNSElnUlik=.sha256","index.html":"&eY9aBHpnmbMTXXnbzv9gxxXvJp8O5NpcqulQxdnsW/s=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&3dPiSNYjoJE3zn1oTT1SBhbvkW9MHr7ZUDxUJiBI1Ss=.sha256","tf.js":"&qaMkoT5UElfhFNFcDLimlm3asDLaYytsypoz7CJh9q0=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.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","tf-shared.js":"&Vi9pHWY2Dh6+cJlX0lLa4gxrC7VlkeWaU0fQidwzaQ0=.sha256"}}
|
{"type":"tildefriends-app","files":{"app.js":"&MctA7OZPTgdTZnlSwKMJTYjZg+S8blg4VdO/njxN0QU=.sha256","index.html":"&eY9aBHpnmbMTXXnbzv9gxxXvJp8O5NpcqulQxdnsW/s=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&3dPiSNYjoJE3zn1oTT1SBhbvkW9MHr7ZUDxUJiBI1Ss=.sha256","tf.js":"&7hS4IikdZdlZDiMlZ1UK9Wf6rdOwceevKGPBRlhDZ68=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.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","tf-shared.js":"&Vi9pHWY2Dh6+cJlX0lLa4gxrC7VlkeWaU0fQidwzaQ0=.sha256"}}
|
@ -69,15 +69,6 @@ async function followingDeep(db, seed_ids, depth) {
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function followers(db, visible_users, id) {
|
|
||||||
if (g_followers_cache[id]) {
|
|
||||||
return g_followers_cache[id];
|
|
||||||
}
|
|
||||||
var results = visible_users.filter(user => g_following_cache[user] && g_following_cache[user].has(id));
|
|
||||||
g_followers_cache[id] = results;
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getAbout(db, id) {
|
async function getAbout(db, id) {
|
||||||
var o = await db.get(id + ":about");
|
var o = await db.get(id + ":about");
|
||||||
const k_version = 4;
|
const k_version = 4;
|
||||||
@ -354,9 +345,8 @@ async function refresh(selected) {
|
|||||||
var all_posts = [].concat(posts, await getPosts(db, roots));
|
var all_posts = [].concat(posts, await getPosts(db, roots));
|
||||||
await Promise.all(all_posts.map(x => app.postMessage({message: x})));
|
await Promise.all(all_posts.map(x => app.postMessage({message: x})));
|
||||||
await Promise.all(all_followed.map(id => getAbout(db, id).then(results => app.postMessage({user: {user: id, about: results}}))));
|
await Promise.all(all_followed.map(id => getAbout(db, id).then(results => app.postMessage({user: {user: id, about: results}}))));
|
||||||
await Promise.all(all_followed.map(id => getVotes(db, id).then(results => app.postMessage({votes: results}))));
|
await Promise.all(all_followed.map(id => getVotes(db, id).then(results => results.length ? app.postMessage({votes: results}) : null)));
|
||||||
await Promise.all(all_followed.map(id => following(db, id).then(results => app.postMessage({following: {id: id, users: [...results]}}))));
|
await Promise.all(all_followed.map(id => following(db, id).then(results => app.postMessage({following: {id: id, users: [...results]}}))));
|
||||||
await Promise.all(all_followed.map(id => followers(db, all_followed, id).then(results => app.postMessage({followers: {id: id, users: results}}))));
|
|
||||||
await app.postMessage({ready: true});
|
await app.postMessage({ready: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,16 +90,6 @@ function processMessages() {
|
|||||||
if (event.data.user.user == g_data.whoami) {
|
if (event.data.user.user == g_data.whoami) {
|
||||||
updateEditUser();
|
updateEditUser();
|
||||||
}
|
}
|
||||||
} else if (key == 'followers') {
|
|
||||||
if (!g_data.users[event.data.followers.id]) {
|
|
||||||
Vue.set(g_data.users, event.data.followers.id, {});
|
|
||||||
}
|
|
||||||
if (!g_data.users[event.data.followers.id].followers) {
|
|
||||||
Vue.set(g_data.users[event.data.followers.id], 'followers', {});
|
|
||||||
}
|
|
||||||
for (let user of event.data.followers.users) {
|
|
||||||
Vue.set(g_data.users[event.data.followers.id].followers, user, true);
|
|
||||||
}
|
|
||||||
} else if (key == 'following') {
|
} else if (key == 'following') {
|
||||||
if (!g_data.users[event.data.following.id]) {
|
if (!g_data.users[event.data.following.id]) {
|
||||||
Vue.set(g_data.users, event.data.following.id, {});
|
Vue.set(g_data.users, event.data.following.id, {});
|
||||||
@ -109,6 +99,13 @@ function processMessages() {
|
|||||||
}
|
}
|
||||||
for (let user of event.data.following.users) {
|
for (let user of event.data.following.users) {
|
||||||
Vue.set(g_data.users[event.data.following.id].following, user, true);
|
Vue.set(g_data.users[event.data.following.id].following, user, true);
|
||||||
|
if (!g_data.users[user]) {
|
||||||
|
Vue.set(g_data.users, user, {});
|
||||||
|
}
|
||||||
|
if (!g_data.users[user].followers) {
|
||||||
|
Vue.set(g_data.users[user], 'followers', {});
|
||||||
|
}
|
||||||
|
Vue.set(g_data.users[user].followers, event.data.following.id, true);
|
||||||
}
|
}
|
||||||
} else if (key == 'broadcasts') {
|
} else if (key == 'broadcasts') {
|
||||||
g_data.broadcasts = event.data.broadcasts;
|
g_data.broadcasts = event.data.broadcasts;
|
||||||
|
Loading…
Reference in New Issue
Block a user