Skip to content

Commit 9272842

Browse files
committed
feat: remove the getIdentity prop from the profileSaga
1 parent 87fdafa commit 9272842

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/modules/profile/sagas.spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import {
1818
setProfileAvatarDescriptionRequest,
1919
setProfileAvatarDescriptionSuccess
2020
} from './actions'
21+
import { getIdentityOrRedirect } from '../identity/sagas'
22+
import { call } from 'redux-saga/effects'
2123

2224
let mockAuthIdentity: AuthIdentity | undefined = {} as AuthIdentity
2325

2426
const profileSagas = createProfileSaga({
25-
getIdentity: () => mockAuthIdentity,
2627
peerUrl: 'aURL'
2728
})
2829
const address = 'anAddress'
@@ -58,7 +59,8 @@ describe('when handling the action to set the profile avatar description', () =>
5859
EntitiesOperator.prototype.deployEntityWithoutNewFiles
5960
),
6061
Promise.reject(new Error(errorMessage))
61-
]
62+
],
63+
[call(getIdentityOrRedirect), mockAuthIdentity]
6264
])
6365
.put(setProfileAvatarDescriptionFailure(address, errorMessage))
6466
.dispatch(setProfileAvatarDescriptionRequest(address, description))
@@ -83,6 +85,7 @@ describe('when handling the action to set the profile avatar description', () =>
8385

8486
return expectSaga(profileSagas)
8587
.provide([
88+
[call(getIdentityOrRedirect), mockAuthIdentity],
8689
[
8790
matchers.call.fn(PeerAPI.prototype.fetchProfile),
8891
dynamicDeepParametersEquality(
@@ -166,6 +169,7 @@ describe('when handling the action to set the profile avatar alias', () => {
166169
it('should dispatch an action to signal that the request failed', () => {
167170
return expectSaga(profileSagas)
168171
.provide([
172+
[call(getIdentityOrRedirect), mockAuthIdentity],
169173
[
170174
matchers.call.fn(PeerAPI.prototype.fetchProfile),
171175
Promise.resolve(profileFromLambda)
@@ -201,6 +205,7 @@ describe('when handling the action to set the profile avatar alias', () => {
201205

202206
return expectSaga(profileSagas)
203207
.provide([
208+
[call(getIdentityOrRedirect), mockAuthIdentity],
204209
[
205210
matchers.call.fn(PeerAPI.prototype.fetchProfile),
206211
dynamicDeepParametersEquality(

src/modules/profile/sagas.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Avatar } from '@dcl/schemas/dist/platform/profile'
44
import { EntityType } from '@dcl/schemas/dist/platform/entity'
55
import { PeerAPI } from '../../lib/peer'
66
import { EntitiesOperator } from '../../lib/entities'
7+
import { getIdentityOrRedirect } from '../identity/sagas'
78
import {
89
ConnectWalletSuccessAction,
910
CONNECT_WALLET_SUCCESS,
@@ -31,13 +32,11 @@ import { Profile } from './types'
3132
export const NO_IDENTITY_FOUND_ERROR_MESSAGE = 'No identity found'
3233

3334
type CreateProfileSagaOptions = {
34-
getIdentity: () => AuthIdentity | undefined
3535
peerUrl: string
3636
peerWithNoGbCollectorUrl?: string
3737
}
3838

3939
export function createProfileSaga({
40-
getIdentity,
4140
peerUrl,
4241
peerWithNoGbCollectorUrl
4342
}: CreateProfileSagaOptions) {
@@ -139,7 +138,7 @@ export function createProfileSaga({
139138
const profileMetadata: Profile = {
140139
avatars: [newAvatar, ...profileWithContentHashes.avatars.slice(1)]
141140
}
142-
const identity = getIdentity()
141+
const identity: AuthIdentity | null = yield call(getIdentityOrRedirect)
143142

144143
if (identity) {
145144
yield call(

0 commit comments

Comments
 (0)