|
@@ -72,24 +72,27 @@ export class FeedProvider {
|
|
|
// Fetch user's friends
|
|
|
const friends = await this.getCachedFriends(this.userId);
|
|
|
|
|
|
- let privateTweetHashs = [];
|
|
|
- friends.forEach(async friend => {
|
|
|
- privateTweetHashs = privateTweetHashs.concat(
|
|
|
- await this.gun.fetchPrivateTweetHashsForUserInInterval(
|
|
|
- friend.id_str,
|
|
|
+ // Extract friends user ids and add own user id
|
|
|
+ const friendsAndUserIds = friends
|
|
|
+ .map(friend => friend.id_str)
|
|
|
+ .concat([this.userId]);
|
|
|
+
|
|
|
+ // Fetch ipfs hashs for period
|
|
|
+ const promises = [];
|
|
|
+ friendsAndUserIds.forEach(async accountId => {
|
|
|
+ promises.push(
|
|
|
+ this.gun.fetchPrivateTweetHashsForUserInInterval(
|
|
|
+ accountId,
|
|
|
intervalStart,
|
|
|
intervalEnd
|
|
|
)
|
|
|
);
|
|
|
});
|
|
|
|
|
|
- // Add users private tweets
|
|
|
- privateTweetHashs = privateTweetHashs.concat(
|
|
|
- await this.gun.fetchPrivateTweetHashsForUserInInterval(
|
|
|
- this.userId,
|
|
|
- intervalStart,
|
|
|
- intervalEnd
|
|
|
- )
|
|
|
+ const resolvedPromises = await Promise.all(promises);
|
|
|
+ const privateTweetHashs = resolvedPromises.reduce(
|
|
|
+ (el, privateTweets) => privateTweets.concat(el),
|
|
|
+ []
|
|
|
);
|
|
|
|
|
|
if (privateTweetHashs.length) {
|