import type { JSX } from 'react'; import { Component } from 'react'; import { FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import { Link } from 'react-router-dom'; import type Immutable from 'immutable'; import { Sparklines, SparklinesCurve } from 'react-sparklines'; import { ShortNumber } from 'mastodon/components/short_number'; import { Skeleton } from 'mastodon/components/skeleton'; interface SilentErrorBoundaryProps { children: React.ReactNode; } class SilentErrorBoundary extends Component { state = { error: false, }; componentDidCatch() { this.setState({ error: true }); } render() { if (this.state.error) { return null; } return this.props.children; } } /** * Used to render counter of how much people are talking about hashtag * @param displayNumber Counter number to display * @param pluralReady Whether the count is plural * @returns Formatted counter of how much people are talking about hashtag */ export const accountsCountRenderer = ( displayNumber: JSX.Element, pluralReady: number, ) => ( {displayNumber}, days: 2, }} /> ); interface ImmutableHashtagProps { hashtag: Immutable.Map; } export const ImmutableHashtag = ({ hashtag }: ImmutableHashtagProps) => ( > ) .reverse() // eslint-disable-next-line @typescript-eslint/no-non-null-assertion .map((day) => day.get('uses')!) .toArray()} /> ); export interface HashtagProps { className?: string; description?: React.ReactNode; history?: number[]; name: string; people: number; to: string; uses?: number; withGraph?: boolean; } export const Hashtag: React.FC = ({ name, to, people, uses, history, className, description, withGraph = true, }) => (
{name ? ( <> #{name} ) : ( )} {description ? ( {description} ) : typeof people !== 'undefined' ? ( ) : ( )}
{typeof uses !== 'undefined' && (
)} {withGraph && (
0)} >
)}
);