Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

[C-2718] Fix mobile sign-up environment issues #3691

Merged
merged 2 commits into from
Jul 3, 2023
Merged
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
43 changes: 28 additions & 15 deletions packages/web/src/common/store/pages/signon/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ const { getUsers } = cacheUsersSelectors
const getAccountUser = accountSelectors.getAccountUser
const { toast } = toastActions

const IS_PRODUCTION_BUILD = process.env.NODE_ENV === 'production'
const IS_PRODUCTION = process.env.REACT_APP_ENVIRONMENT === 'production'
const IS_STAGING = process.env.REACT_APP_ENVIRONMENT === 'staging'

const SIGN_UP_TIMEOUT_MILLIS = 20 /* min */ * 60 * 1000

const messages = {
Expand All @@ -73,14 +69,26 @@ const messages = {
emailCheckFailed: 'Something has gone wrong, please try again later.'
}

// Users ID to filter out of the suggested artists to follow list and to follow by default
let defaultFollowUserIds = new Set([])
if (IS_PRODUCTION) {
// user id 51: official audius account
defaultFollowUserIds = new Set([51])
} else if (IS_STAGING) {
// user id 1964: stage testing account
defaultFollowUserIds = new Set([1964])
function* getDefautFollowUserIds() {
const { ENVIRONMENT } = yield getContext('env')
// Users ID to filter out of the suggested artists to follow list and to follow by default

let defaultFollowUserIds = new Set([])

switch (ENVIRONMENT) {
case 'production': {
// user id 51: official audius account
defaultFollowUserIds = new Set([51])
break
}
case 'staging': {
// user id 1964: stage testing account
defaultFollowUserIds = new Set([1964])
break
}
}

return defaultFollowUserIds
Comment on lines +76 to +91
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a tradeoff in readability, but I think this would be cleaner as an expression. Also removes the need for mutating defaultFollowUserIds!

Suggested change
let defaultFollowUserIds = new Set([])
switch (ENVIRONMENT) {
case 'production': {
// user id 51: official audius account
defaultFollowUserIds = new Set([51])
break
}
case 'staging': {
// user id 1964: stage testing account
defaultFollowUserIds = new Set([1964])
break
}
}
return defaultFollowUserIds
return new Set({
// user id 51: official audius account
production: [51],
// user id 1964: stage testing account
staging: [1964],
}[ENVIRONMENT] ?? [])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dang i merged and this comment hadnt loaded :/ i agree though

}

export function* fetchSuggestedFollowUserIds() {
Expand Down Expand Up @@ -128,6 +136,7 @@ function* fetchAllFollowArtist() {
function* fetchFollowArtistGenre(followArtistCategory) {
const apiClient = yield getContext('apiClient')
const genres = followArtistCategoryGenreMappings[followArtistCategory]
const defaultFollowUserIds = yield call(getDefautFollowUserIds)
try {
const users = yield apiClient.getTopArtistGenres({
genres,
Expand Down Expand Up @@ -186,6 +195,8 @@ function* validateHandle(action) {
const { handle, isOauthVerified, onValidate } = action
const audiusBackendInstance = yield getContext('audiusBackendInstance')
const remoteConfigInstance = yield getContext('remoteConfigInstance')
const { ENVIRONMENT } = yield getContext('env')

yield call(waitForWrite)
try {
if (handle.length > MAX_HANDLE_LENGTH) {
Expand Down Expand Up @@ -216,7 +227,7 @@ function* validateHandle(action) {
)
const handleInUse = !isEmpty(user)

if (IS_PRODUCTION_BUILD || IS_PRODUCTION) {
if (ENVIRONMENT === 'production') {
const [twitterUserQuery, instagramUser, tikTokUser] = yield all([
call(audiusBackendInstance.twitterHandle, handle),
call(audiusBackendInstance.instagramHandle, handle),
Expand Down Expand Up @@ -606,12 +617,14 @@ function* followCollections(collectionIds, favoriteSource) {

function* followArtists() {
const audiusBackendInstance = yield getContext('audiusBackendInstance')
const { ENVIRONMENT } = yield getContext('env')
const defaultFollowUserIds = yield call(getDefautFollowUserIds)
yield call(waitForWrite)
try {
// Auto-follow Hot & New Playlist
if (IS_PRODUCTION) {
if (ENVIRONMENT === 'production') {
yield fork(followCollections, [4281], FavoriteSource.SIGN_UP)
} else if (IS_STAGING) {
} else if (ENVIRONMENT === 'staging') {
yield fork(followCollections, [555], FavoriteSource.SIGN_UP)
}

Expand Down