simplified app/main.js a bit
This commit is contained in:
parent
4557a352f8
commit
b1db7ac312
26
app/main.js
26
app/main.js
|
@ -27,6 +27,9 @@ if (process.env.NODE_ENV === 'production') {
|
||||||
|
|
||||||
(async function start() {
|
(async function start() {
|
||||||
const capabilities = await getCapabilities();
|
const capabilities = await getCapabilities();
|
||||||
|
if (!capabilities.crypto) {
|
||||||
|
return window.location.assign('/unsupported/crypto');
|
||||||
|
}
|
||||||
if (capabilities.serviceWorker) {
|
if (capabilities.serviceWorker) {
|
||||||
await navigator.serviceWorker.register('/serviceWorker.js');
|
await navigator.serviceWorker.register('/serviceWorker.js');
|
||||||
await navigator.serviceWorker.ready;
|
await navigator.serviceWorker.ready;
|
||||||
|
@ -44,29 +47,6 @@ if (process.env.NODE_ENV === 'production') {
|
||||||
};
|
};
|
||||||
|
|
||||||
const app = routes(choo());
|
const app = routes(choo());
|
||||||
app.use((state, emitter) => {
|
|
||||||
window.appState = state;
|
|
||||||
window.appEmit = emitter.emit.bind(emitter);
|
|
||||||
let unsupportedReason = null;
|
|
||||||
|
|
||||||
if (
|
|
||||||
// Firefox < 50
|
|
||||||
/firefox/i.test(navigator.userAgent) &&
|
|
||||||
parseInt(navigator.userAgent.match(/firefox\/*([^\n\r]*)\./i)[1], 10) < 50
|
|
||||||
) {
|
|
||||||
unsupportedReason = 'outdated';
|
|
||||||
}
|
|
||||||
if (!state.capabilities.crypto) {
|
|
||||||
unsupportedReason = /firefox/i.test(navigator.userAgent)
|
|
||||||
? 'outdated'
|
|
||||||
: 'gcm';
|
|
||||||
}
|
|
||||||
if (unsupportedReason) {
|
|
||||||
setTimeout(() =>
|
|
||||||
emitter.emit('replaceState', `/unsupported/${unsupportedReason}`)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
app.use(metrics);
|
app.use(metrics);
|
||||||
app.use(controller);
|
app.use(controller);
|
||||||
app.use(dragManager);
|
app.use(dragManager);
|
||||||
|
|
|
@ -39,8 +39,16 @@ module.exports = function(state) {
|
||||||
var isIE = /trident\\\/7\.|msie/i.test(navigator.userAgent);
|
var isIE = /trident\\\/7\.|msie/i.test(navigator.userAgent);
|
||||||
var isUnsupportedPage = /\\\/unsupported/.test(location.pathname);
|
var isUnsupportedPage = /\\\/unsupported/.test(location.pathname);
|
||||||
if (isIE && !isUnsupportedPage) {
|
if (isIE && !isUnsupportedPage) {
|
||||||
window.location.replace('/unsupported/ie');
|
window.location.assign('/unsupported/ie');
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
// Firefox < 50
|
||||||
|
/firefox/i.test(navigator.userAgent) &&
|
||||||
|
parseInt(navigator.userAgent.match(/firefox\\/*([^\\n\\r]*)\./i)[1], 10) < 50
|
||||||
|
) {
|
||||||
|
window.location.assign('/unsupported/outdated');
|
||||||
|
}
|
||||||
|
|
||||||
var LIMITS = {
|
var LIMITS = {
|
||||||
ANON: {
|
ANON: {
|
||||||
MAX_FILE_SIZE: ${config.anon_max_file_size},
|
MAX_FILE_SIZE: ${config.anon_max_file_size},
|
||||||
|
|
Loading…
Reference in New Issue