ClaimPreview & sidebar: strip '@' since channel is implied (#879)

## Ticket
865: Hide @ symbol in areas where channel names are implied
This commit is contained in:
infinite-persistence 2022-02-23 04:42:43 -08:00 committed by GitHub
parent 39de1d7e84
commit cfd234d615
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 5 deletions

View file

@ -43,7 +43,7 @@ function ClaimPreviewSubtitle(props: Props) {
<div className="media__subtitle"> <div className="media__subtitle">
{claim ? ( {claim ? (
<React.Fragment> <React.Fragment>
<UriIndicator uri={uri} link />{' '} <UriIndicator uri={uri} link stripAtSign />{' '}
{!pending && claim && ( {!pending && claim && (
<> <>
{isChannel && type !== 'inline' && ( {isChannel && type !== 'inline' && (

View file

@ -222,7 +222,7 @@ function ClaimPreviewTile(props: Props) {
<TruncatedText text={title || (claim && claim.name)} lines={isChannel ? 1 : 2} /> <TruncatedText text={title || (claim && claim.name)} lines={isChannel ? 1 : 2} />
{isChannel && ( {isChannel && (
<div className="claim-tile__about"> <div className="claim-tile__about">
<UriIndicator uri={uri} /> <UriIndicator uri={uri} stripAtSign />
</div> </div>
)} )}
</h2> </h2>
@ -247,7 +247,7 @@ function ClaimPreviewTile(props: Props) {
</UriIndicator> </UriIndicator>
<div className="claim-tile__about"> <div className="claim-tile__about">
<UriIndicator uri={uri} link /> <UriIndicator uri={uri} link stripAtSign />
<div className="claim-tile__about--counts"> <div className="claim-tile__about--counts">
<FileViewCountInline uri={uri} isLivestream={isLivestream} /> <FileViewCountInline uri={uri} isLivestream={isLivestream} />
{isLivestream && <LivestreamDateTime uri={uri} />} {isLivestream && <LivestreamDateTime uri={uri} />}

View file

@ -13,6 +13,7 @@ import I18nMessage from 'component/i18nMessage';
import ChannelThumbnail from 'component/channelThumbnail'; import ChannelThumbnail from 'component/channelThumbnail';
import { useIsMobile, useIsLargeScreen, isTouch } from 'effects/use-screensize'; import { useIsMobile, useIsLargeScreen, isTouch } from 'effects/use-screensize';
import { GetLinksData } from 'util/buildHomepage'; import { GetLinksData } from 'util/buildHomepage';
import { stripLeadingAtSign } from 'util/string';
import { DOMAIN, ENABLE_UI_NOTIFICATIONS, ENABLE_NO_SOURCE_CLAIMS, CHANNEL_STAKED_LEVEL_LIVESTREAM } from 'config'; import { DOMAIN, ENABLE_UI_NOTIFICATIONS, ENABLE_NO_SOURCE_CLAIMS, CHANNEL_STAKED_LEVEL_LIVESTREAM } from 'config';
const FOLLOWED_ITEM_INITIAL_LIMIT = 10; const FOLLOWED_ITEM_INITIAL_LIMIT = 10;
@ -539,7 +540,7 @@ function SubscriptionListItem({ subscription }: { subscription: Subscription })
> >
<ChannelThumbnail xsmall uri={uri} hideStakedIndicator /> <ChannelThumbnail xsmall uri={uri} hideStakedIndicator />
<span dir="auto" className="button__label"> <span dir="auto" className="button__label">
{channelName} {stripLeadingAtSign(channelName)}
</span> </span>
</Button> </Button>
</li> </li>

View file

@ -3,6 +3,7 @@ import type { Node } from 'react';
import React from 'react'; import React from 'react';
import classnames from 'classnames'; import classnames from 'classnames';
import Button from 'component/button'; import Button from 'component/button';
import { stripLeadingAtSign } from 'util/string';
type ChannelInfo = { uri: string, name: string }; type ChannelInfo = { uri: string, name: string };
@ -14,6 +15,7 @@ type Props = {
focusable?: boolean, // Defaults to 'true' if not provided. focusable?: boolean, // Defaults to 'true' if not provided.
hideAnonymous?: boolean, hideAnonymous?: boolean,
inline?: boolean, inline?: boolean,
stripAtSign?: boolean,
className?: string, className?: string,
children: ?Node, // to allow for other elements to be nested within the UriIndicator (commit: 1e82586f). children: ?Node, // to allow for other elements to be nested within the UriIndicator (commit: 1e82586f).
// --- redux --- // --- redux ---
@ -79,6 +81,7 @@ class UriIndicator extends React.PureComponent<Props> {
focusable = true, focusable = true,
external = false, external = false,
hideAnonymous = false, hideAnonymous = false,
stripAtSign,
className, className,
} = this.props; } = this.props;
@ -109,7 +112,7 @@ class UriIndicator extends React.PureComponent<Props> {
const inner = ( const inner = (
<span dir="auto" className={classnames('channel-name', { 'channel-name--inline': inline })}> <span dir="auto" className={classnames('channel-name', { 'channel-name--inline': inline })}>
{channelName} {stripAtSign ? stripLeadingAtSign(channelName) : channelName}
</span> </span>
); );

View file

@ -21,3 +21,7 @@ export function toCompactNotation(number: string | number, lang: ?string, minThr
return Number(number).toLocaleString(locale); return Number(number).toLocaleString(locale);
} }
} }
export function stripLeadingAtSign(str: ?string) {
return str && str.charAt(0) === '@' ? str.slice(1) : str;
}