store the custom HS/IS URL in local storage, add some review commentary

pull/21833/head
Matthew Hodgson 2015-11-10 19:10:30 +00:00
parent 02ad2b5152
commit 5fea3c2673
3 changed files with 24 additions and 0 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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()
);