diff --git a/packages/web/src/common/store/pages/signon/sagas.js b/packages/web/src/common/store/pages/signon/sagas.js index d486441946c..9679633eca4 100644 --- a/packages/web/src/common/store/pages/signon/sagas.js +++ b/packages/web/src/common/store/pages/signon/sagas.js @@ -113,6 +113,16 @@ function* getArtistsToFollow() { yield put(signOnActions.setUsersToFollow(users)) } +function* fetchDefaultFollowArtists() { + yield call(waitForRead) + try { + const defaultFollowUserIds = yield call(getDefautFollowUserIds) + yield call(fetchUsers, Array.from(defaultFollowUserIds)) + } catch (e) { + console.error('Unable to fetch default follow artists', e) + } +} + function* fetchAllFollowArtist() { yield call(waitForRead) try { @@ -495,10 +505,10 @@ function* signUp() { } }, function* () { - yield put(signOnActions.signUpSucceeded()) yield put(signOnActions.sendWelcomeEmail(name)) yield call(fetchAccountAsync, { isSignUp: true }) yield put(signOnActions.followArtists()) + yield put(signOnActions.signUpSucceeded()) }, function* ({ timeout }) { if (timeout) { @@ -728,7 +738,11 @@ function* watchValidateHandle() { } function* watchSignUp() { - yield takeLatest(signOnActions.SIGN_UP, signUp) + yield takeLatest(signOnActions.SIGN_UP, function* (action) { + // Fetch the default follow artists in parallel so that we don't have to block on this later (thus adding perceived sign up time) in the follow artists step. + yield fork(fetchDefaultFollowArtists) + yield signUp(action) + }) } function* watchSignIn() { diff --git a/packages/web/src/common/store/social/users/sagas.ts b/packages/web/src/common/store/social/users/sagas.ts index 5c4821b0913..a05e86d6176 100644 --- a/packages/web/src/common/store/social/users/sagas.ts +++ b/packages/web/src/common/store/social/users/sagas.ts @@ -15,7 +15,7 @@ import { import { call, select, takeEvery, put } from 'typed-redux-saga' import { make } from 'common/store/analytics/actions' -import { adjustUserField } from 'common/store/cache/users/sagas' +import { adjustUserField, fetchUsers } from 'common/store/cache/users/sagas' import * as signOnActions from 'common/store/pages/signon/actions' import { profilePage } from 'utils/route' import { waitForWrite } from 'utils/sagaHelpers' @@ -48,9 +48,19 @@ export function* followUser( } const users = yield* select(getUsers, { ids: [action.userId, accountId] }) - const followedUser = users[action.userId] + let followedUser = users[action.userId] const currentUser = users[accountId] + if (!followedUser) { + try { + // If we haven't cached the followed user, need to fetch and cache it first to ensure that we have the correct `does_current_user_follow` on the user value before the follow gets indexed. + const { entries } = yield* call(fetchUsers, [action.userId]) + followedUser = entries[action.userId] + } catch (e) { + console.error('Failed to fetch the followed user', action.userId) + } + } + if (followedUser) { // Increment the followed user's follower count yield* put(