1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-06 12:02:40 +03:00

Remove Crypto.start() (#2871)

This isn't really needed, and its semantics are poorly defined. (Contrary to
the comment, it dos *not* set background processes running).
This commit is contained in:
Richard van der Hoff
2022-11-14 10:01:05 +00:00
committed by GitHub
parent ba6a001d67
commit b40cf75c9d
4 changed files with 23 additions and 11 deletions

View File

@@ -1122,4 +1122,22 @@ describe("Crypto", function() {
expect(free).toHaveBeenCalled(); expect(free).toHaveBeenCalled();
}); });
}); });
describe("start", () => {
let client: TestClient;
beforeEach(async () => {
client = new TestClient("@alice:example.org", "aliceweb");
await client.client.initCrypto();
});
afterEach(async function() {
await client!.stop();
});
// start() is a no-op nowadays, so there's not much to test here.
it("should complete successfully", async () => {
await client!.client.crypto!.start();
});
});
}); });

View File

@@ -1200,7 +1200,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
if (this.crypto) { if (this.crypto) {
this.crypto.uploadDeviceKeys(); this.crypto.uploadDeviceKeys();
this.crypto.start();
} }
// periodically poll for turn servers if we support voip // periodically poll for turn servers if we support voip

View File

@@ -100,7 +100,7 @@ export class OutgoingRoomKeyRequestManager {
// of sendOutgoingRoomKeyRequests // of sendOutgoingRoomKeyRequests
private sendOutgoingRoomKeyRequestsRunning = false; private sendOutgoingRoomKeyRequestsRunning = false;
private clientRunning = false; private clientRunning = true;
constructor( constructor(
private readonly baseApis: MatrixClient, private readonly baseApis: MatrixClient,
@@ -108,13 +108,6 @@ export class OutgoingRoomKeyRequestManager {
private readonly cryptoStore: CryptoStore, private readonly cryptoStore: CryptoStore,
) {} ) {}
/**
* Called when the client is started. Sets background processes running.
*/
public start(): void {
this.clientRunning = true;
}
/** /**
* Called when the client is stopped. Stops any running background processes. * Called when the client is stopped. Stops any running background processes.
*/ */

View File

@@ -1775,9 +1775,11 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
eventEmitter.on(MatrixEventEvent.Decrypted, this.onTimelineEvent); eventEmitter.on(MatrixEventEvent.Decrypted, this.onTimelineEvent);
} }
/** Start background processes related to crypto */ /**
* @deprecated this does nothing and will be removed in a future version
*/
public start(): void { public start(): void {
this.outgoingRoomKeyRequestManager.start(); logger.warn("MatrixClient.crypto.start() is deprecated");
} }
/** Stop background processes related to crypto */ /** Stop background processes related to crypto */