- {!!profile.name &&
{profile.name}
}
- {!!profile.name && !!profile.nip05 && (
+ {!!profile?.name &&
{profile.name}
}
+ {!!profile?.name && !!profile.nip05 && (
<>
ยท
{profile.nip05}
@@ -100,7 +100,7 @@ export default function ProfilePage({
)}
- {!!profile.about && (
+ {!!profile?.about && (
{profile.about}
diff --git a/app/_providers/ndk/context/Users.ts b/app/_providers/ndk/context/Users.ts
index 7d2a6e7..4450e8e 100644
--- a/app/_providers/ndk/context/Users.ts
+++ b/app/_providers/ndk/context/Users.ts
@@ -54,8 +54,9 @@ export const Users = (ndk: NDK | undefined) => {
}
function getProfile(id: string) {
- if (users[id]) {
- return users[id].profile!;
+ const user = users[id];
+ if (user) {
+ return user.profile;
} else {
fetchUser(id);
}
diff --git a/app/_providers/ndk/context/index.tsx b/app/_providers/ndk/context/index.tsx
index b900ba4..48bb8be 100644
--- a/app/_providers/ndk/context/index.tsx
+++ b/app/_providers/ndk/context/index.tsx
@@ -56,8 +56,8 @@ interface NDKContext {
}
| undefined,
) => Promise
;
- getUser: (_: string) => NDKUser;
- getProfile: (_: string) => NDKUserProfile;
+ getUser: (_: string) => NDKUser | undefined;
+ getProfile: (_: string) => NDKUserProfile | undefined;
}
const NDKContext = createContext({
diff --git a/app/_providers/ndk/utils/notes.ts b/app/_providers/ndk/utils/notes.ts
index b43d7cc..7b20ef1 100644
--- a/app/_providers/ndk/utils/notes.ts
+++ b/app/_providers/ndk/utils/notes.ts
@@ -46,7 +46,7 @@ export const parseContent = ({
// Convert legacy mentions to bech32 entities
const mentionMatch = text.match(/^#\[(\d+)\]/i);
- if (mentionMatch) {
+ if (mentionMatch && mentionMatch[1]) {
const i = parseInt(mentionMatch[1]);
if (tags[i]) {
diff --git a/bun.lockb b/bun.lockb
index 1d4bd33..cc3693e 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/components/CreatorCard/index.tsx b/components/CreatorCard/index.tsx
index 20ecb43..d0c83c4 100644
--- a/components/CreatorCard/index.tsx
+++ b/components/CreatorCard/index.tsx
@@ -13,7 +13,7 @@ import { BANNER } from "@/constants/app";
import { getNameToShow } from "@/lib/utils";
type CreatorCardProps = {
- profile: NDKUserProfile;
+ profile?: NDKUserProfile;
npub: string;
recentWork: {
id: string;
diff --git a/components/KindCard/1.tsx b/components/KindCard/1.tsx
index b362f95..5764c7f 100644
--- a/components/KindCard/1.tsx
+++ b/components/KindCard/1.tsx
@@ -10,7 +10,7 @@ import { toast } from "sonner";
export default function Kind1(props: Event) {
const { content, pubkey, tags } = props;
- const r = getTagsValues("r", tags);
+ const r = getTagsValues("r", tags).filter(Boolean);
const npub = nip19.npubEncode(pubkey);
return (
diff --git a/components/KindCard/30023.tsx b/components/KindCard/30023.tsx
index 3f65e15..7b839c2 100644
--- a/components/KindCard/30023.tsx
+++ b/components/KindCard/30023.tsx
@@ -8,7 +8,9 @@ import { removeDuplicates } from "@/lib/utils";
export default function Kind30023({ content, pubkey, tags }: Event) {
const title = getTagValues("title", tags);
const summary = getTagValues("summary", tags);
- const contentTags = removeDuplicates(getTagsValues("t", tags));
+ const contentTags = removeDuplicates(getTagsValues("t", tags)).filter(
+ Boolean,
+ );
return (
diff --git a/components/KindCard/components/ProfileHeader.tsx b/components/KindCard/components/ProfileHeader.tsx
index d7b1e1a..bcfcfe4 100644
--- a/components/KindCard/components/ProfileHeader.tsx
+++ b/components/KindCard/components/ProfileHeader.tsx
@@ -14,7 +14,7 @@ export default function ProfileHeader({ pubkey }: ProfileHeaderProps) {
return (
-
+
{getTwoLetters({ npub, profile })}
@@ -23,7 +23,7 @@ export default function ProfileHeader({ pubkey }: ProfileHeaderProps) {
{getNameToShow({ npub, profile })}
- {!!profile.nip05 && }
+ {!!profile?.nip05 && }
);
diff --git a/components/TextRendering/index.tsx b/components/TextRendering/index.tsx
index 427e384..7e54f83 100644
--- a/components/TextRendering/index.tsx
+++ b/components/TextRendering/index.tsx
@@ -50,12 +50,16 @@ const RenderText = ({ text }: { text?: string }) => {
// specialElement =