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