This commit is contained in:
Shusui MOYATANI
2023-03-04 12:59:45 +09:00
parent 7cc2a304dc
commit 4be810523d
13 changed files with 221 additions and 99 deletions

View File

@@ -0,0 +1,25 @@
import { Component, Switch, Match } from 'solid-js';
import useConfig from '@/clients/useConfig';
import useProfile, { type Profile } from '@/clients/useProfile';
type UserNameDisplayProps = {
pubkey: string;
};
const UserNameDisplay: Component<UserNameDisplayProps> = (props) => {
const [config] = useConfig();
const { profile } = useProfile(() => ({
relayUrls: config().relayUrls,
pubkey: props.pubkey,
}));
return (
<Switch fallback={`@${props.pubkey}`}>
<Match when={(profile()?.display_name?.length ?? 0) > 0}>{profile()?.display_name}</Match>
<Match when={(profile()?.name?.length ?? 0) > 0}>@{profile()?.name}</Match>
</Switch>
);
};
export default UserNameDisplay;