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';
|
2020-06-15 08:58:51 +00:00
|
|
|
import { getCurrentNetworkName } from 'state/networks';
|
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 }) {
|
2020-06-15 08:58:51 +00:00
|
|
|
observe(store, [getRouter, getCurrentNetworkName], (router, networkName) => {
|
2017-05-26 06:20:00 +00:00
|
|
|
let title;
|
2017-05-19 05:29:44 +00:00
|
|
|
|
2017-05-26 06:20:00 +00:00
|
|
|
if (router.route === 'chat') {
|
2020-06-15 08:58:51 +00:00
|
|
|
const { network, name } = router.params;
|
2017-05-26 06:20:00 +00:00
|
|
|
if (name) {
|
2020-06-15 08:58:51 +00:00
|
|
|
title = `${name} @ ${networkName || network}`;
|
2017-05-19 05:29:44 +00:00
|
|
|
} else {
|
2020-06-15 08:58:51 +00:00
|
|
|
title = networkName || network;
|
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
|
|
|
|
2018-11-22 09:09:13 +00:00
|
|
|
if (title) {
|
|
|
|
document.title = `${title} | Dispatch`;
|
|
|
|
} else {
|
|
|
|
document.title = 'Dispatch';
|
|
|
|
}
|
2017-05-26 06:20:00 +00:00
|
|
|
});
|
2017-05-19 05:29:44 +00:00
|
|
|
}
|