feat(Flash): Get flashes from ssr

This commit is contained in:
Berkeley Martinez
2018-01-08 11:12:00 -08:00
parent 4c5b41fe9a
commit 5a32585ddd
2 changed files with 30 additions and 12 deletions

View File

@@ -5,10 +5,10 @@ import { render } from 'redux-epic';
import createHistory from 'history/createBrowserHistory';
import useLangRoutes from './utils/use-lang-routes';
import sendPageAnalytics from './utils/send-page-analytics';
import flashToToast from './utils/flash-to-toast';
import { App, createApp, provideStore } from '../common/app';
import { getLangFromPath } from '../common/app/utils/lang';
import flashReducer, { messagesFoundOnBoot } from '../common/app/Flash/redux';
// client specific epics
import epics from './epics';
@@ -29,7 +29,7 @@ const {
document,
ga,
__fcc__: {
flash = [],
flash = {},
data: ssrState = {},
csrf: {
token: csrfToken
@@ -51,7 +51,10 @@ const defaultState = isColdStored() ?
const primaryLang = getLangFromPath(location.pathname);
defaultState.app.csrfToken = csrfToken;
defaultState.toasts = flashToToast(flash);
defaultState.flash = flashReducer(
defaultState.flash,
messagesFoundOnBoot(flash)
);
const serviceOptions = { xhrPath: '/services', context: { _csrf: csrfToken } };
@@ -78,7 +81,7 @@ createApp({
});
}
})
.doOnNext(() => log('rendering'))
.do(() => log('rendering'))
.flatMap(({ store }) => render(provideStore(App, store), DOMContainer))
.subscribe(
() => debug('react rendered'),