From 7b3df49c7ff6b331d1e3c6edc0488d6d2f1ab59d Mon Sep 17 00:00:00 2001 From: Isla Koenigsknecht Date: Tue, 2 Apr 2024 10:20:39 -0400 Subject: [PATCH] Fix issue of duplicate CRSs being generated --- CHANGELOG.md | 2 ++ .../storage/certifacteRequests/certificatesRequestsStore.ts | 1 + packages/backend/src/nest/storage/storage.service.ts | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5ad80e5c2..dcc0e8492c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ # Fixes: +* Don't create duplicate CSRs when joining a community under certain circumstances ([#2321](https://github.com/TryQuiet/quiet/issues/2321)) + [2.2.0] # New features: diff --git a/packages/backend/src/nest/storage/certifacteRequests/certificatesRequestsStore.ts b/packages/backend/src/nest/storage/certifacteRequests/certificatesRequestsStore.ts index 5c30871d59..ce32cbe387 100644 --- a/packages/backend/src/nest/storage/certifacteRequests/certificatesRequestsStore.ts +++ b/packages/backend/src/nest/storage/certifacteRequests/certificatesRequestsStore.ts @@ -29,6 +29,7 @@ export class CertificatesRequestsStore extends EventEmitter { write: ['*'], }, }) + await this.store.load() this.store.events.on('write', async (_address, entry) => { this.logger('Added CSR to database') diff --git a/packages/backend/src/nest/storage/storage.service.ts b/packages/backend/src/nest/storage/storage.service.ts index 1d9ba7eafe..5f353a3119 100644 --- a/packages/backend/src/nest/storage/storage.service.ts +++ b/packages/backend/src/nest/storage/storage.service.ts @@ -314,7 +314,7 @@ export class StorageService extends EventEmitter { public async updatePeersList() { const users = this.getAllUsers() - const peers = users.map(peer => createLibp2pAddress(peer.onionAddress, peer.peerId)) + const peers = Array.from(new Set(users.map(peer => createLibp2pAddress(peer.onionAddress, peer.peerId)))) console.log('updatePeersList, peers count:', peers.length) const community = await this.localDbService.getCurrentCommunity()