Skip to content

Commit

Permalink
feat: remove the getIdentity prop from the profileSaga
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo committed Jan 24, 2024
1 parent 87fdafa commit 9272842
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/modules/profile/sagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ import {
setProfileAvatarDescriptionRequest,
setProfileAvatarDescriptionSuccess
} from './actions'
import { getIdentityOrRedirect } from '../identity/sagas'
import { call } from 'redux-saga/effects'

let mockAuthIdentity: AuthIdentity | undefined = {} as AuthIdentity

const profileSagas = createProfileSaga({
getIdentity: () => mockAuthIdentity,
peerUrl: 'aURL'
})
const address = 'anAddress'
Expand Down Expand Up @@ -58,7 +59,8 @@ describe('when handling the action to set the profile avatar description', () =>
EntitiesOperator.prototype.deployEntityWithoutNewFiles
),
Promise.reject(new Error(errorMessage))
]
],
[call(getIdentityOrRedirect), mockAuthIdentity]
])
.put(setProfileAvatarDescriptionFailure(address, errorMessage))
.dispatch(setProfileAvatarDescriptionRequest(address, description))
Expand All @@ -83,6 +85,7 @@ describe('when handling the action to set the profile avatar description', () =>

return expectSaga(profileSagas)
.provide([
[call(getIdentityOrRedirect), mockAuthIdentity],
[
matchers.call.fn(PeerAPI.prototype.fetchProfile),
dynamicDeepParametersEquality(
Expand Down Expand Up @@ -166,6 +169,7 @@ describe('when handling the action to set the profile avatar alias', () => {
it('should dispatch an action to signal that the request failed', () => {
return expectSaga(profileSagas)
.provide([
[call(getIdentityOrRedirect), mockAuthIdentity],
[
matchers.call.fn(PeerAPI.prototype.fetchProfile),
Promise.resolve(profileFromLambda)
Expand Down Expand Up @@ -201,6 +205,7 @@ describe('when handling the action to set the profile avatar alias', () => {

return expectSaga(profileSagas)
.provide([
[call(getIdentityOrRedirect), mockAuthIdentity],
[
matchers.call.fn(PeerAPI.prototype.fetchProfile),
dynamicDeepParametersEquality(
Expand Down
5 changes: 2 additions & 3 deletions src/modules/profile/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Avatar } from '@dcl/schemas/dist/platform/profile'
import { EntityType } from '@dcl/schemas/dist/platform/entity'
import { PeerAPI } from '../../lib/peer'
import { EntitiesOperator } from '../../lib/entities'
import { getIdentityOrRedirect } from '../identity/sagas'
import {
ConnectWalletSuccessAction,
CONNECT_WALLET_SUCCESS,
Expand Down Expand Up @@ -31,13 +32,11 @@ import { Profile } from './types'
export const NO_IDENTITY_FOUND_ERROR_MESSAGE = 'No identity found'

type CreateProfileSagaOptions = {
getIdentity: () => AuthIdentity | undefined
peerUrl: string
peerWithNoGbCollectorUrl?: string
}

export function createProfileSaga({
getIdentity,
peerUrl,
peerWithNoGbCollectorUrl
}: CreateProfileSagaOptions) {
Expand Down Expand Up @@ -139,7 +138,7 @@ export function createProfileSaga({
const profileMetadata: Profile = {
avatars: [newAvatar, ...profileWithContentHashes.avatars.slice(1)]
}
const identity = getIdentity()
const identity: AuthIdentity | null = yield call(getIdentityOrRedirect)

if (identity) {
yield call(
Expand Down

0 comments on commit 9272842

Please sign in to comment.