add timeout to getExtendedFollows

This commit is contained in:
Martti Malmi 2021-07-28 09:46:02 +03:00
parent b1656419ce
commit a608a4ae65

View File

@ -60,12 +60,16 @@ function getExtendedFollows(callback, k, maxDepth = 3, currentDepth = 1) {
addFollow(k, currentDepth - 1); addFollow(k, currentDepth - 1);
let n = 0;
State.public.user(k).get('follow').map().on((isFollowing, followedKey) => { // TODO: unfollow State.public.user(k).get('follow').map().on((isFollowing, followedKey) => { // TODO: unfollow
if (follows[followedKey] === isFollowing) { return; } if (follows[followedKey] === isFollowing) { return; }
if (isFollowing) { if (isFollowing) {
n = n + 1;
addFollow(followedKey, currentDepth, k); addFollow(followedKey, currentDepth, k);
if (currentDepth < maxDepth) { if (currentDepth < maxDepth) {
getExtendedFollows(callback, followedKey, maxDepth, currentDepth + 1); setTimeout(() => {
getExtendedFollows(callback, followedKey, maxDepth, currentDepth + 1);
}, n * 100);
} }
} else { } else {
removeFollow(followedKey, currentDepth, k); removeFollow(followedKey, currentDepth, k);