get uncached profiles from process.env.HTTP_CACHE

This commit is contained in:
Martti Malmi
2023-10-06 08:12:03 +03:00
parent 234167b749
commit 58ba714d36
5 changed files with 26 additions and 6 deletions

View File

@ -11,6 +11,20 @@ export function useUserProfile(pubKey?: HexKey): MetadataCache | undefined {
h => {
if (pubKey) {
system.ProfileLoader.TrackMetadata(pubKey);
if (process.env.HTTP_CACHE && !system.ProfileLoader.Cache.getFromCache(pubKey)) {
try {
fetch(`${process.env.HTTP_CACHE}/profile/${pubKey}`).then(async r => {
if (r.ok) {
const data = await r.json();
if (data) {
system.ProfileLoader.onProfileEvent(data);
}
}
});
} catch (e) {
console.error(e);
}
}
}
const release = system.ProfileLoader.Cache.hook(h, pubKey);
return () => {