From 29d289a5cc9d22261c54a5c9f25884f9b0629f4a Mon Sep 17 00:00:00 2001 From: Emi Date: Wed, 24 Apr 2024 14:10:37 +0200 Subject: [PATCH] chore: don't clear invitation data from Community --- .../connections-manager.service.ts | 3 +-- .../src/nest/local-db/local-db.service.ts | 9 --------- .../src/rtl-tests/community.create.test.tsx | 1 - .../src/rtl-tests/community.join.test.tsx | 1 - .../src/sagas/communities/communities.slice.ts | 18 +----------------- .../startConnection/startConnection.saga.ts | 2 -- 6 files changed, 2 insertions(+), 32 deletions(-) diff --git a/packages/backend/src/nest/connections-manager/connections-manager.service.ts b/packages/backend/src/nest/connections-manager/connections-manager.service.ts index 71ba24bf1..7800d75b4 100644 --- a/packages/backend/src/nest/connections-manager/connections-manager.service.ts +++ b/packages/backend/src/nest/connections-manager/connections-manager.service.ts @@ -11,7 +11,7 @@ import { CryptoEngine, setEngine } from 'pkijs' import { getLibp2pAddressesFromCsrs, removeFilesFromDir } from '../common/utils' import { LazyModuleLoader } from '@nestjs/core' -import { createLibp2pAddress, isPSKcodeValid, p2pAddressesToPairs } from '@quiet/common' +import { createLibp2pAddress, isPSKcodeValid } from '@quiet/common' import { CertFieldsTypes, getCertFieldValue, loadCertificate } from '@quiet/identity' import { ChannelMessageIdsResponse, @@ -520,7 +520,6 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI // Unblock websocket endpoints this.socketService.resolveReadyness() - await this.localDbService.deleteInviteData() this.serverIoProvider.io.emit(SocketActionTypes.COMMUNITY_LAUNCHED, { id: community.id }) } diff --git a/packages/backend/src/nest/local-db/local-db.service.ts b/packages/backend/src/nest/local-db/local-db.service.ts index 0559a057c..ba3d796ed 100644 --- a/packages/backend/src/nest/local-db/local-db.service.ts +++ b/packages/backend/src/nest/local-db/local-db.service.ts @@ -151,15 +151,6 @@ export class LocalDbService { return communityId in ((await this.getCommunities()) ?? {}) } - public async deleteInviteData() { - const community = await this.getCurrentCommunity() - if (!community) throw new Error('No community found') - if (!community.inviteData) return - this.logger(`Deleting invite data from community ${community.id}`) - const updatedCommunity = { ...community, inviteData: null } - await this.setCommunity(updatedCommunity) - } - // These are potentially temporary functions to help us migrate data to the // backend. Currently this information lives under the COMMUNITY key in // LevelDB, but on the frontend this data lives in the Identity model. So we diff --git a/packages/desktop/src/rtl-tests/community.create.test.tsx b/packages/desktop/src/rtl-tests/community.create.test.tsx index 080e23558..9d225ae66 100644 --- a/packages/desktop/src/rtl-tests/community.create.test.tsx +++ b/packages/desktop/src/rtl-tests/community.create.test.tsx @@ -164,7 +164,6 @@ describe('User', () => { "Files/checkForMissingFiles", "Network/addInitializedCommunity", "Communities/clearInvitationCodes", - "Communities/clearInvitationData", "PublicChannels/channelsReplicated", "Communities/updateCommunityData", "PublicChannels/addChannel", diff --git a/packages/desktop/src/rtl-tests/community.join.test.tsx b/packages/desktop/src/rtl-tests/community.join.test.tsx index 6be3de1e9..0f62b173e 100644 --- a/packages/desktop/src/rtl-tests/community.join.test.tsx +++ b/packages/desktop/src/rtl-tests/community.join.test.tsx @@ -180,7 +180,6 @@ describe('User', () => { "Files/checkForMissingFiles", "Network/addInitializedCommunity", "Communities/clearInvitationCodes", - "Communities/clearInvitationData", "PublicChannels/channelsReplicated", "PublicChannels/setChannelSubscribed", "PublicChannels/addChannel", diff --git a/packages/state-manager/src/sagas/communities/communities.slice.ts b/packages/state-manager/src/sagas/communities/communities.slice.ts index 2bd38c188..0e66c0e6b 100644 --- a/packages/state-manager/src/sagas/communities/communities.slice.ts +++ b/packages/state-manager/src/sagas/communities/communities.slice.ts @@ -1,15 +1,7 @@ import { createSlice, type EntityState, type PayloadAction } from '@reduxjs/toolkit' import { StoreKeys } from '../store.keys' import { communitiesAdapter } from './communities.adapter' -import { - InvitationPair, - type AddOwnerCertificatePayload, - type Community, - type CreateNetworkPayload, - type StorePeerListPayload, - CommunityMetadata, - InvitationData, -} from '@quiet/types' +import { InvitationPair, type Community, type CreateNetworkPayload } from '@quiet/types' export class CommunitiesState { public invitationCodes: InvitationPair[] = [] @@ -46,14 +38,6 @@ export const communitiesSlice = createSlice({ clearInvitationCodes: state => { state.invitationCodes = [] }, - clearInvitationData: (state, action: PayloadAction) => { - communitiesAdapter.updateOne(state.communities, { - id: action.payload, - changes: { - inviteData: null, - }, - }) - }, }, }) diff --git a/packages/state-manager/src/sagas/socket/startConnection/startConnection.saga.ts b/packages/state-manager/src/sagas/socket/startConnection/startConnection.saga.ts index f0dab53d6..9c908f13e 100644 --- a/packages/state-manager/src/sagas/socket/startConnection/startConnection.saga.ts +++ b/packages/state-manager/src/sagas/socket/startConnection/startConnection.saga.ts @@ -86,7 +86,6 @@ export function subscribe(socket: Socket) { | ReturnType | ReturnType | ReturnType - | ReturnType >(emit => { // UPDATE FOR APP socket.on(SocketActionTypes.TOR_INITIALIZED, () => { @@ -142,7 +141,6 @@ export function subscribe(socket: Socket) { emit(filesActions.checkForMissingFiles(payload.id)) emit(networkActions.addInitializedCommunity(payload.id)) emit(communitiesActions.clearInvitationCodes()) - emit(communitiesActions.clearInvitationData(payload.id)) }) socket.on(SocketActionTypes.COMMUNITY_UPDATED, (payload: Community) => {