2017-11-30 22:41:09 +01:00
|
|
|
import 'fluent-intl-polyfill';
|
2017-08-24 23:54:02 +02:00
|
|
|
import app from './routes';
|
|
|
|
import locale from '../common/locales';
|
|
|
|
import fileManager from './fileManager';
|
|
|
|
import dragManager from './dragManager';
|
|
|
|
import { canHasSend } from './utils';
|
|
|
|
import assets from '../common/assets';
|
|
|
|
import storage from './storage';
|
|
|
|
import metrics from './metrics';
|
2017-09-12 02:09:29 +02:00
|
|
|
import experiments from './experiments';
|
2017-08-24 23:54:02 +02:00
|
|
|
import Raven from 'raven-js';
|
|
|
|
|
|
|
|
if (navigator.doNotTrack !== '1' && window.RAVEN_CONFIG) {
|
|
|
|
Raven.config(window.SENTRY_ID, window.RAVEN_CONFIG).install();
|
|
|
|
}
|
|
|
|
|
|
|
|
app.use((state, emitter) => {
|
|
|
|
state.transfer = null;
|
|
|
|
state.fileInfo = null;
|
|
|
|
state.translate = locale.getTranslator();
|
|
|
|
state.storage = storage;
|
|
|
|
state.raven = Raven;
|
2018-01-24 19:23:13 +01:00
|
|
|
window.appState = state;
|
|
|
|
emitter.on('DOMContentLoaded', async function checkSupport() {
|
|
|
|
let unsupportedReason = null;
|
2017-09-13 21:01:55 +02:00
|
|
|
if (
|
2018-01-24 19:23:13 +01:00
|
|
|
// Firefox < 50
|
2017-09-13 21:01:55 +02:00
|
|
|
/firefox/i.test(navigator.userAgent) &&
|
2018-01-24 19:23:13 +01:00
|
|
|
parseInt(navigator.userAgent.match(/firefox\/*([^\n\r]*)\./i)[1], 10) < 50
|
2017-09-13 21:01:55 +02:00
|
|
|
) {
|
2018-01-24 19:23:13 +01:00
|
|
|
unsupportedReason = 'outdated';
|
2017-09-13 21:01:55 +02:00
|
|
|
}
|
2017-11-06 22:36:36 +01:00
|
|
|
if (/edge\/\d+/i.test(navigator.userAgent)) {
|
2018-01-24 19:23:13 +01:00
|
|
|
unsupportedReason = 'edge';
|
2017-11-06 22:36:36 +01:00
|
|
|
}
|
2017-08-24 23:54:02 +02:00
|
|
|
const ok = await canHasSend(assets.get('cryptofill.js'));
|
|
|
|
if (!ok) {
|
2018-01-24 19:23:13 +01:00
|
|
|
unsupportedReason = /firefox/i.test(navigator.userAgent)
|
|
|
|
? 'outdated'
|
|
|
|
: 'gcm';
|
2017-11-06 23:09:15 +01:00
|
|
|
}
|
2018-01-24 19:23:13 +01:00
|
|
|
if (unsupportedReason) {
|
|
|
|
setTimeout(() =>
|
|
|
|
emitter.emit('replaceState', `/unsupported/${unsupportedReason}`)
|
|
|
|
);
|
2017-08-24 23:54:02 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
app.use(metrics);
|
|
|
|
app.use(fileManager);
|
|
|
|
app.use(dragManager);
|
2017-09-12 02:09:29 +02:00
|
|
|
app.use(experiments);
|
2017-08-24 23:54:02 +02:00
|
|
|
|
2017-11-08 00:54:42 +01:00
|
|
|
app.mount('body');
|