diff --git a/app/javascript/entrypoints/wrapstodon.tsx b/app/javascript/entrypoints/wrapstodon.tsx index e1eebcce57..d599d30e67 100644 --- a/app/javascript/entrypoints/wrapstodon.tsx +++ b/app/javascript/entrypoints/wrapstodon.tsx @@ -2,10 +2,8 @@ import { createRoot } from 'react-dom/client'; import { Provider as ReduxProvider } from 'react-redux'; -import { - importFetchedAccounts, - importFetchedStatuses, -} from '@/mastodon/actions/importer'; +import { importFetchedStatuses } from '@/mastodon/actions/importer'; +import { hydrateStore } from '@/mastodon/actions/store'; import type { ApiAnnualReportResponse } from '@/mastodon/api/annual_report'; import { Router } from '@/mastodon/components/router'; import { WrapstodonShare } from '@/mastodon/features/annual_report/share'; @@ -33,7 +31,14 @@ function loaded() { if (!report) { throw new Error('Initial state report not found'); } - store.dispatch(importFetchedAccounts(initialState.accounts)); + + // Set up store + store.dispatch( + hydrateStore({ + meta: { locale: document.documentElement.lang }, + accounts: initialState.accounts, + }), + ); store.dispatch(importFetchedStatuses(initialState.statuses)); store.dispatch(setReport(report)); diff --git a/app/javascript/mastodon/actions/store.js b/app/javascript/mastodon/actions/store.js index e8fec13453..7a68679d44 100644 --- a/app/javascript/mastodon/actions/store.js +++ b/app/javascript/mastodon/actions/store.js @@ -22,6 +22,8 @@ export function hydrateStore(rawState) { dispatch(hydrateCompose()); dispatch(hydrateSearch()); - dispatch(importFetchedAccounts(Object.values(rawState.accounts))); + if (rawState.accounts) { + dispatch(importFetchedAccounts(Object.values(rawState.accounts))); + } }; } diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index c7e27abd45..e413f2893d 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -363,7 +363,9 @@ export const composeReducer = (state = initialState, action) => { switch(action.type) { case STORE_HYDRATE: - return hydrate(state, action.state.get('compose')); + if (action.state.get('compose')) + return hydrate(state, action.state.get('compose')); + return state; case COMPOSE_MOUNT: return state .set('mounted', state.get('mounted') + 1)