]> cat aescling's git repositories - mastodon.git/blob - app/javascript/flavours/glitch/util/main.js
Merge branch 'master' into glitch-soc/merge-upstream
[mastodon.git] / app / javascript / flavours / glitch / util / main.js
1 import * as registerPushNotifications from 'flavours/glitch/actions/push_notifications';
2 import { default as Mastodon, store } from 'flavours/glitch/containers/mastodon';
3 import React from 'react';
4 import ReactDOM from 'react-dom';
5 import ready from './ready';
6
7 const perf = require('./performance');
8
9 function main() {
10 perf.start('main()');
11
12 if (window.history && history.replaceState) {
13 const { pathname, search, hash } = window.location;
14 const path = pathname + search + hash;
15 if (!(/^\/web[$/]/).test(path)) {
16 history.replaceState(null, document.title, `/web${path}`);
17 }
18 }
19
20 ready(() => {
21 const mountNode = document.getElementById('mastodon');
22 const props = JSON.parse(mountNode.getAttribute('data-props'));
23
24 ReactDOM.render(<Mastodon {...props} />, mountNode);
25 if (process.env.NODE_ENV === 'production') {
26 // avoid offline in dev mode because it's harder to debug
27 require('offline-plugin/runtime').install();
28 store.dispatch(registerPushNotifications.register());
29 }
30 perf.stop('main()');
31 });
32 }
33
34 export default main;
This page took 0.077507 seconds and 4 git commands to generate.