Minor refresh cleanup.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3738 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-01-08 00:08:01 +00:00
parent ae84f69025
commit 1cf55d7d64
2 changed files with 8 additions and 17 deletions

View File

@ -61,7 +61,7 @@ async function followingDeep(db, seed_ids, depth) {
var f = await Promise.all(seed_ids.map(x => following(db, x)));
var ids = [].concat(...f);
var x = await followingDeep(db, [...new Set(ids)].sort(), depth - 1);
x = [].concat(...x, ...seed_ids);
x = [...new Set([].concat(...x, ...seed_ids))].sort();
g_following_deep_cache[key] = x;
return x;
}
@ -279,26 +279,17 @@ async function refresh(selected) {
return null;
}
});
roots = roots.filter(function(root) {
return root && posts.every(post => post.id != root);
});
var have = posts.map(x => x.id);
roots = [...new Set(roots)].filter(x => x && !have[x]);
var all_posts = [].concat(posts, await getPosts(db, roots));
return Promise.all(all_posts.map(x => app.postMessage({message: x})));
}),
Promise.all([].concat(all_followed.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}});
}),
getVotes(db, id).then(votes => app.postMessage({votes: votes})),
getAbout(db, id).then(user => app.postMessage({user: {user: id, about: user}})),
following(db, id).then(f => app.postMessage({following: {id: id, users: f}})),
followers(db, id).then(f => app.postMessage({followers: {id: id, users: f}})),
];
}))),
]);