From de2bed80048940c4c2b58ccbfdb861bee1777433 Mon Sep 17 00:00:00 2001 From: Vin Kabuki Date: Thu, 7 Sep 2023 12:47:45 +0200 Subject: [PATCH 1/3] Remove registration attempts selector --- .../src/sagas/communities/communities.selectors.ts | 8 -------- .../errors/handleErrors/handleErrors.saga.test.ts | 1 - .../sagas/errors/handleErrors/handleErrors.saga.ts | 12 +----------- .../sendDeletionMessage/sendDeletionMessage.saga.ts | 7 ++++--- .../sendInitialChannelMessage.saga.ts | 5 +---- 5 files changed, 6 insertions(+), 27 deletions(-) diff --git a/packages/state-manager/src/sagas/communities/communities.selectors.ts b/packages/state-manager/src/sagas/communities/communities.selectors.ts index 4a1d44c232..53f71a4e60 100644 --- a/packages/state-manager/src/sagas/communities/communities.selectors.ts +++ b/packages/state-manager/src/sagas/communities/communities.selectors.ts @@ -69,13 +69,6 @@ export const invitationUrl = createSelector(currentCommunity, community => { return invitationShareUrl(registrarUrl) }) -export const registrationAttempts = (communityId: string) => - createSelector(selectEntities, communities => { - const community = communities[communityId] - if (!community) return 0 - return community.registrationAttempts || 0 - }) - export const ownerNickname = createSelector( currentCommunity, getOldestParsedCerificate, @@ -107,7 +100,6 @@ export const communitiesSelectors = { currentCommunity, currentCommunityId, registrarUrl, - registrationAttempts, invitationCode, invitationUrl, ownerNickname, diff --git a/packages/state-manager/src/sagas/errors/handleErrors/handleErrors.saga.test.ts b/packages/state-manager/src/sagas/errors/handleErrors/handleErrors.saga.test.ts index ceedaa7c38..3d963669e0 100644 --- a/packages/state-manager/src/sagas/errors/handleErrors/handleErrors.saga.test.ts +++ b/packages/state-manager/src/sagas/errors/handleErrors/handleErrors.saga.test.ts @@ -47,7 +47,6 @@ describe('handle errors', () => { .provide([[call.fn(delay), null]]) .call(retryRegistration, community.id) .put(errorsActions.addError(errorPayload)) - .put(communitiesActions.updateRegistrationAttempts({ id: community.id, registrationAttempts: 1 })) .run() }) diff --git a/packages/state-manager/src/sagas/errors/handleErrors/handleErrors.saga.ts b/packages/state-manager/src/sagas/errors/handleErrors/handleErrors.saga.ts index 7e710efcd2..e153aec9c0 100644 --- a/packages/state-manager/src/sagas/errors/handleErrors/handleErrors.saga.ts +++ b/packages/state-manager/src/sagas/errors/handleErrors/handleErrors.saga.ts @@ -1,8 +1,6 @@ import { type PayloadAction } from '@reduxjs/toolkit' -import { call, delay, put, select } from 'typed-redux-saga' +import { call, put, select } from 'typed-redux-saga' import { identitySelectors } from '../../identity/identity.selectors' -import { communitiesActions } from '../../communities/communities.slice' -import { communitiesSelectors } from '../../communities/communities.selectors' import { identityActions } from '../../identity/identity.slice' import { errorsActions } from '../errors.slice' import logger from '../../../utils/logger' @@ -44,14 +42,6 @@ export function* handleErrorsSaga( console.error(`Received error ${error} without community`) return } - // Leave for integration test assertions purposes - const registrationAttempts = yield* select(communitiesSelectors.registrationAttempts(error.community)) - yield* put( - communitiesActions.updateRegistrationAttempts({ - id: error.community, - registrationAttempts: registrationAttempts + 1, - }) - ) yield* call(retryRegistration, error.community) } } diff --git a/packages/state-manager/src/sagas/messages/sendDeletionMessage/sendDeletionMessage.saga.ts b/packages/state-manager/src/sagas/messages/sendDeletionMessage/sendDeletionMessage.saga.ts index e5e0b9f165..aa7af97ac9 100644 --- a/packages/state-manager/src/sagas/messages/sendDeletionMessage/sendDeletionMessage.saga.ts +++ b/packages/state-manager/src/sagas/messages/sendDeletionMessage/sendDeletionMessage.saga.ts @@ -1,6 +1,7 @@ import { type PayloadAction } from '@reduxjs/toolkit' import { put, select } from 'typed-redux-saga' import { communitiesSelectors } from '../../communities/communities.selectors' +import { identitySelectors } from '../../identity/identity.selectors' import { publicChannelsSelectors } from '../../publicChannels/publicChannels.selectors' import { messagesActions } from '../messages.slice' import { MessageType, type WriteMessagePayload } from '@quiet/types' @@ -12,9 +13,9 @@ export function* sendDeletionMessageSaga( const generalChannel = yield* select(publicChannelsSelectors.generalChannel) if (!generalChannel) return - const isGeneral = channelId === generalChannel.id + const user = yield* select(identitySelectors.currentIdentity) - const ownerNickname = yield* select(communitiesSelectors.ownerNickname) + const isGeneral = channelId === generalChannel.id const community = yield* select(communitiesSelectors.currentCommunity) @@ -22,7 +23,7 @@ export function* sendDeletionMessageSaga( const payload: WriteMessagePayload = { type: MessageType.Info, - message: `@${ownerNickname} deleted #${channelId.slice(0, channelId.indexOf('_'))}`, // TEMPORARY + message: `@${user?.nickname} deleted #${channelId.slice(0, channelId.indexOf('_'))}`, // TEMPORARY channelId: generalChannel.id, } diff --git a/packages/state-manager/src/sagas/publicChannels/createGeneralChannel/sendInitialChannelMessage.saga.ts b/packages/state-manager/src/sagas/publicChannels/createGeneralChannel/sendInitialChannelMessage.saga.ts index 739f1e49fa..9607e72e79 100644 --- a/packages/state-manager/src/sagas/publicChannels/createGeneralChannel/sendInitialChannelMessage.saga.ts +++ b/packages/state-manager/src/sagas/publicChannels/createGeneralChannel/sendInitialChannelMessage.saga.ts @@ -1,6 +1,5 @@ import { type PayloadAction } from '@reduxjs/toolkit' import { put, select } from 'typed-redux-saga' -import { communitiesSelectors } from '../../communities/communities.selectors' import { messagesActions } from '../../messages/messages.slice' import { publicChannelsSelectors } from '../publicChannels.selectors' import { publicChannelsActions } from '../publicChannels.slice' @@ -17,13 +16,11 @@ export function* sendInitialChannelMessageSaga( const pendingGeneralChannelRecreation = yield* select(publicChannelsSelectors.pendingGeneralChannelRecreation) - const ownerNickname = yield* select(communitiesSelectors.ownerNickname) - const user = yield* select(identitySelectors.currentIdentity) const message = pendingGeneralChannelRecreation && isGeneral - ? `@${ownerNickname} deleted all messages in #general` + ? `@${user?.nickname} deleted all messages in #general` : `@${user?.nickname} created #${channelName}` const payload: WriteMessagePayload = { From 8819aad5e1bee52fe7cbad34ad5dfedb91b2aa73 Mon Sep 17 00:00:00 2001 From: Vin Kabuki Date: Thu, 7 Sep 2023 12:48:43 +0200 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30b4cb2400..86ae5f8d04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,4 +6,6 @@ * Fixed bug with changing joining community/create community screens with required field. -* Fixed bug with displaying incorrect default settings tab. \ No newline at end of file +* Fixed bug with displaying incorrect default settings tab. + +* Removed registration attempts selector and corresponding usage. \ No newline at end of file From ca97df80b0544948da1858a873bc2fa02cc2926d Mon Sep 17 00:00:00 2001 From: Vin Kabuki Date: Tue, 10 Oct 2023 09:37:35 +0200 Subject: [PATCH 3/3] Run linter --- .../src/sagas/communities/communities.selectors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/state-manager/src/sagas/communities/communities.selectors.ts b/packages/state-manager/src/sagas/communities/communities.selectors.ts index 75bd4381d8..2b86b0072e 100644 --- a/packages/state-manager/src/sagas/communities/communities.selectors.ts +++ b/packages/state-manager/src/sagas/communities/communities.selectors.ts @@ -9,7 +9,7 @@ import { getOldestParsedCerificate } from '../users/users.selectors' // Workaround for "The inferred type of 'communitiesSelectors' cannot be named without a reference to // 'packages/identity/node_modules/pkijs/build'. This is likely not portable. A type annotation is necessary." // https://github.com/microsoft/TypeScript/issues/47663#issuecomment-1270716220 -import type { } from 'pkijs' +import type {} from 'pkijs' const communitiesSlice: CreatedSelectors[StoreKeys.Communities] = (state: StoreState) => state[StoreKeys.Communities]