Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3327103
D13977.id45901.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13977.id45901.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D13977: [lib] Wait to finish all followed channels queries before querying for a specific one
Attached
Detach File
Event Timeline
Log In to Comment