Merge branch 'develop' into experimental
This commit is contained in:
commit
22a1a7343b
22 changed files with 458 additions and 210 deletions
|
@ -24,6 +24,8 @@ require('gfm.css/gfm.css');
|
|||
require('highlight.js/styles/github.css');
|
||||
require('draft-js/dist/Draft.css');
|
||||
|
||||
import './rageshakesetup';
|
||||
|
||||
import React from 'react';
|
||||
// add React and ReactPerf to the global namespace, to make them easier to
|
||||
// access via the console
|
||||
|
@ -32,7 +34,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|||
global.Perf = require('react-addons-perf');
|
||||
}
|
||||
|
||||
import RunModernizrTests from './modernizr'; // this side-effects a global
|
||||
import './modernizr';
|
||||
import ReactDOM from 'react-dom';
|
||||
import sdk from 'matrix-react-sdk';
|
||||
import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg';
|
||||
|
@ -41,8 +43,6 @@ import VectorConferenceHandler from 'matrix-react-sdk/lib/VectorConferenceHandle
|
|||
import Promise from 'bluebird';
|
||||
import request from 'browser-request';
|
||||
import * as languageHandler from 'matrix-react-sdk/lib/languageHandler';
|
||||
// Also import _t directly so we can call it just `_t` as this is what gen-i18n.js expects
|
||||
import { _t } from 'matrix-react-sdk/lib/languageHandler';
|
||||
|
||||
import url from 'url';
|
||||
|
||||
|
@ -50,14 +50,12 @@ import {parseQs, parseQsFromFragment} from './url_utils';
|
|||
import Platform from './platform';
|
||||
|
||||
import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
|
||||
import SettingsStore, {SettingLevel} from "matrix-react-sdk/lib/settings/SettingsStore";
|
||||
import SettingsStore from "matrix-react-sdk/lib/settings/SettingsStore";
|
||||
import Tinter from 'matrix-react-sdk/lib/Tinter';
|
||||
import SdkConfig from "matrix-react-sdk/lib/SdkConfig";
|
||||
|
||||
import Olm from 'olm';
|
||||
|
||||
import rageshake from "matrix-react-sdk/lib/rageshake/rageshake";
|
||||
|
||||
import CallHandler from 'matrix-react-sdk/lib/CallHandler';
|
||||
|
||||
import {getVectorConfig} from './getconfig';
|
||||
|
@ -68,33 +66,17 @@ let lastLocationHashSet = null;
|
|||
// and need to migrate, but they spam the console with warnings.
|
||||
Promise.config({warnings: false});
|
||||
|
||||
function initRageshake() {
|
||||
rageshake.init().then(() => {
|
||||
console.log("Initialised rageshake: See https://bugs.chromium.org/p/chromium/issues/detail?id=583193 to fix line numbers on Chrome.");
|
||||
|
||||
window.addEventListener('beforeunload', (e) => {
|
||||
console.log('riot-web closing');
|
||||
// try to flush the logs to indexeddb
|
||||
rageshake.flush();
|
||||
});
|
||||
|
||||
rageshake.cleanup();
|
||||
}, (err) => {
|
||||
console.error("Failed to initialise rageshake: " + err);
|
||||
});
|
||||
}
|
||||
|
||||
function checkBrowserFeatures(featureList) {
|
||||
if (!window.Modernizr) {
|
||||
console.error("Cannot check features - Modernizr global is missing.");
|
||||
return false;
|
||||
}
|
||||
var featureComplete = true;
|
||||
for (var i = 0; i < featureList.length; i++) {
|
||||
let featureComplete = true;
|
||||
for (let i = 0; i < featureList.length; i++) {
|
||||
if (window.Modernizr[featureList[i]] === undefined) {
|
||||
console.error(
|
||||
"Looked for feature '%s' but Modernizr has no results for this. " +
|
||||
"Has it been configured correctly?", featureList[i]
|
||||
"Has it been configured correctly?", featureList[i],
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
@ -115,7 +97,7 @@ function getScreenFromLocation(location) {
|
|||
return {
|
||||
screen: fragparts.location.substring(1),
|
||||
params: fragparts.params,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Here, we do some crude URL analysis to allow
|
||||
|
@ -140,10 +122,10 @@ function onHashChange(ev) {
|
|||
// so a web page can update the URL bar appropriately.
|
||||
function onNewScreen(screen) {
|
||||
console.log("newscreen "+screen);
|
||||
var hash = '#/' + screen;
|
||||
const hash = '#/' + screen;
|
||||
lastLocationHashSet = hash;
|
||||
window.location.hash = hash;
|
||||
};
|
||||
}
|
||||
|
||||
// We use this to work out what URL the SDK should
|
||||
// pass through when registering to allow the user to
|
||||
|
@ -180,7 +162,7 @@ function makeRegistrationUrl(params) {
|
|||
return url;
|
||||
}
|
||||
|
||||
function getConfig(configJsonFilename) {
|
||||
export function getConfig(configJsonFilename) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
request(
|
||||
{ method: "GET", url: configJsonFilename },
|
||||
|
@ -216,16 +198,15 @@ function onTokenLoginCompleted() {
|
|||
// if we did a token login, we're now left with the token, hs and is
|
||||
// url as query params in the url; a little nasty but let's redirect to
|
||||
// clear them.
|
||||
var parsedUrl = url.parse(window.location.href);
|
||||
const parsedUrl = url.parse(window.location.href);
|
||||
parsedUrl.search = "";
|
||||
var formatted = url.format(parsedUrl);
|
||||
const formatted = url.format(parsedUrl);
|
||||
console.log("Redirecting to " + formatted + " to drop loginToken " +
|
||||
"from queryparams");
|
||||
window.location.href = formatted;
|
||||
}
|
||||
|
||||
async function loadApp() {
|
||||
initRageshake();
|
||||
MatrixClientPeg.setIndexedDbWorkerScript(window.vector_indexeddb_worker_script);
|
||||
CallHandler.setConferenceHandler(VectorConferenceHandler);
|
||||
|
||||
|
@ -273,7 +254,6 @@ async function loadApp() {
|
|||
}
|
||||
|
||||
// as quickly as we possibly can, set a default theme...
|
||||
const styleElements = Object.create(null);
|
||||
let a;
|
||||
const theme = "dharma";//SettingsStore.getValue("theme");
|
||||
for (let i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
|
||||
|
@ -297,7 +277,7 @@ async function loadApp() {
|
|||
// in case it is the first time loading Riot.
|
||||
// `InstallTrigger` is a Object which only exists on Firefox
|
||||
// (it is used for their Plugins) and can be used as a
|
||||
// feature check.
|
||||
// feature check.
|
||||
// Firefox loads css always before js. This is why we dont use
|
||||
// onload or it's EventListener as thoose will never trigger.
|
||||
if (typeof InstallTrigger !== 'undefined') {
|
||||
|
@ -349,19 +329,19 @@ async function loadApp() {
|
|||
initialScreenAfterLogin={getScreenFromLocation(window.location)}
|
||||
defaultDeviceDisplayName={platform.getDefaultDeviceDisplayName()}
|
||||
/>,
|
||||
document.getElementById('matrixchat')
|
||||
document.getElementById('matrixchat'),
|
||||
);
|
||||
} else {
|
||||
console.error("Browser is missing required features.");
|
||||
// take to a different landing page to AWOOOOOGA at the user
|
||||
var CompatibilityPage = sdk.getComponent("structures.CompatibilityPage");
|
||||
const CompatibilityPage = sdk.getComponent("structures.CompatibilityPage");
|
||||
window.matrixChat = ReactDOM.render(
|
||||
<CompatibilityPage onAccept={function() {
|
||||
if (window.localStorage) window.localStorage.setItem('mx_accepts_unsupported_browser', true);
|
||||
console.log("User accepts the compatibility risks.");
|
||||
loadApp();
|
||||
}} />,
|
||||
document.getElementById('matrixchat')
|
||||
document.getElementById('matrixchat'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue