diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js
index a8e20f5ec14..96934d205e6 100644
--- a/src/HtmlUtils.js
+++ b/src/HtmlUtils.js
@@ -25,6 +25,9 @@ import emojione from 'emojione';
import classNames from 'classnames';
emojione.imagePathSVG = 'emojione/svg/';
+// Store PNG path for displaying many flags at once (for increased performance over SVG)
+emojione.imagePathPNG = 'emojione/png/';
+// Use SVGs for emojis
emojione.imageType = 'svg';
const EMOJI_REGEX = new RegExp(emojione.unicodeRegexp+"+", "gi");
@@ -64,16 +67,23 @@ export function unicodeToImage(str) {
* emoji.
*
* @param alt {string} String to use for the image alt text
+ * @param useSvg {boolean} Whether to use SVG image src. If False, PNG will be used.
* @param unicode {integer} One or more integers representing unicode characters
* @returns A img node with the corresponding emoji
*/
-export function charactersToImageNode(alt, ...unicode) {
+export function charactersToImageNode(alt, useSvg, ...unicode) {
const fileName = unicode.map((u) => {
return u.toString(16);
}).join('-');
- return ;
+ const path = useSvg ? emojione.imagePathSVG : emojione.imagePathPNG;
+ const fileType = useSvg ? 'svg' : 'png';
+ return ;
}
+
export function stripParagraphs(html: string): string {
const contentDiv = document.createElement('div');
contentDiv.innerHTML = html;
diff --git a/src/components/structures/login/Login.js b/src/components/structures/login/Login.js
index 7e1a5f9d35c..315a0ea2425 100644
--- a/src/components/structures/login/Login.js
+++ b/src/components/structures/login/Login.js
@@ -17,13 +17,11 @@ limitations under the License.
'use strict';
-var React = require('react');
-var ReactDOM = require('react-dom');
-var sdk = require('../../../index');
-var Login = require("../../../Login");
-var PasswordLogin = require("../../views/login/PasswordLogin");
-var CasLogin = require("../../views/login/CasLogin");
-var ServerConfig = require("../../views/login/ServerConfig");
+import React from 'react';
+import ReactDOM from 'react-dom';
+import url from 'url';
+import sdk from '../../../index';
+import Login from '../../../Login';
/**
* A wire component which glues together login UI components and Login logic
@@ -67,6 +65,7 @@ module.exports = React.createClass({
username: "",
phoneCountry: null,
phoneNumber: "",
+ currentFlow: "m.login.password",
};
},
@@ -129,23 +128,19 @@ module.exports = React.createClass({
this.setState({ phoneNumber: phoneNumber });
},
- onHsUrlChanged: function(newHsUrl) {
+ onServerConfigChange: function(config) {
var self = this;
- this.setState({
- enteredHomeserverUrl: newHsUrl,
- errorText: null, // reset err messages
- }, function() {
- self._initLoginLogic(newHsUrl);
- });
- },
-
- onIsUrlChanged: function(newIsUrl) {
- var self = this;
- this.setState({
- enteredIdentityServerUrl: newIsUrl,
+ let newState = {
errorText: null, // reset err messages
- }, function() {
- self._initLoginLogic(null, newIsUrl);
+ };
+ if (config.hsUrl !== undefined) {
+ newState.enteredHomeserverUrl = config.hsUrl;
+ }
+ if (config.isUrl !== undefined) {
+ newState.enteredIdentityServerUrl = config.isUrl;
+ }
+ this.setState(newState, function() {
+ self._initLoginLogic(config.hsUrl || null, config.isUrl);
});
},
@@ -161,25 +156,28 @@ module.exports = React.createClass({
});
this._loginLogic = loginLogic;
+ this.setState({
+ enteredHomeserverUrl: hsUrl,
+ enteredIdentityServerUrl: isUrl,
+ busy: true,
+ loginIncorrect: false,
+ });
+
loginLogic.getFlows().then(function(flows) {
// old behaviour was to always use the first flow without presenting
// options. This works in most cases (we don't have a UI for multiple
// logins so let's skip that for now).
loginLogic.chooseFlow(0);
+ self.setState({
+ currentFlow: self._getCurrentFlowStep(),
+ });
}, function(err) {
self._setStateFromError(err, false);
}).finally(function() {
self.setState({
- busy: false
+ busy: false,
});
});
-
- this.setState({
- enteredHomeserverUrl: hsUrl,
- enteredIdentityServerUrl: isUrl,
- busy: true,
- loginIncorrect: false,
- });
},
_getCurrentFlowStep: function() {
@@ -231,6 +229,13 @@ module.exports = React.createClass({
componentForStep: function(step) {
switch (step) {
case 'm.login.password':
+ const PasswordLogin = sdk.getComponent('login.PasswordLogin');
+ // HSs that are not matrix.org may not be configured to have their
+ // domain name === domain part.
+ let hsDomain = url.parse(this.state.enteredHomeserverUrl).hostname;
+ if (hsDomain !== 'matrix.org') {
+ hsDomain = null;
+ }
return (