mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-10 06:43:00 +00:00
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:
1 parent
c539fef553
commit
aae2ea7d16
3 files changed
+83
-4
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user