use just name instead of display_name

This commit is contained in:
Martti Malmi 2023-05-01 11:19:26 +03:00
parent 8984d64871
commit 83dffa5234
16 changed files with 26 additions and 64 deletions

View File

@ -561,7 +561,7 @@ export default {
<>
{' '}
<a href={link}>
@<Name key={match + i} pub={match} hideBadge={true} userNameOnly={true} />
@<Name key={match + i} pub={match} hideBadge={true} />
</a>
</>
);
@ -576,7 +576,7 @@ export default {
<>
{' '}
<a href={`/${data.pubkey}`}>
@<Name key={match + i} pub={data.pubkey} hideBadge={true} userNameOnly={true} />
@<Name key={match + i} pub={data.pubkey} hideBadge={true} />
</a>
</>
);
@ -636,7 +636,7 @@ export default {
const link = `/${Key.toNostrBech32Address(tagTarget, 'npub')}`;
return (
<a href={link}>
@<Name key={tagTarget + i} pub={tagTarget} hideBadge={true} userNameOnly={true} />
@<Name key={tagTarget + i} pub={tagTarget} hideBadge={true} />
</a>
);
} else if (tag[0] === 'e') {

View File

@ -73,7 +73,7 @@ export default class Header extends Component {
);
this.setState({ title });
} else {
const title = <Name displayNameOnly={true} key={this.chatId} pub={this.chatId} />;
const title = <Name key={this.chatId} pub={this.chatId} />;
this.setState({ title });
}
}

View File

@ -10,8 +10,6 @@ type Props = {
pub: string;
placeholder?: string;
hideBadge?: boolean;
userNameOnly?: boolean;
displayNameOnly?: boolean; // Add the new prop here
};
const Name = (props: Props) => {
@ -29,8 +27,8 @@ const Name = (props: Props) => {
initialName = profile.name?.trim().slice(0, 100) || '';
initialDisplayName = profile.display_name?.trim().slice(0, 100);
}
if (!initialDisplayName) {
initialDisplayName = AnimalName(Key.toNostrBech32Address(props.pub, 'npub') || props.pub);
if (!initialName) {
initialName = AnimalName(Key.toNostrBech32Address(props.pub, 'npub') || props.pub);
isGenerated = true;
}
const [name, setName] = useState(initialName);
@ -48,35 +46,13 @@ const Name = (props: Props) => {
});
}
}, [props.pub]);
if (props.userNameOnly) {
return (
<>
{name || displayName}
{props.hideBadge ? '' : <Badge pub={props.pub} />}
</>
);
}
if (props.displayNameOnly) {
return (
<>
<span className={`display-name ${isNameGenerated ? 'generated' : ''}`}>
{displayName || name || props.placeholder}
</span>
{props.hideBadge ? '' : <Badge pub={props.pub} />}
</>
);
}
const showUserName = name && displayName && displayName.toLowerCase() !== name.toLowerCase();
return (
<>
<span className={`display-name ${isNameGenerated ? 'generated' : ''}`}>
{displayName || name || props.placeholder}
{name || displayName || props.placeholder}
</span>
{props.hideBadge ? '' : <Badge pub={props.pub} />}
{showUserName ? <small className="user-name mar-left5">@{name}</small> : ''}
</>
);
};

View File

