Skip to content

Commit

Permalink
Remove registration attempts selector (#1768)
Browse files Browse the repository at this point in the history
* Remove registration attempts selector

* Update changelog

* Run linter
  • Loading branch information
vinkabuki authored Oct 16, 2023
1 parent 8c63ea6 commit 7f7ebab
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -106,7 +99,6 @@ export const communitiesSelectors = {
currentCommunity,
currentCommunityId,
registrarUrl,
registrationAttempts,
invitationCodes,
invitationCode,
invitationUrl,
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

0 comments on commit 7f7ebab

Please sign in to comment.