mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
refactor logout in client so we don't need a fully loaded session
instead, we pass the session id in this will make it easier to first dispose the client when leaving the /session/<id> and just creating a client without fully loading it to log out. This way sync is already not running anymore.
This commit is contained in:
parent
164d72830f
commit
c6c1d3b3d8
@ -386,10 +386,21 @@ export class Client {
|
||||
return !this._reconnector;
|
||||
}
|
||||
|
||||
logout() {
|
||||
startLogout(sessionId) {
|
||||
return this._platform.logger.run("logout", async log => {
|
||||
this._sessionId = sessionId;
|
||||
log.set("id", this._sessionId);
|
||||
const sessionInfo = await this._platform.sessionInfoStorage.get(this._sessionId);
|
||||
if (!sessionInfo) {
|
||||
throw new Error(`Could not find session for id ${this._sessionId}`);
|
||||
}
|
||||
try {
|
||||
await this._session?.logout(log);
|
||||
const hsApi = new HomeServerApi({
|
||||
homeserver: sessionInfo.homeServer,
|
||||
accessToken: sessionInfo.accessToken,
|
||||
request: this._platform.request
|
||||
});
|
||||
await hsApi.logout({log}).response();
|
||||
} catch (err) {}
|
||||
await this.deleteSession(log);
|
||||
});
|
||||
|
@ -109,11 +109,6 @@ export class Session {
|
||||
return this._sessionInfo.userId;
|
||||
}
|
||||
|
||||
/** @internal call Client.logout instead */
|
||||
async logout(log = undefined) {
|
||||
await this._hsApi.logout({log}).response();
|
||||
}
|
||||
|
||||
// called once this._e2eeAccount is assigned
|
||||
_setupEncryption() {
|
||||
// TODO: this should all go in a wrapper in e2ee/ that is bootstrapped by passing in the account
|
||||
|
Loading…
Reference in New Issue
Block a user