make MatrixClientPeg an actual global too otherwise things go very wierd
parent
8af6c2275b
commit
9fb5702c2f
|
@ -59,23 +59,23 @@ if (localStorage) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
class MatrixClient {
|
||||||
get: function() {
|
get() {
|
||||||
return matrixClient;
|
return matrixClient;
|
||||||
},
|
}
|
||||||
|
|
||||||
unset: function() {
|
unset() {
|
||||||
matrixClient = null;
|
matrixClient = null;
|
||||||
},
|
}
|
||||||
|
|
||||||
replaceUsingUrls: function(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
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
replaceUsingAccessToken: function(hs_url, is_url, user_id, access_token) {
|
replaceUsingAccessToken(hs_url, is_url, user_id, access_token) {
|
||||||
if (localStorage) {
|
if (localStorage) {
|
||||||
try {
|
try {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
|
@ -97,5 +97,9 @@ module.exports = {
|
||||||
console.warn("No local storage available: can't persist session!");
|
console.warn("No local storage available: can't persist session!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
if (!global.mxMatrixClient) {
|
||||||
|
global.mxMatrixClient = new MatrixClient();
|
||||||
|
}
|
||||||
|
module.exports = global.mxMatrixClient;
|
||||||
|
|
Loading…
Reference in New Issue