diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index 62c49a5f2d..d940b69f27 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -68,11 +68,33 @@ class MatrixClient { matrixClient = null; } + // FIXME, XXX: this all seems very convoluted :( + // + // if we replace the singleton using URLs we bypass our createClient() + // global helper function... but if we replace it using + // an access_token we don't? + // + // Why do we have this peg wrapper rather than just MatrixClient.get()? + // Why do we name MatrixClient as MatrixClientPeg when we export it? + // + // -matthew + replaceUsingUrls(hs_url, is_url) { matrixClient = Matrix.createClient({ baseUrl: hs_url, idBaseUrl: is_url }); + // XXX: factor this out with the localStorage setting in replaceUsingAccessToken + if (localStorage) { + try { + localStorage.setItem("mx_hs_url", hs_url); + localStorage.setItem("mx_is_url", is_url); + } catch (e) { + console.warn("Error using local storage: can't persist HS/IS URLs!"); + } + } else { + console.warn("No local storage available: can't persist HS/IS URLs!"); + } } replaceUsingAccessToken(hs_url, is_url, user_id, access_token) { diff --git a/src/controllers/molecules/ServerConfig.js b/src/controllers/molecules/ServerConfig.js index 3f5dd99bb5..06d7ffd3e1 100644 --- a/src/controllers/molecules/ServerConfig.js +++ b/src/controllers/molecules/ServerConfig.js @@ -48,6 +48,7 @@ module.exports = { }); }, + // XXX: horrible naming due to potential confusion between the word 'is' and the acronym 'IS' isChanged: function(ev) { this.setState({is_url: ev.target.value}, function() { this.props.onIsUrlChanged(this.state.is_url); diff --git a/src/controllers/templates/Login.js b/src/controllers/templates/Login.js index 3472bf32ce..f2e9df2929 100644 --- a/src/controllers/templates/Login.js +++ b/src/controllers/templates/Login.js @@ -35,6 +35,7 @@ module.exports = { onHSChosen: function() { MatrixClientPeg.replaceUsingUrls( + // XXX: why is the controller invoking methods from the view? :( -matthew this.getHsUrl(), this.getIsUrl() );