diff --git a/app/javascript/flavours/glitch/entrypoints/wrapstodon.tsx b/app/javascript/flavours/glitch/entrypoints/wrapstodon.tsx index 5de491c47a..972e5dac03 100644 --- a/app/javascript/flavours/glitch/entrypoints/wrapstodon.tsx +++ b/app/javascript/flavours/glitch/entrypoints/wrapstodon.tsx @@ -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, }), ); diff --git a/app/javascript/flavours/glitch/features/annual_report/archetype.tsx b/app/javascript/flavours/glitch/features/annual_report/archetype.tsx index 352a99656b..743aa0c05c 100644 --- a/app/javascript/flavours/glitch/features/annual_report/archetype.tsx +++ b/app/javascript/flavours/glitch/features/annual_report/archetype.tsx @@ -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 (
, + }} /> )} @@ -199,7 +199,7 @@ export const Archetype: React.FC<{

{isRevealed ? ( intl.formatMessage(descriptions[archetype], { - name, + name: , }) ) : ( 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 && ( )} diff --git a/app/javascript/flavours/glitch/features/annual_report/most_used_hashtag.tsx b/app/javascript/flavours/glitch/features/annual_report/most_used_hashtag.tsx index 7f60db8038..46f17fff9b 100644 --- a/app/javascript/flavours/glitch/features/annual_report/most_used_hashtag.tsx +++ b/app/javascript/flavours/glitch/features/annual_report/most_used_hashtag.tsx @@ -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 (

#{hashtag.name}

- {context === 'modal' ? ( + {context === 'modal' && ( - ) : ( - name && ( - - ) + )} + {context !== 'modal' && account && ( + , + }} + /> )}

diff --git a/app/javascript/flavours/glitch/features/annual_report/shared_page.tsx b/app/javascript/flavours/glitch/features/annual_report/shared_page.tsx index a2dc9ff848..8e08817924 100644 --- a/app/javascript/flavours/glitch/features/annual_report/shared_page.tsx +++ b/app/javascript/flavours/glitch/features/annual_report/shared_page.tsx @@ -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 (
@@ -23,7 +24,7 @@ export const WrapstodonSharedPage: FC = () => { - {!me && ( + {!isLoggedIn && (