perf: use batch fetch for profile refresh

Replaces the sequential loop in `forceRefreshAllProfiles` with `batchFetchProfiles` to reduce network requests.
Updates `batchFetchProfilesFromRelays` to support `forceRefresh`, ensuring fresh data is requested while maintaining optimistic UI updates.
Adds unit tests for `forceRefresh` behavior.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-07 23:15:13 +00:00
1 parent c539fef553
commit aae2ea7d16
3 files changed
+83 -4

No files matched your search

+4
View File
@@ -10,6 +10,7 @@ const DEFAULT_PROFILE_IMAGE = "assets/svg/default-profile.svg";
export async function batchFetchProfilesFromRelays({
authorSet,
forceRefresh = false,
getProfileCacheEntry,
setProfileCacheEntry,
updateProfileInDOM,
@@ -50,6 +51,9 @@ export async function batchFetchProfilesFromRelays({
const cacheEntry = getProfileCacheEntry(normalizedPubkey);
if (cacheEntry) {
updateProfileInDOM(normalizedPubkey, cacheEntry.profile);
if (forceRefresh) {
toFetch.push(normalizedPubkey);
}
} else {
toFetch.push(normalizedPubkey);
}