mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-18 14:34:25 +01:00
update
This commit is contained in:
25
src/components/UserDisplayName.tsx
Normal file
25
src/components/UserDisplayName.tsx
Normal 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;
|
||||
Reference in New Issue
Block a user