Thread viewer for Bluesky

load getLikes in batches of 10

Changed files
+14 -4
+14 -4
like_stats_page.js
··· 86 let myPosts = await this.appView.loadUserTimeline(accountAPI.user.did, requestedDays); 87 let likedPosts = myPosts.filter(x => !x['reason'] && x['post']['likeCount'] > 0); 88 89 - let fetchPostLikes = likedPosts.map(x => { 90 - return this.appView.fetchAll('app.bsky.feed.getLikes', { uri: x['post']['uri'], limit: 100 }, { field: 'likes' }); 91 - }); 92 93 - let results = await Promise.all(fetchPostLikes); 94 return results.flat(); 95 } 96
··· 86 let myPosts = await this.appView.loadUserTimeline(accountAPI.user.did, requestedDays); 87 let likedPosts = myPosts.filter(x => !x['reason'] && x['post']['likeCount'] > 0); 88 89 + let results = []; 90 + 91 + for (let i = 0; i < likedPosts.length; i += 10) { 92 + let batch = likedPosts.slice(i, i + 10); 93 94 + let fetchBatch = batch.map(x => { 95 + return this.appView.fetchAll('app.bsky.feed.getLikes', { uri: x['post']['uri'], limit: 100 }, { 96 + field: 'likes' 97 + }); 98 + }); 99 + 100 + let batchResults = await Promise.all(fetchBatch); 101 + results = results.concat(batchResults); 102 + } 103 + 104 return results.flat(); 105 } 106