[Glitch] Fixes display names not rendering with emojis

Port 5fa7654688 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo
2025-12-15 13:54:46 +01:00
committed by Claire
parent 0c852a426f
commit 56a9d62972
5 changed files with 29 additions and 25 deletions

View File

@@ -25,7 +25,7 @@ function loaded() {
const initialState = JSON.parse(
propsNode.textContent,
) as ApiAnnualReportResponse;
) as ApiAnnualReportResponse & { me?: string };
const report = initialState.annual_reports[0];
if (!report) {
@@ -35,7 +35,10 @@ function loaded() {
// Set up store
store.dispatch(
hydrateStore({
meta: { locale: document.documentElement.lang },
meta: {
locale: document.documentElement.lang,
me: initialState.me,
},
accounts: initialState.accounts,
}),
);

View File

@@ -6,6 +6,7 @@ import classNames from 'classnames';
import { Avatar } from '@/flavours/glitch/components/avatar';
import { Button } from '@/flavours/glitch/components/button';
import { DisplayName } from '@/flavours/glitch/components/display_name';
import { me } from '@/flavours/glitch/initial_state';
import type { Account } from '@/flavours/glitch/models/account';
import type {
@@ -137,9 +138,6 @@ export const Archetype: React.FC<{
? archetypeSelfDescriptions
: archetypePublicDescriptions;
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- we specifically want to fallback if `display_name` is empty
const name = account?.display_name || account?.username;
return (
<div
className={classNames(styles.box, styles.archetype)}
@@ -182,7 +180,9 @@ export const Archetype: React.FC<{
<FormattedMessage
id='annual_report.summary.archetype.title_public'
defaultMessage="{name}'s archetype"
values={{ name }}
values={{
name: <DisplayName variant='simple' account={account} />,
}}
/>
)}
</h2>
@@ -199,7 +199,7 @@ export const Archetype: React.FC<{
<p>
{isRevealed ? (
intl.formatMessage(descriptions[archetype], {
name,
name: <DisplayName variant='simple' account={account} />,
})
) : (
<FormattedMessage

View File

@@ -10,7 +10,6 @@ import classNames from 'classnames/bind';
import { closeModal } from '@/flavours/glitch/actions/modal';
import { IconButton } from '@/flavours/glitch/components/icon_button';
import { LoadingIndicator } from '@/flavours/glitch/components/loading_indicator';
import { me } from '@/flavours/glitch/initial_state';
import {
createAppSelector,
useAppDispatch,
@@ -30,9 +29,6 @@ const moduleClassNames = classNames.bind(styles);
const accountSelector = createAppSelector(
[(state) => state.accounts, (state) => state.annualReport.report],
(accounts, report) => {
if (me) {
return accounts.get(me);
}
if (report?.schema_version === 2) {
return accounts.get(report.account_id);
}
@@ -109,7 +105,7 @@ export const AnnualReport: FC<{ context?: 'modal' | 'standalone' }> = ({
{topHashtag && (
<MostUsedHashtag
hashtag={topHashtag}
name={account?.display_name}
account={account}
context={context}
/>
)}

View File

@@ -2,15 +2,17 @@ import { FormattedMessage } from 'react-intl';
import classNames from 'classnames';
import { DisplayName } from '@/flavours/glitch/components/display_name';
import type { Account } from '@/flavours/glitch/models/account';
import type { NameAndCount } from 'flavours/glitch/models/annual_report';
import styles from './index.module.scss';
export const MostUsedHashtag: React.FC<{
hashtag: NameAndCount;
name: string | undefined;
context: 'modal' | 'standalone';
}> = ({ hashtag, name, context }) => {
account?: Account;
}> = ({ hashtag, context, account }) => {
return (
<div
className={classNames(styles.box, styles.mostUsedHashtag, styles.content)}
@@ -25,20 +27,22 @@ export const MostUsedHashtag: React.FC<{
<div className={styles.statExtraLarge}>#{hashtag.name}</div>
<p>
{context === 'modal' ? (
{context === 'modal' && (
<FormattedMessage
id='annual_report.summary.most_used_hashtag.used_count'
defaultMessage='You included this hashtag in {count, plural, one {one post} other {# posts}}.'
values={{ count: hashtag.count }}
/>
) : (
name && (
<FormattedMessage
id='annual_report.summary.most_used_hashtag.used_count_public'
defaultMessage='{name} included this hashtag in {count, plural, one {one post} other {# posts}}.'
values={{ count: hashtag.count, name }}
/>
)
)}
{context !== 'modal' && account && (
<FormattedMessage
id='annual_report.summary.most_used_hashtag.used_count_public'
defaultMessage='{name} included this hashtag in {count, plural, one {one post} other {# posts}}.'
values={{
count: hashtag.count,
name: <DisplayName variant='simple' account={account} />,
}}
/>
)}
</p>
</div>

View File

@@ -3,12 +3,13 @@ import type { FC } from 'react';
import { FormattedMessage } from 'react-intl';
import { IconLogo } from '@/flavours/glitch/components/logo';
import { me } from '@/flavours/glitch/initial_state';
import { useAppSelector } from '@/flavours/glitch/store';
import { AnnualReport } from './index';
import classes from './shared_page.module.scss';
export const WrapstodonSharedPage: FC = () => {
const isLoggedIn = useAppSelector((state) => !!state.meta.get('me'));
return (
<main className={classes.wrapper}>
<AnnualReport />
@@ -23,7 +24,7 @@ export const WrapstodonSharedPage: FC = () => {
<a href='https://joinmastodon.org'>
<FormattedMessage id='footer.about' defaultMessage='About' />
</a>
{!me && (
{!isLoggedIn && (
<a href='https://joinmastodon.org/servers'>
<FormattedMessage
id='annual_report.shared_page.sign_up'