forked from Kieran/snort
proper error handling in profile http cache
This commit is contained in:
parent
bf0af2d14e
commit
0b5dc2d290
@ -12,19 +12,23 @@ export function useUserProfile(pubKey?: HexKey): MetadataCache | undefined {
|
|||||||
if (pubKey) {
|
if (pubKey) {
|
||||||
system.ProfileLoader.TrackMetadata(pubKey);
|
system.ProfileLoader.TrackMetadata(pubKey);
|
||||||
if (process.env.HTTP_CACHE && !system.ProfileLoader.Cache.getFromCache(pubKey)) {
|
if (process.env.HTTP_CACHE && !system.ProfileLoader.Cache.getFromCache(pubKey)) {
|
||||||
try {
|
fetch(`${process.env.HTTP_CACHE}/profile/${pubKey}`)
|
||||||
fetch(`${process.env.HTTP_CACHE}/profile/${pubKey}`).then(async r => {
|
.then(async r => {
|
||||||
if (r.ok) {
|
if (r.ok) {
|
||||||
|
try {
|
||||||
const data = await r.json();
|
const data = await r.json();
|
||||||
if (data) {
|
if (data) {
|
||||||
system.ProfileLoader.onProfileEvent(data);
|
system.ProfileLoader.onProfileEvent(data);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
console.error(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const release = system.ProfileLoader.Cache.hook(h, pubKey);
|
const release = system.ProfileLoader.Cache.hook(h, pubKey);
|
||||||
return () => {
|
return () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user