Keep follow sync trickling

This commit is contained in:
2026-04-08 16:28:14 +05:30
parent 5cce03d2ec
commit 3929ca5eb5
+22 -15
View File
@@ -252,25 +252,29 @@ const syncUserData = () => {
loadFeedsForPubkey(pubkey)
}
const syncFollowList = () => {
const syncFollowList = async (signal: AbortSignal) => {
for (const pubkeys of chunk(10, get(bootstrapPubkeys))) {
void (async () => {
// This isn't urgent, avoid clogging other stuff up
await sleep(1000)
if (signal.aborted) return
await Promise.all(
pubkeys.flatMap(pk => [
loadRelayList(pk),
loadGroupList(pk),
loadProfile(pk),
loadFollowList(pk),
loadMuteList(pk),
]),
)
})()
// This isn't urgent, avoid clogging other stuff up
await sleep(1000)
if (signal.aborted) return
await Promise.all(
pubkeys.flatMap(pk => [
loadRelayList(pk),
loadGroupList(pk),
loadProfile(pk),
loadFollowList(pk),
loadMuteList(pk),
]),
)
}
}
let bootstrapFollowController = new AbortController()
const unsubscribeGroupList = merged([userGroupList]).subscribe(([$userGroupList]) => {
syncGroupList($userGroupList)
})
@@ -280,10 +284,13 @@ const syncUserData = () => {
})
const unsubscribeFollows = merged([userFollowList]).subscribe(() => {
syncFollowList()
bootstrapFollowController.abort()
bootstrapFollowController = new AbortController()
void syncFollowList(bootstrapFollowController.signal)
})
return () => {
bootstrapFollowController.abort()
unsubscribersByKey.forEach(call)
unsubscribeGroupList()
unsubscribeRelayList()