@ -79,7 +79,7 @@ export default class OnboardingNotification extends Component {
<Identicon str={pub} width={40} />
</div>
<div style="flex: 1">
<Name displayNameOnly={true} pub={pub} placeholder="Suggested follow" />
<Name pub={pub} placeholder="Suggested follow" />
<br />
<small>{description}</small>
</div>

View File

@ -50,11 +50,7 @@ class Block extends Component<Props> {
>
<span className="nonhover">
{t(this.state[this.key] ? this.actionDone : this.action)}{' '}
{this.props.showName ? (
<Name pub={this.props.id} userNameOnly={true} hideBadge={true} />
) : (
''
)}
{this.props.showName ? <Name pub={this.props.id} hideBadge={true} /> : ''}
</span>
<span className="hover">{t(this.hoverAction)}</span>
</Button>

View File

@ -58,7 +58,7 @@ export default function Like(props: Props) {
</i>
<div>
<a href={userLink} style={{ marginRight: 5 }}>
<Name pub={props.event.pubkey} userNameOnly={true} />
<Name pub={props.event.pubkey} />
</a>
{allLikes.length > 1 && <> and {allLikes.length - 1} others </>} {likeText}
</div>

View File

@ -177,7 +177,7 @@ const Note = ({
{t('replying_to') + ' '}
{replyingToUsers.slice(0, 3).map((u) => (
<a href={`/${Key.toNostrBech32Address(u, 'npub')}`}>
@<Name pub={u} hideBadge={true} userNameOnly={true} />{' '}
@<Name pub={u} hideBadge={true} />{' '}
</a>
))}
{replyingToUsers?.length > 3 ? '...' : ''}

View File

@ -1,4 +1,5 @@
import styled from 'styled-components';
import Modal from '../modal/Modal';
import SafeImg from '../SafeImg';

View File

@ -42,14 +42,18 @@ export default function Repost(props: Props) {
<ArrowPathIcon width={24} />
</i>
<a href={`/${Key.toNostrBech32Address(props.event.pubkey, 'npub')}`}>
<Name pub={props.event?.pubkey} hideBadge={true} userNameOnly={true} />
<Name pub={props.event?.pubkey} hideBadge={true} />
</a>
<span style={{ marginLeft: '5px' }}>
{allReposts.length > 1 && `and ${allReposts.length - 1} others`} {t('reposted')}
</span>
</small>
</div>
<EventComponent key={repostedEventId + props.event.id} id={repostedEventId} fullWidth={props.fullWidth} />
<EventComponent
key={repostedEventId + props.event.id}
id={repostedEventId}
fullWidth={props.fullWidth}
/>
</div>
</div>
);

View File

@ -65,7 +65,7 @@ export default function Zap(props: Props) {
</i>
<div>
<a href={userLink} style={{ marginRight: '5px' }}>
<Name pub={zappingUser} userNameOnly={true} />
<Name pub={zappingUser} />
</a>
{allZaps.length > 1 && <span> and {allZaps.length - 1} others </span>}
{zappedText}

View File

@ -11,7 +11,7 @@ const QRModal = (props) => {
<div style={{ textAlign: 'center', flex: 1 }}>
<QrCode data={link} />
<p>
<Name displayNameOnly={true} pub={props.pub} />
<Name pub={props.pub} />
</p>
</div>
</Modal>

View File

@ -414,7 +414,7 @@ export default function SendSats(props: ZapProps) {
<div className="lnurl-header">
<h2>
{props.title || title}
<Name displayNameOnly={true} pub={recipient} />
<Name pub={recipient} />
</h2>
</div>
{invoiceForm()}

View File

@ -11,8 +11,6 @@ import SocialNetwork from '../nostr/SocialNetwork';
import { translate as t } from '../translations/Translation';
const explainers = {
display_name: 'Name',
name: 'Username',
lud16: 'Bitcoin lightning address ⚡ (lud16)',
picture: 'Picture url',
banner: 'Banner url',
@ -82,16 +80,7 @@ export default class EditProfile extends Component {
};
render() {
const fields = [
'display_name',
'name',
'picture',
'about',
'banner',
'website',
'lud16',
'nip05',
];
const fields = ['name', 'picture', 'about', 'banner', 'website', 'lud16', 'nip05'];
// add other possible fields from profile
Object.keys(this.state.profile).forEach((key) => {
if (!fields.includes(key)) {

View File

@ -122,7 +122,7 @@ class Follows extends View {
<div className="centered-container">
<h3 style={{ display: 'flex' }}>
<a href={`/${this.props.id}`}>
<Name displayNameOnly={true} pub={this.props.id} />
<Name pub={this.props.id} />
</a>
:<i> </i>
<span style={{ flex: 1 }} className="mar-left5">

View File

@ -188,11 +188,7 @@ class Profile extends View {
? html`
<${Button} onClick=${(e) => this.viewAs(e)}>
${t('view_as') + ' '}
<${Name}
pub=${this.state.hexPub}
userNameOnly=${true}
hideBadge=${true}
/>
<${Name} pub=${this.state.hexPub} hideBadge=${true} />
<//>
`
: ''}
@ -452,7 +448,7 @@ class Profile extends View {
console.log('Invalid banner URL', profile.banner);
}
// profile may contain arbitrary fields, so be careful
// profile may contain arbitrary fields, so be careful what you pass to setState
this.setState({
name: profile.name,
display_name: profile.display_name,

View File

@ -113,7 +113,7 @@ class ChatListItem extends Component {
<${Identicon} str=${npub} width="49" />
<div class="text">
<div>
<span class="name"><${Name} displayNameOnly=${true} pub=${this.props.chat} /></span>
<span class="name"><${Name} pub=${this.props.chat} /></span>
<small class="latest-time">${time}</small>
</div>
<small class="latest"> ${this.state.latestText} </small>