fix: check null encodedKeyPair in onKeyPairChange

This commit is contained in:
Shibo Lyu 2025-04-02 00:30:10 +08:00
parent 82f0fc35b0
commit 5a7641b4d6

View file

@ -52,8 +52,8 @@ class ChatServerConnectionPool {
this.connections.clear();
}
private async onKeyPairChange(encodedKeyPair: EncodedBlahKeyPair) {
this.keypair = await BlahKeyPair.fromEncoded(encodedKeyPair);
private async onKeyPairChange(encodedKeyPair: EncodedBlahKeyPair | null) {
this.keypair = encodedKeyPair ? await BlahKeyPair.fromEncoded(encodedKeyPair) : null;
for (const connection of this.connections.values()) {
connection.changeKeyPair(this.keypair);
connection.connect();