File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1204,6 +1204,8 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
12041204 * clean shutdown.
12051205 */
12061206 public stopClient ( ) {
1207+ if ( ! this . clientRunning ) return ; // already stopped
1208+
12071209 logger . log ( 'stopping MatrixClient' ) ;
12081210
12091211 this . clientRunning = false ;
@@ -7067,9 +7069,10 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
70677069 * it is up to the caller to either reset or destroy the MatrixClient after
70687070 * this method succeeds.
70697071 * @param {module:client.callback } callback Optional.
7072+ * @param {boolean } stopClient whether to stop the client before calling /logout to prevent invalid token errors.
70707073 * @return {Promise } Resolves: On success, the empty object
70717074 */
7072- public async logout ( callback ?: Callback ) : Promise < { } > {
7075+ public async logout ( callback ?: Callback , stopClient = false ) : Promise < { } > {
70737076 if ( this . crypto ?. backupManager ?. getKeyBackupEnabled ( ) ) {
70747077 try {
70757078 while ( await this . crypto . backupManager . backupPendingKeys ( 200 ) > 0 ) ;
@@ -7080,6 +7083,11 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
70807083 ) ;
70817084 }
70827085 }
7086+
7087+ if ( stopClient ) {
7088+ this . stopClient ( ) ;
7089+ }
7090+
70837091 return this . http . authedRequest (
70847092 callback , Method . Post , '/logout' ,
70857093 ) ;
You can’t perform that action at this time.
0 commit comments