dispatch/client/src/js/modules/documentTitle.js

29 lines
670 B
JavaScript
Raw Normal View History

2017-05-19 05:29:44 +00:00
import capitalize from 'lodash/capitalize';
import observe from '../util/observe';
import { getCurrentServerName } from '../reducers/servers';
const getRouter = state => state.router;
export default function documentTitle({ store }) {
observe(
store,
[getRouter, getCurrentServerName],
(router, serverName) => {
let title;
if (router.route === 'chat') {
const { name } = router.params;
if (name) {
title = `${name} @ ${serverName}`;
} else {
title = serverName;
}
} else {
title = capitalize(router.route);
}
document.title = `${title} | Dispatch`;
}
);
}