fix: context issue in production (#187)

This commit is contained in:
雨宮蓮
2024-05-13 15:18:23 +07:00
committed by GitHub
parent 135d0918b3
commit cf70b0f882
73 changed files with 671 additions and 949 deletions

View File

@@ -0,0 +1,24 @@
import { useProfile } from "@lume/ark";
import { displayNpub } from "@lume/utils";
import { useRouteContext } from "@tanstack/react-router";
export function MentionUser({ pubkey }: { pubkey: string }) {
const { ark } = useRouteContext({ strict: false });
const { isLoading, isError, profile } = useProfile(pubkey);
return (
<button
type="button"
onClick={() => ark.open_profile(pubkey)}
className="break-words text-start text-blue-500 hover:text-blue-600"
>
{isLoading
? "@anon"
: isError
? displayNpub(pubkey, 16)
: `@${
profile?.name || profile?.display_name || profile?.name || "anon"
}`}
</button>
);
}