Skip to content

Commit

Permalink
[C-2718] Fix mobile sign-up environment issues (#3691)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanjeffers committed Jul 3, 2023
1 parent 2a7a7b0 commit 949525c
Showing 1 changed file with 28 additions and 15 deletions.
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
}

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

0 comments on commit 949525c

Please sign in to comment.