store the custom HS/IS URL in local storage, add some review commentary
parent
02ad2b5152
commit
5fea3c2673
|
@ -68,11 +68,33 @@ class MatrixClient {
|
||||||
matrixClient = null;
|
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) {
|
replaceUsingUrls(hs_url, is_url) {
|
||||||
matrixClient = Matrix.createClient({
|
matrixClient = Matrix.createClient({
|
||||||
baseUrl: hs_url,
|
baseUrl: hs_url,
|
||||||
idBaseUrl: is_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) {
|
replaceUsingAccessToken(hs_url, is_url, user_id, access_token) {
|
||||||
|
|
|
@ -48,6 +48,7 @@ module.exports = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// XXX: horrible naming due to potential confusion between the word 'is' and the acronym 'IS'
|
||||||
isChanged: function(ev) {
|
isChanged: function(ev) {
|
||||||
this.setState({is_url: ev.target.value}, function() {
|
this.setState({is_url: ev.target.value}, function() {
|
||||||
this.props.onIsUrlChanged(this.state.is_url);
|
this.props.onIsUrlChanged(this.state.is_url);
|
||||||
|
|
|
@ -35,6 +35,7 @@ module.exports = {
|
||||||
|
|
||||||
onHSChosen: function() {
|
onHSChosen: function() {
|
||||||
MatrixClientPeg.replaceUsingUrls(
|
MatrixClientPeg.replaceUsingUrls(
|
||||||
|
// XXX: why is the controller invoking methods from the view? :( -matthew
|
||||||
this.getHsUrl(),
|
this.getHsUrl(),
|
||||||
this.getIsUrl()
|
this.getIsUrl()
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue