Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32153565
D13977.1765034870.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D13977.1765034870.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
Sat, Dec 6, 3:27 PM (17 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5832919
Default Alt Text
D13977.1765034870.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