Page MenuHomePhabricator

D13977.id45901.diff
No OneTemporary

D13977.id45901.diff

diff --git a/lib/utils/fc-cache.js b/lib/utils/fc-cache.js
--- a/lib/utils/fc-cache.js
+++ b/lib/utils/fc-cache.js
@@ -186,6 +186,41 @@
}
const fetchFarcasterChannelPromise = (async () => {
+ // First, we finish any ongoing fetches of followed channels,
+ // since our channel might be one of them
+ const fidsInFollowedChannelQueryCache = [
+ ...this.followedFarcasterChannelsQueryCache.keys(),
+ ];
+ const followedChannelQueryPromises = fidsInFollowedChannelQueryCache
+ .map(fid => {
+ const entry = this.getCachedFollowedFarcasterChannelsEntryForFID(fid);
+ if (!entry) {
+ return null;
+ }
+ const { followedFarcasterChannels } = entry;
+ if (followedFarcasterChannels instanceof Promise) {
+ return followedFarcasterChannels;
+ }
+ return null;
+ })
+ .filter(Boolean);
+ if (followedChannelQueryPromises.length > 0) {
+ const followedChannelQueryResults = await Promise.all(
+ followedChannelQueryPromises,
+ );
+ for (const followedChannelQueryResult of followedChannelQueryResults) {
+ if (!followedChannelQueryResult) {
+ continue;
+ }
+ for (const channel of followedChannelQueryResult) {
+ if (channel.id !== channelID) {
+ continue;
+ }
+ return channel;
+ }
+ }
+ }
+
let farcasterChannel;
try {
farcasterChannel = await Promise.race([
@@ -279,6 +314,20 @@
followedFarcasterChannels,
});
+ if (followedFarcasterChannels) {
+ for (const channel of followedFarcasterChannels) {
+ const channelID = channel.id;
+ if (this.getCachedFarcasterChannelForChannelID(channelID)) {
+ continue;
+ }
+ this.farcasterChannelQueryCache.set(channelID, {
+ channelID,
+ expirationTime: Date.now() + cacheTimeout,
+ farcasterChannel: channel,
+ });
+ }
+ }
+
return followedFarcasterChannels;
})();

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 21, 8:17 AM (6 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2555290
Default Alt Text
D13977.id45901.diff (2 KB)

Event Timeline