Send followers/following information differently so that we load posts faster.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3727 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-01-02 15:36:11 +00:00
parent 3026443c1e
commit 4268963e70
3 changed files with 15 additions and 21 deletions

View File

@ -267,8 +267,7 @@ async function refresh() {
app.postMessage({connections: await ssb.connections()}),
app.postMessage({apps: await core.apps()}),
followingDeep(db, [whoami], 2).then(function(f) {
return Promise.all([
getRecentPostIds(db, whoami, [].concat([whoami], f), k_posts_max).then(async function(ids) {
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) {
@ -284,20 +283,20 @@ async function refresh() {
return [].concat(posts, await getPosts(db, roots));
}).then(function(posts) {
return Promise.all(posts.map(x => app.postMessage({message: x})));
}),
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}});
}),
]);
})),
]);
}).then(function() {
return 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}});
}),
sendUser(db, id),
]);
});
});
}),
sendUser(db, whoami),
]);
}
@ -321,8 +320,6 @@ core.register('message', async function(m) {
await ssb.connect(m.message.connect);
} else if (m.message.appendMessage) {
await ssb.appendMessage(m.message.appendMessage);
} else if (m.message.user) {
await sendUser(await database("ssb"), m.message.user);
} else if (m.message.refresh) {
await refresh();
}

View File

@ -7,9 +7,6 @@ Vue.component('tf-user', {
edit_profile_description: null,
} },
props: ['id'],
mounted: function() {
window.parent.postMessage({user: this.id}, '*');
},
computed: {
following: {
get: function() {