feat: group metadata query
This commit is contained in:
@@ -45,7 +45,7 @@ export function NoteRepost({
|
||||
const list: Promise<MenuItem>[] = [];
|
||||
|
||||
for (const account of accounts) {
|
||||
const res = await commands.getProfile(account, true);
|
||||
const res = await commands.getProfile(account);
|
||||
let name = "unknown";
|
||||
|
||||
if (res.status === "ok") {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { memo } from "react";
|
||||
export const MentionUser = memo(function MentionUser({
|
||||
pubkey,
|
||||
}: { pubkey: string }) {
|
||||
const { isLoading, isError, profile } = useProfile(pubkey);
|
||||
const { isLoading, profile } = useProfile(pubkey);
|
||||
|
||||
return (
|
||||
<button
|
||||
@@ -14,10 +14,8 @@ export const MentionUser = memo(function MentionUser({
|
||||
className="break-words text-start text-blue-500 hover:text-blue-600"
|
||||
>
|
||||
{isLoading
|
||||
? "@anon"
|
||||
: isError
|
||||
? displayNpub(pubkey, 16)
|
||||
: `@${profile?.name || profile?.display_name || displayNpub(pubkey, 16)}`}
|
||||
? displayNpub(pubkey, 16)
|
||||
: `@${profile?.name || profile?.display_name || displayNpub(pubkey, 16)}`}
|
||||
</button>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2,26 +2,27 @@ import { useProfile } from "@/system";
|
||||
import type { Metadata } from "@/types";
|
||||
import { type ReactNode, createContext, useContext } from "react";
|
||||
|
||||
const UserContext = createContext<{
|
||||
interface UserContext {
|
||||
pubkey: string;
|
||||
profile: Metadata;
|
||||
isError: boolean;
|
||||
profile: Metadata | undefined;
|
||||
isLoading: boolean;
|
||||
}>(null);
|
||||
}
|
||||
|
||||
const UserContext = createContext<UserContext | null>(null);
|
||||
|
||||
export function UserProvider({
|
||||
pubkey,
|
||||
children,
|
||||
embedProfile,
|
||||
data,
|
||||
}: {
|
||||
pubkey: string;
|
||||
children: ReactNode;
|
||||
embedProfile?: string;
|
||||
data?: string;
|
||||
}) {
|
||||
const { isLoading, isError, profile } = useProfile(pubkey, embedProfile);
|
||||
const { isLoading, profile } = useProfile(pubkey, data);
|
||||
|
||||
return (
|
||||
<UserContext.Provider value={{ pubkey, profile, isError, isLoading }}>
|
||||
<UserContext.Provider value={{ pubkey, isLoading, profile }}>
|
||||
{children}
|
||||
</UserContext.Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user