mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-17 14:04:21 +01:00
27 lines
752 B
TypeScript
27 lines
752 B
TypeScript
import { Component, Switch, Match } from 'solid-js';
|
|
import { npubEncode } from 'nostr-tools/nip19';
|
|
|
|
import useConfig from '@/nostr/useConfig';
|
|
import useProfile from '@/nostr/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={npubEncode(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;
|