From 7f7ebab312b941e56d9cae2fa002d02b7f0ce503 Mon Sep 17 00:00:00 2001 From: vinkabuki Date: Mon, 16 Oct 2023 16:09:36 +0200 Subject: [PATCH] Remove registration attempts selector (#1768) * Remove registration attempts selector * Update changelog * Run linter --- CHANGELOG.md | 2 ++ .../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 +---- 6 files changed, 8 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a0e5e3cdb..7fe34a70e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * Shorter dots-placeholder for invite link +* Removed registration attempts selector and corresponding usage. + * Revert adjusting bootstrap scripts for developing on Windows [2.0.1-alpha.2] diff --git a/packages/state-manager/src/sagas/communities/communities.selectors.ts b/packages/state-manager/src/sagas/communities/communities.selectors.ts index 7c97185122..2b86b0072e 100644 --- a/packages/state-manager/src/sagas/communities/communities.selectors.ts +++ b/packages/state-manager/src/sagas/communities/communities.selectors.ts @@ -68,13 +68,6 @@ export const invitationUrl = createSelector(currentCommunity, community => { return invitationShareUrl(initialPeers) }) -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, @@ -106,7 +99,6 @@ export const communitiesSelectors = { currentCommunity, currentCommunityId, registrarUrl, - registrationAttempts, invitationCodes, invitationCode, invitationUrl, 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 = {