You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
7 years ago
|
import * as WebPushSubscription from './web_push_subscription';
|
||
7 years ago
|
import Mastodon from 'flavours/glitch/containers/mastodon';
|
||
7 years ago
|
import React from 'react';
|
||
|
import ReactDOM from 'react-dom';
|
||
8 years ago
|
import ready from './ready';
|
||
8 years ago
|
|
||
8 years ago
|
const perf = require('./performance');
|
||
8 years ago
|
|
||
|
function main() {
|
||
8 years ago
|
perf.start('main()');
|
||
8 years ago
|
|
||
8 years ago
|
if (window.history && history.replaceState) {
|
||
|
const { pathname, search, hash } = window.location;
|
||
|
const path = pathname + search + hash;
|
||
|
if (!(/^\/web[$/]/).test(path)) {
|
||
|
history.replaceState(null, document.title, `/web${path}`);
|
||
|
}
|
||
|
}
|
||
|
|
||
8 years ago
|
ready(() => {
|
||
8 years ago
|
const mountNode = document.getElementById('mastodon');
|
||
|
const props = JSON.parse(mountNode.getAttribute('data-props'));
|
||
|
|
||
|
ReactDOM.render(<Mastodon {...props} />, mountNode);
|
||
8 years ago
|
if (process.env.NODE_ENV === 'production') {
|
||
|
// avoid offline in dev mode because it's harder to debug
|
||
7 years ago
|
require('offline-plugin/runtime').install();
|
||
8 years ago
|
WebPushSubscription.register();
|
||
|
}
|
||
8 years ago
|
perf.stop('main()');
|
||
8 years ago
|
|
||
|
// remember the initial URL
|
||
|
if (window.history && typeof window._mastoInitialHistoryLen === 'undefined') {
|
||
|
window._mastoInitialHistoryLen = window.history.length;
|
||
|
}
|
||
8 years ago
|
});
|
||
|
}
|
||
|
|
||
8 years ago
|
export default main;
|