+ re:
+ {(mentions?.length ?? 0) > 0 ? (
+ <>
+ {pubMentions} {others}
+ >
+ ) : (
+ replyLink && {replyLink.encode().substring(0, 12)}
+ )}
+
+ );
+ }
+
+ const canRenderAsTextNote = [EventKind.TextNote, EventKind.Polls, EventKind.LongFormTextNote];
+ if (!canRenderAsTextNote.includes(ev.kind)) {
+ const alt = findTag(ev, "alt");
+ if (alt) {
+ return (
+
-
{name.trim()}
+ {overrideUsername ? overrideUsername :
}
{nip05 &&
}
{subHeader}
@@ -113,13 +110,3 @@ export default function ProfileImage({
);
}
}
-
-export function getDisplayName(user: UserMetadata | undefined, pubkey: HexKey) {
- let name = hexToBech32(NostrPrefix.PublicKey, pubkey).substring(0, 12);
- if (typeof user?.display_name === "string" && user.display_name.length > 0) {
- name = user.display_name;
- } else if (typeof user?.name === "string" && user.name.length > 0) {
- name = user.name;
- }
- return name;
-}
diff --git a/packages/app/src/Notifications.ts b/packages/app/src/Notifications.ts
index 4da9df5a..814d55af 100644
--- a/packages/app/src/Notifications.ts
+++ b/packages/app/src/Notifications.ts
@@ -1,5 +1,5 @@
import { TaggedNostrEvent, EventKind, MetadataCache } from "@snort/system";
-import { getDisplayName } from "Element/User/ProfileImage";
+import { getDisplayName } from "Element/User/DisplayName";
import { MentionRegex } from "Const";
import { defaultAvatar, tagFilterOfTextRepost, unwrap } from "SnortUtils";
import { UserCache } from "Cache";
diff --git a/packages/app/src/Pages/FreeNostrAddressPage.tsx b/packages/app/src/Pages/FreeNostrAddressPage.tsx
index a3d5ca24..664180f7 100644
--- a/packages/app/src/Pages/FreeNostrAddressPage.tsx
+++ b/packages/app/src/Pages/FreeNostrAddressPage.tsx
@@ -1,12 +1,7 @@
import FormattedMessage from "@snort/app/src/Element/FormattedMessage";
-/*
-import { IrisHost } from "Const";
-import Nip5Service from "Element/Nip5Service";
- */
-
import messages from "./messages";
-import IrisAccount from "../Element/IrisAccount/IrisAccount";
+import IrisAccount from "Element/IrisAccount/IrisAccount";
export default function FreeNostrAddressPage() {
return (
diff --git a/packages/app/src/Pages/MessagesPage.tsx b/packages/app/src/Pages/MessagesPage.tsx
index e3c69585..35a09d3c 100644
--- a/packages/app/src/Pages/MessagesPage.tsx
+++ b/packages/app/src/Pages/MessagesPage.tsx
@@ -7,7 +7,7 @@ import { NostrLink, NostrPrefix, TLVEntryType, UserMetadata, decodeTLV } from "@
import { useUserProfile, useUserSearch } from "@snort/system-react";
import UnreadCount from "Element/UnreadCount";
-import ProfileImage, { getDisplayName } from "Element/User/ProfileImage";
+import ProfileImage from "Element/User/ProfileImage";
import { appendDedupe, debounce, parseId } from "SnortUtils";
import NoteToSelf from "Element/User/NoteToSelf";
import useModeration from "Hooks/useModeration";
@@ -25,6 +25,7 @@ import { useEventFeed } from "Feed/EventFeed";
import { LoginSession, LoginStore } from "Login";
import { Nip28ChatSystem } from "chat/nip28";
import { ChatParticipantProfile } from "Element/Chat/ChatParticipant";
+import { getDisplayName } from "Element/User/DisplayName";
const TwoCol = 768;
const ThreeCol = 1500;
diff --git a/packages/app/src/Pages/Notifications.tsx b/packages/app/src/Pages/Notifications.tsx
index 3e0325a5..a3784007 100644
--- a/packages/app/src/Pages/Notifications.tsx
+++ b/packages/app/src/Pages/Notifications.tsx
@@ -12,13 +12,14 @@ import { markNotificationsRead } from "Login";
import { Notifications, UserCache } from "Cache";
import { dedupe, findTag, orderDescending } from "SnortUtils";
import Icon from "Icons/Icon";
-import ProfileImage, { getDisplayName } from "Element/User/ProfileImage";
+import ProfileImage from "Element/User/ProfileImage";
import useModeration from "Hooks/useModeration";
import { useEventFeed } from "Feed/EventFeed";
import Text from "Element/Text";
import { formatShort } from "Number";
import { LiveEvent } from "Element/LiveEvent";
import ProfilePreview from "Element/User/ProfilePreview";
+import { getDisplayName } from "Element/User/DisplayName";
function notificationContext(ev: TaggedNostrEvent) {
switch (ev.kind) {
diff --git a/packages/app/src/Pages/ProfilePage.tsx b/packages/app/src/Pages/ProfilePage.tsx
index d1c8d066..5c2501ad 100644
--- a/packages/app/src/Pages/ProfilePage.tsx
+++ b/packages/app/src/Pages/ProfilePage.tsx
@@ -58,7 +58,7 @@ import { ZapTarget } from "Zapper";
import { useStatusFeed } from "Feed/StatusFeed";
import messages from "./messages";
-import { SpotlightMediaModal } from "../Element/Deck/SpotlightMedia";
+import { SpotlightMediaModal } from "Element/Deck/SpotlightMedia";
const NOTES = 0;
const REACTIONS = 1;
diff --git a/packages/app/src/ZapPoolController.ts b/packages/app/src/ZapPoolController.ts
index 99a290d4..6667e76e 100644
--- a/packages/app/src/ZapPoolController.ts
+++ b/packages/app/src/ZapPoolController.ts
@@ -1,5 +1,5 @@
import { UserCache } from "Cache";
-import { getDisplayName } from "Element/User/ProfileImage";
+import { getDisplayName } from "Element/User/DisplayName";
import { LNURL, ExternalStore, unixNow } from "@snort/shared";
import { Toastore } from "Toaster";
import { LNWallet, WalletInvoiceState, Wallets } from "Wallet";
diff --git a/packages/app/webpack.config.js b/packages/app/webpack.config.js
index ab9ec892..aa115b0b 100644
--- a/packages/app/webpack.config.js
+++ b/packages/app/webpack.config.js
@@ -90,6 +90,8 @@ 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")),
+ "process.env.ANIMAL_NAME_PLACEHOLDERS": JSON.stringify(appConfig.get("animalNamePlaceholders")),
}),
],
module: {
diff --git a/packages/system-react/src/useUserProfile.ts b/packages/system-react/src/useUserProfile.ts
index 5d718761..d6b12585 100644
--- a/packages/system-react/src/useUserProfile.ts
+++ b/packages/system-react/src/useUserProfile.ts
@@ -11,6 +11,24 @@ export function useUserProfile(pubKey?: HexKey): MetadataCache | undefined {
h => {
if (pubKey) {
system.ProfileLoader.TrackMetadata(pubKey);
+ if (process.env.HTTP_CACHE && !system.ProfileLoader.Cache.getFromCache(pubKey)) {
+ fetch(`${process.env.HTTP_CACHE}/profile/${pubKey}`)
+ .then(async r => {
+ if (r.ok) {
+ try {
+ const data = await r.json();
+ if (data) {
+ system.ProfileLoader.onProfileEvent(data);
+ }
+ } catch (e) {
+ console.error(e);
+ }
+ }
+ })
+ .catch(e => {
+ console.error(e);
+ });
+ }
}
const release = system.ProfileLoader.Cache.hook(h, pubKey);
return () => {