Add an interface for MatrixClientCreds
and make MatrixClientPeg functions use it consistently
This commit is contained in:
parent
cf7e7d65c8
commit
d9a7d50a03
3 changed files with 25 additions and 11 deletions
|
@ -31,6 +31,14 @@ function deviceId() {
|
|||
return id;
|
||||
}
|
||||
|
||||
interface MatrixClientCreds {
|
||||
homeserverUrl: string,
|
||||
identityServerUrl: string,
|
||||
userId: string,
|
||||
accessToken: string,
|
||||
guest: boolean,
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper object for handling the js-sdk Matrix Client object in the react-sdk
|
||||
* Handles the creation/initialisation of client objects.
|
||||
|
@ -70,8 +78,14 @@ class MatrixClientPeg {
|
|||
* Replace this MatrixClientPeg's client with a client instance that has
|
||||
* Home Server / Identity Server URLs and active credentials
|
||||
*/
|
||||
replaceUsingAccessToken(hs_url, is_url, user_id, access_token, isGuest) {
|
||||
this._replaceClient(hs_url, is_url, user_id, access_token, isGuest);
|
||||
replaceUsingCreds(creds: MatrixClientCreds) {
|
||||
this._replaceClient(
|
||||
creds.homeserverUrl,
|
||||
creds.identityServerUrl,
|
||||
creds.userId,
|
||||
creds.accessToken,
|
||||
creds.guest,
|
||||
);
|
||||
}
|
||||
|
||||
_replaceClient(hs_url, is_url, user_id, access_token, isGuest) {
|
||||
|
@ -103,7 +117,7 @@ class MatrixClientPeg {
|
|||
}
|
||||
}
|
||||
|
||||
getCredentials() {
|
||||
getCredentials(): MatrixClientCreds {
|
||||
return {
|
||||
homeserverUrl: this.matrixClient.baseUrl,
|
||||
identityServerUrl: this.matrixClient.idBaseUrl,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue