diff --git a/packages/app/config/default.json b/packages/app/config/default.json index 7dcaecae..4f79e44f 100644 --- a/packages/app/config/default.json +++ b/packages/app/config/default.json @@ -4,5 +4,6 @@ "appTitle": "Snort - Nostr", "nip05Domain": "snort.social", "favicon": "public/favicon.ico", - "appleTouchIconUrl": "/nostrich_512.png" + "appleTouchIconUrl": "/nostrich_512.png", + "httpCache": "" } diff --git a/packages/app/config/iris.json b/packages/app/config/iris.json index 10b7f5be..b1e4ecdb 100644 --- a/packages/app/config/iris.json +++ b/packages/app/config/iris.json @@ -4,5 +4,6 @@ "appTitle": "iris", "nip05Domain": "iris.to", "favicon": "public/iris/favicon.ico", - "appleTouchIconUrl": "/img/apple-touch-icon.png" + "appleTouchIconUrl": "/img/apple-touch-icon.png", + "httpCache": "https://api.iris.to" } diff --git a/packages/app/src/Element/Modal.tsx b/packages/app/src/Element/Modal.tsx index 7415caef..f0c6c57f 100644 --- a/packages/app/src/Element/Modal.tsx +++ b/packages/app/src/Element/Modal.tsx @@ -29,10 +29,13 @@ export default function Modal(props: ModalProps) { return (
-
{ - e.stopPropagation(); - props.onClick?.(e); - }}>{props.children}
+
{ + e.stopPropagation(); + props.onClick?.(e); + }}> + {props.children} +
); diff --git a/packages/app/webpack.config.js b/packages/app/webpack.config.js index ab9ec892..98b72204 100644 --- a/packages/app/webpack.config.js +++ b/packages/app/webpack.config.js @@ -90,6 +90,7 @@ const config = { "process.env.APP_NAME": JSON.stringify(appConfig.get("appName")), "process.env.APP_NAME_CAPITALIZED": JSON.stringify(appConfig.get("appNameCapitalized")), "process.env.NIP05_DOMAIN": JSON.stringify(appConfig.get("nip05Domain")), + "process.env.HTTP_CACHE": JSON.stringify(appConfig.get("httpCache")), }), ], module: { diff --git a/packages/system-react/src/useUserProfile.ts b/packages/system-react/src/useUserProfile.ts index 5d718761..a06c0575 100644 --- a/packages/system-react/src/useUserProfile.ts +++ b/packages/system-react/src/useUserProfile.ts @@ -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 () => {