Fix document title syncing

This commit is contained in:
Berkeley Martinez
2016-02-04 15:44:02 -08:00
parent f150b31c24
commit c4ba7ac46a

View File

@ -2,14 +2,15 @@
// () => // () =>
// (next: (action: Action) => Object) => // (next: (action: Action) => Object) =>
// titleSage(action: Action) => Object|Void // titleSage(action: Action) => Object|Void
export default (doc) => () => next => { export default ({ doc }) => ({ getState }) => next => {
return function titleSage(action) { return function titleSage(action) {
// get next state // get next state
const result = next(action); const result = next(action);
if (action !== 'updateTitle') { if (action.type !== 'app.updateTitle') {
return result; return result;
} }
const newTitle = result.app.title; const state = getState();
const newTitle = state.app.title;
doc.title = newTitle; doc.title = newTitle;
return result; return result;
}; };