diff --git a/app/helpers/wrapstodon_helper.rb b/app/helpers/wrapstodon_helper.rb index da3b0d6fad8..8031c51179e 100644 --- a/app/helpers/wrapstodon_helper.rb +++ b/app/helpers/wrapstodon_helper.rb @@ -2,15 +2,19 @@ module WrapstodonHelper def render_wrapstodon_share_data(report) - json = ActiveModelSerializers::SerializableResource.new( + payload = ActiveModelSerializers::SerializableResource.new( AnnualReportsPresenter.new([report]), serializer: REST::AnnualReportsSerializer, scope: nil, scope_name: :current_user - ).to_json + ).as_json + + payload[:me] = current_account.id.to_s if user_signed_in? + + json_string = payload.to_json # rubocop:disable Rails/OutputSafety - content_tag(:script, json_escape(json).html_safe, type: 'application/json', id: 'wrapstodon-data') + content_tag(:script, json_escape(json_string).html_safe, type: 'application/json', id: 'wrapstodon-data') # rubocop:enable Rails/OutputSafety end end diff --git a/app/javascript/entrypoints/wrapstodon.tsx b/app/javascript/entrypoints/wrapstodon.tsx index 7a74e18d521..e2c8d5a38e5 100644 --- a/app/javascript/entrypoints/wrapstodon.tsx +++ b/app/javascript/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/mastodon/features/annual_report/archetype.tsx b/app/javascript/mastodon/features/annual_report/archetype.tsx index 465944df542..7d1cf0bdd48 100644 --- a/app/javascript/mastodon/features/annual_report/archetype.tsx +++ b/app/javascript/mastodon/features/annual_report/archetype.tsx @@ -12,6 +12,7 @@ import replier from '@/images/archetypes/replier.png'; import space_elements from '@/images/archetypes/space_elements.png'; import { Avatar } from '@/mastodon/components/avatar'; import { Button } from '@/mastodon/components/button'; +import { DisplayName } from '@/mastodon/components/display_name'; import { me } from '@/mastodon/initial_state'; import type { Account } from '@/mastodon/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:
- {context === 'modal' ? (
+ {context === 'modal' && (