Fix welcome user
https://github.com/matrix-org/matrix-react-sdk/pull/3101 meant we don't get logged straight in after registering if using an email address, but this was the point at which we made a chat with the welcome user. Instead, set a flag in memory that we should try & make a chat with the welcome user for that user ID if we get a session for them. Of course, if the user logs in on both tabs, this would mean each would make a chat with the welcome user (although actually this was a problem with the old code too). Check our m.direct to see if we've started a chat with the welcome user before making one (which also means we have to make sure the cached sync is up to date... see comments).
This commit is contained in:
parent
2a7301fa8f
commit
8fa50b26a6
3 changed files with 85 additions and 18 deletions
|
@ -51,6 +51,7 @@ interface MatrixClientCreds {
|
|||
class MatrixClientPeg {
|
||||
constructor() {
|
||||
this.matrixClient = null;
|
||||
this._justRegisteredUserId = null;
|
||||
|
||||
// These are the default options used when when the
|
||||
// client is started in 'start'. These can be altered
|
||||
|
@ -85,6 +86,31 @@ class MatrixClientPeg {
|
|||
MatrixActionCreators.stop();
|
||||
}
|
||||
|
||||
/*
|
||||
* If we've registered a user ID we set this to the ID of the
|
||||
* user we've just registered. If they then go & log in, we
|
||||
* can send them to the welcome user (obviously this doesn't
|
||||
* guarentee they'll get a chat with the welcome user).
|
||||
*
|
||||
* @param {string} uid The user ID of the user we've just registered
|
||||
*/
|
||||
setJustRegisteredUserId(uid) {
|
||||
this._justRegisteredUserId = uid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if the current user has just been registered by this
|
||||
* client as determined by setJustRegisteredUserId()
|
||||
*
|
||||
* @returns {bool} True if user has just been registered
|
||||
*/
|
||||
currentUserIsJustRegistered() {
|
||||
return (
|
||||
this.matrixClient &&
|
||||
this.matrixClient.credentials.userId === this._justRegisteredUserId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace this MatrixClientPeg's client with a client instance that has
|
||||
* homeserver / identity server URLs and active credentials
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue