Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove registration attempts selector #1768

Merged
merged 8 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

* Fixed bug with changing joining community/create community screens with required field.

* Fixed bug with displaying incorrect default settings tab.
* Fixed bug with displaying incorrect default settings tab.

* Removed registration attempts selector and corresponding usage.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -107,7 +100,6 @@ export const communitiesSelectors = {
currentCommunity,
currentCommunityId,
registrarUrl,
registrationAttempts,
invitationCode,
invitationUrl,
ownerNickname,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -12,17 +13,17 @@ 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)

const isOwner = Boolean(community?.CA)

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,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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 = {
Expand Down