Merge pull request #358 from matrix-org/rav/device_id_for_register

Set the device_id on pre-login MatrixClient
This commit is contained in:
David Baker 2016-07-21 13:15:39 +01:00 committed by GitHub
commit 46a2c74d71

View file

@ -97,35 +97,20 @@ class MatrixClient {
// FIXME, XXX: this all seems very convoluted :( // FIXME, XXX: this all seems very convoluted :(
// //
// if we replace the singleton using URLs we bypass our createClientForPeg()
// 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 have this peg wrapper rather than just MatrixClient.get()?
// Why do we name MatrixClient as MatrixClientPeg when we export it? // Why do we name MatrixClient as MatrixClientPeg when we export it?
// //
// -matthew // -matthew
replaceUsingUrls(hs_url, is_url) { replaceUsingUrls(hs_url, is_url) {
matrixClient = Matrix.createClient({ this.replaceClient(hs_url, is_url);
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, isGuest) { replaceUsingAccessToken(hs_url, is_url, user_id, access_token, isGuest) {
this.replaceClient(hs_url, is_url, user_id, access_token, isGuest);
}
replaceClient(hs_url, is_url, user_id, access_token, isGuest) {
if (localStorage) { if (localStorage) {
try { try {
localStorage.clear(); localStorage.clear();