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

Actually fix follow artists step in sign up flow C-3206 #6312

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion packages/mobile/src/screens/signon/FirstFollows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const FirstFollows = (props: FirstFollowsProps) => {

const handleArtistsSelected = () => {
dispatch(signOnActions.finishSignUp())
dispatch(signOnActions.followArtists(followArtists.selectedUserIds))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we kept this here, but just changed the takeLatest like you did? I don't have the full picture but it seemed the issue was the saga not getting triggered, not an issue with dispatching followArtists?

Copy link
Contributor Author

@nicoback2 nicoback2 Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just left another comment, we can't do followArtists until the account is created, fetched, and populated in the store. That's what the saga in the other file intended to do (by also waiting on fetchAccountSucceeded) but failed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah makes sense, thanks


track(
make({
Expand Down
10 changes: 2 additions & 8 deletions packages/web/src/common/store/pages/signon/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ function* signUp() {
yield put(signOnActions.signUpSucceeded())
yield put(signOnActions.sendWelcomeEmail(name))
yield call(fetchAccountAsync, { isSignUp: true })
yield put(signOnActions.followArtists())
},
function* ({ timeout }) {
if (timeout) {
Expand Down Expand Up @@ -739,14 +740,7 @@ function* watchConfigureMetaMask() {
}

function* watchFollowArtists() {
while (
yield all([
Copy link
Contributor Author

@nicoback2 nicoback2 Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This while(yield) thing was a killer. If you were signed into an account when you started the session, then the take(accountActions.fetchAccountSucceeded.type) requirement was already fulfilled before you start the sign up flow for the new account. So when signOnActions.FOLLOW_ARTISTS was dispatched from the follow artists component, followArtists would fire right away even though it's supposed to wait until the new account is created and fetched. This is why the followArtists step would ultimately fail (since the user account is empty as it fired too early in the flow).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified this by just having it take that one action and dispatching it when we actually want it to go.

take(accountActions.fetchAccountSucceeded.type),
take(signOnActions.FOLLOW_ARTISTS)
])
) {
yield call(followArtists)
}
yield takeLatest(signOnActions.FOLLOW_ARTISTS, followArtists)
}

function* watchShowToast() {
Expand Down
3 changes: 0 additions & 3 deletions packages/web/src/pages/sign-on/SignOnProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ export class SignOnProvider extends Component<SignOnProps, SignOnState> {
email,
handle
} = this.props.fields
this.props.followArtists(selectedUserIds)
this.props.recordCompleteFollow(
selectedUserIds.join('|'),
selectedUserIds.length,
Expand Down Expand Up @@ -561,8 +560,6 @@ function mapDispatchToProps(dispatch: Dispatch) {
nextPage: (isMobile: boolean) => dispatch(signOnAction.nextPage(isMobile)),
previousPage: () => dispatch(signOnAction.previousPage()),
goToPage: (page: Pages) => dispatch(signOnAction.goToPage(page)),
followArtists: (userIds: ID[]) =>
dispatch(signOnAction.followArtists(userIds)),
addFollows: (userIds: ID[]) =>
dispatch(signOnAction.addFollowArtists(userIds)),
removeFollows: (userIds: ID[]) =>
Expand Down