diff --git a/app/javascript/flavours/glitch/actions/store.js b/app/javascript/flavours/glitch/actions/store.js index b2d19575c4..2a45373c9e 100644 --- a/app/javascript/flavours/glitch/actions/store.js +++ b/app/javascript/flavours/glitch/actions/store.js @@ -37,7 +37,9 @@ export function hydrateStore(rawState) { dispatch(hydrateCompose()); dispatch(hydrateSearch()); - dispatch(importFetchedAccounts(Object.values(rawState.accounts))); + if (rawState.accounts) { + dispatch(importFetchedAccounts(Object.values(rawState.accounts))); + } dispatch(saveSettings()); }; } diff --git a/app/javascript/flavours/glitch/entrypoints/wrapstodon.tsx b/app/javascript/flavours/glitch/entrypoints/wrapstodon.tsx index 86efd7676e..acb8ad90e1 100644 --- a/app/javascript/flavours/glitch/entrypoints/wrapstodon.tsx +++ b/app/javascript/flavours/glitch/entrypoints/wrapstodon.tsx @@ -2,10 +2,8 @@ import { createRoot } from 'react-dom/client'; import { Provider as ReduxProvider } from 'react-redux'; -import { - importFetchedAccounts, - importFetchedStatuses, -} from '@/flavours/glitch/actions/importer'; +import { importFetchedStatuses } from '@/flavours/glitch/actions/importer'; +import { hydrateStore } from '@/flavours/glitch/actions/store'; import type { ApiAnnualReportResponse } from '@/flavours/glitch/api/annual_report'; import { Router } from '@/flavours/glitch/components/router'; import { WrapstodonShare } from '@/flavours/glitch/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/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index 4c7a127a3d..74b1666796 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -442,7 +442,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)