Skip to content
This repository was archived by the owner on Oct 4, 2023. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
import { CommonState } from '../../commonStore'

import { getCompletionStages } from './profile-progress'
const NATIVE_MOBILE = process.env.REACT_APP_NATIVE_MOBILE

/**
* Gets the state of a user challenge, with the most progress dominating
Expand Down Expand Up @@ -59,7 +58,7 @@ export const getOptimisticUserChallengeStepCounts = (state: CommonState) => {
}
/**
* Converts a user challenge to an optimistic user challenge
* @param challenge The original UserChallenge
* @param challenge
* @param stepCountOverrides the overrides to apply to challenge step counts
* @param userChallengesOverrides the overrides to apply to other challenge states (currently used for disbursement)
* @returns the optimistic state of that challenge
Expand All @@ -70,7 +69,8 @@ const toOptimisticChallenge = (
stepCountOverrides: Partial<Record<ChallengeRewardID, number>>,
userChallengesOverrides: Partial<
Record<ChallengeRewardID, Partial<UserChallenge>>
>
>,
isNativeMobile?: boolean
): OptimisticUserChallenge => {
const currentStepCountOverride = stepCountOverrides[challenge.challenge_id]
const userChallengeOverrides = userChallengesOverrides[challenge.challenge_id]
Expand All @@ -91,7 +91,7 @@ const toOptimisticChallenge = (
// If we're on native mobile, we might not yet have the is_mobile user_event
// on DN, so optimistically mark this challenge as complete so the client
// can start claiming
if (challenge.challenge_id === 'mobile-install' && NATIVE_MOBILE) {
if (challenge.challenge_id === 'mobile-install' && isNativeMobile) {
challengeOverridden.is_complete = true
}

Expand Down Expand Up @@ -127,7 +127,10 @@ const toOptimisticChallenge = (
* @param challenge The user challenge to get the optimistic state for
* @returns the same challenge with state and current_step_count overridden as necessary
*/
export const getOptimisticUserChallenges = (state: CommonState) => {
export const getOptimisticUserChallenges = (
state: CommonState,
isNativeMobile?: boolean
) => {
const stepCountOverrides = getOptimisticUserChallengeStepCounts(state)
const userChallengesOverrides = getUserChallengesOverrides(state)
const userChallenges = getUserChallenges(state)
Expand All @@ -144,7 +147,8 @@ export const getOptimisticUserChallenges = (state: CommonState) => {
challenge,
undisbursedUserChallenges[challenge.challenge_id] || [],
stepCountOverrides,
userChallengesOverrides
userChallengesOverrides,
isNativeMobile
)
)
.reduce((map, challenge) => {
Expand Down
1 change: 0 additions & 1 deletion packages/mobile/.env.dev.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ HCAPTCHA_BASE_URL=https://staging.audius.co
AMPLITUDE_WRITE_KEY=abc
OPTIMIZELY_KEY=MX4fYBgANQetvmBXGpuxzF
SENTRY_DSN=https://4b15a7a2f2e2459997408b39a0c4942c@o260428.ingest.sentry.io/1851611
NATIVE_NAVIGATION_ENABLED=true

GENERAL_ADMISSION=https://general-admission.staging.audius.co

Expand Down
1 change: 0 additions & 1 deletion packages/mobile/.env.prod.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ HCAPTCHA_BASE_URL=https://audius.co
AMPLITUDE_WRITE_KEY=abc
OPTIMIZELY_KEY=DAJbGEJBC21dzFRPv8snxs
SENTRY_DSN=https://e26d2b01488f4b538ea235de6466c40a@o260428.ingest.sentry.io/1457231
NATIVE_NAVIGATION_ENABLED=true

GENERAL_ADMISSION=https://general-admission.audius.co

Expand Down
1 change: 0 additions & 1 deletion packages/mobile/.env.stage.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ HCAPTCHA_BASE_URL=https://staging.audius.co
AMPLITUDE_WRITE_KEY=abc
OPTIMIZELY_KEY=MX4fYBgANQetvmBXGpuxzF
SENTRY_DSN=https://4b15a7a2f2e2459997408b39a0c4942c@o260428.ingest.sentry.io/1851611
NATIVE_NAVIGATION_ENABLED=true

GENERAL_ADMISSION=https://general-admission.staging.audius.co

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useContext, useEffect } from 'react'

import type { Maybe } from '@audius/common'
import type { Maybe, CommonState } from '@audius/common'
import {
IntKeys,
StringKeys,
Expand Down Expand Up @@ -48,7 +48,9 @@ export const ChallengeRewardsDrawerProvider = () => {
const dispatch = useDispatch()
const { onClose } = useDrawerState(MODAL_NAME)
const modalType = useSelector(getChallengeRewardsModalType)
const userChallenges = useSelector(getOptimisticUserChallenges)
const userChallenges = useSelector((state: CommonState) =>
getOptimisticUserChallenges(state, true)
)

const handleClose = useCallback(() => {
dispatch(resetAndCancelClaimReward())
Expand Down
7 changes: 5 additions & 2 deletions packages/mobile/src/screens/audio-screen/ChallengeRewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { useEffect, useState } from 'react'

import type {
ChallengeRewardID,
ChallengeRewardsModalType
ChallengeRewardsModalType,
CommonState
} from '@audius/common'
import {
removeNullable,
Expand Down Expand Up @@ -70,7 +71,9 @@ export const ChallengeRewards = () => {

const userChallengesLoading = useSelector(getUserChallengesLoading)
const userChallenges = useSelector(getUserChallenges)
const optimisticUserChallenges = useSelector(getOptimisticUserChallenges)
const optimisticUserChallenges = useSelector((state: CommonState) =>
getOptimisticUserChallenges(state, true)
)
const [haveChallengesLoaded, setHaveChallengesLoaded] = useState(false)

// The referred challenge only needs a tile if the user was referred
Expand Down
4 changes: 0 additions & 4 deletions packages/web/.env/.env.mobile.prod

This file was deleted.

4 changes: 0 additions & 4 deletions packages/web/.env/.env.mobile.stage

This file was deleted.

6 changes: 0 additions & 6 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,9 @@
"publish-scripts": "./scripts/publishScripts.sh",
"start": "craco --max-old-space-size=8076 start",
"start:dev": "npm run write-sha && npm run configure-local-env && npm run publish-scripts && env-cmd --no-override ./.env/.env.dev.local npm start",
"start:dev:mobile": "env-cmd ./.env/.env.mobile.prod npm run start:dev",
"start:dev:cloud": "npm run write-sha && npm run configure-local-env-cloud && npm run publish-scripts && env-cmd --no-override ./.env/.env.dev.local npm start",
"start:dev:mobile:cloud": "env-cmd ./.env/.env.mobile.stage npm run start:dev:cloud",
"start:stage": "npm run write-sha && npm run publish-scripts && env-cmd --no-override ./.env/.env.stage npm start",
"start:prod": "npm run write-sha && npm run publish-scripts && env-cmd --no-override ./.env/.env.prod npm start",
"start:mobile-prod": "env-cmd ./.env/.env.mobile.prod npm run start:prod",
"start:mobile-stage": "env-cmd ./.env/.env.mobile.stage npm run start:stage",
"start:ipfs-prod": "env-cmd ./.env/.env.ipfs.prod npm run start:prod",
"start:ipfs-stage": "env-cmd ./.env/.env.ipfs.stage npm run start:stage",
"prebuild": "npm run publish-scripts",
Expand All @@ -136,8 +132,6 @@
"build:stage": "npm run write-sha && env-cmd ./.env/.env.stage npm run build && rm -rf build-staging && mv build build-staging",
"build:prod": "npm run write-sha && env-cmd ./.env/.env.prod npm run build && rm -rf build-production && mv build build-production",
"build:prod-source-maps": "npm run write-sha && env-cmd ./.env/.env.prod env-cmd ./.env/.env.source-maps npm run build && rm -rf build-production && mv build build-production",
"build:mobile-stage": "env-cmd ./.env/.env.mobile.stage npm run build:stage && rm -rf build-mobile-staging && mv build-staging build-mobile-staging",
"build:mobile-prod": "env-cmd ./.env/.env.mobile.prod npm run build:prod && rm -rf build-mobile-production && mv build-production build-mobile-production",
"build:ipfs-stage": "env-cmd ./.env/.env.ipfs.stage npm run build:stage && rm -rf build-mobile-staging && mv build-staging build-ipfs-staging",
"build:ipfs-prod": "env-cmd ./.env/.env.ipfs.prod npm run build:prod && rm -rf build-mobile-production && mv build-production build-ipfs-production",
"test": "craco test --resetMocks=false",
Expand Down
21 changes: 11 additions & 10 deletions packages/web/src/common/store/backend/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { RequestNetworkConnected } from 'services/native-mobile-interface/lifecy
import * as backendActions from './actions'
import { watchBackendErrors } from './errorSagas'
const { getIsReachable } = reachabilitySelectors
const NATIVE_MOBILE = process.env.REACT_APP_NATIVE_MOBILE

const REACHABILITY_TIMEOUT_MS = 8 * 1000

Expand All @@ -47,8 +46,10 @@ export function* waitForBackendSetup() {
}
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function* awaitReachability() {
if (!NATIVE_MOBILE) return true
const isNativeMobile = yield* getContext('isNativeMobile')
if (!isNativeMobile) return true
// Request network connection information.
// If we don't ask the native layer for it, it's possible that we never receive
// and update.
Expand All @@ -64,16 +65,16 @@ function* awaitReachability() {
}

export function* setupBackend() {
const establishedReachability = yield* call(awaitReachability)

// Reachability commented out for now until it is properly addressed
// const establishedReachability = yield* call(awaitReachability)
// If we couldn't connect, show the error page
// and just sit here waiting for reachability.
if (!establishedReachability) {
console.error('No internet connectivity')
yield* put(accountActions.fetchAccountNoInternet())
yield* take(reachabilityActions.SET_REACHABLE)
console.info('Reconnected')
}
// if (!establishedReachability) {
// console.error('No internet connectivity')
// yield* put(accountActions.fetchAccountNoInternet())
// yield* take(reachabilityActions.SET_REACHABLE)
// console.info('Reconnected')
// }

const apiClient = yield* getContext('apiClient')
const fingerprintClient = yield* getContext('fingerprintClient')
Expand Down
5 changes: 2 additions & 3 deletions packages/web/src/common/store/cache/tracks/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ const { getTrack } = cacheTracksSelectors
const setDominantColors = averageColorActions.setDominantColors
const { getAccountUser, getUserId, getUserHandle } = accountSelectors

const NATIVE_MOBILE = process.env.REACT_APP_NATIVE_MOBILE

function* fetchRepostInfo(entries) {
const userIds = []
entries.forEach((entry) => {
Expand Down Expand Up @@ -122,7 +120,8 @@ function* watchAdd() {
}))
)
)
if (!NATIVE_MOBILE) {
const isNativeMobile = yield getContext('isNativeMobile')
if (!isNativeMobile) {
yield fork(fetchRepostInfo, action.entries)
yield fork(fetchFirstSegments, action.entries)
}
Expand Down
4 changes: 0 additions & 4 deletions packages/web/src/common/store/lineup/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ const { getUsers } = cacheUsersSelectors
const { getTrack, getTracks } = cacheTracksSelectors
const { getCollection } = cacheCollectionsSelectors

const IS_NATIVE_MOBILE = process.env.REACT_APP_NATIVE_MOBILE

// This is copied from web/src/utils since moving it to common would require
// changing 90+ files. This will be ignored in RN-reloaded, since we check
// isNativeMobile from storeContext first.
export const isMobile = () => {
// If we are running with the mobile env flag set, short-circuit to `true`
if (IS_NATIVE_MOBILE) return true
let check = false
;(function (a) {
if (
Expand Down
6 changes: 1 addition & 5 deletions packages/web/src/common/store/oauth/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ import {
RequestTwitterAuthSuccessMessage
} from 'services/native-mobile-interface/oauth'

import mobileSagas from './mobileSagas'

const NATIVE_MOBILE = process.env.REACT_APP_NATIVE_MOBILE
const IDENTITY_SERVICE = process.env.REACT_APP_IDENTITY_SERVICE
const INSTAGRAM_APP_ID = process.env.REACT_APP_INSTAGRAM_APP_ID
const INSTAGRAM_REDIRECT_URL =
Expand Down Expand Up @@ -296,8 +293,7 @@ function* watchInstagramAuth() {
}

const sagas = () => {
const sagas = [watchTwitterAuth, watchInstagramAuth]
return NATIVE_MOBILE ? sagas.concat(mobileSagas()) : sagas
return [watchTwitterAuth, watchInstagramAuth]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

jeepers jeffers i touched this file too!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

word i can help resolve for you. basically i just ignored nativeSagas, expecting that you moved it into mobile package etc

}

export default sagas
7 changes: 1 addition & 6 deletions packages/web/src/common/store/pages/signon/reducer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getIsIOS } from 'utils/browser'
import { isMobile } from 'utils/clientUtil'
import { FEED_PAGE } from 'utils/route'

Expand Down Expand Up @@ -38,8 +37,6 @@ import {
} from './actions'
import { Pages, FollowArtistsCategory } from './types'

const NATIVE_MOBILE = process.env.REACT_APP_NATIVE_MOBILE

const createTextField = () => ({
value: '',
error: '',
Expand Down Expand Up @@ -114,10 +111,8 @@ const actionsMap = {
newPage = Pages.FOLLOW
break
case Pages.FOLLOW: {
if (!NATIVE_MOBILE && !isMobile()) {
if (!isMobile()) {
newPage = Pages.APP_CTA
} else if (NATIVE_MOBILE && getIsIOS()) {
newPage = Pages.NOTIFICATION_SETTINGS
} else {
newPage = Pages.LOADING
}
Expand Down
10 changes: 7 additions & 3 deletions packages/web/src/common/store/reachability/sagas.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { reachabilityActions, reachabilitySelectors } from '@audius/common'
import {
reachabilityActions,
reachabilitySelectors,
getContext
} from '@audius/common'
import { takeEvery, call, put, race, select, delay } from 'typed-redux-saga'

import { MessageType, Message } from 'services/native-mobile-interface/types'
import { isMobile } from 'utils/clientUtil'
const { getIsReachable } = reachabilitySelectors
const { setUnreachable, setReachable } = reachabilityActions

const NATIVE_MOBILE = process.env.REACT_APP_NATIVE_MOBILE
const REACHABILITY_URL = process.env.REACT_APP_REACHABILITY_URL

// Property values borrowed from
Expand Down Expand Up @@ -63,7 +66,8 @@ function* updateReachability(isReachable: boolean) {
}

function* reachabilityPollingDaemon() {
if (NATIVE_MOBILE) {
const isNativeMobile = yield* getContext('isNativeMobile')
if (isNativeMobile) {
// Native mobile: use the system connectivity checks
console.log('polling')
yield* takeEvery(
Expand Down
5 changes: 2 additions & 3 deletions packages/web/src/common/store/social/tracks/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ const { getTrack, getTracks } = cacheTracksSelectors

const { getUserId, getUserHandle } = accountSelectors

const NATIVE_MOBILE = process.env.REACT_APP_NATIVE_MOBILE

/* REPOST TRACK */
export function* watchRepostTrack() {
yield* takeEvery(socialActions.REPOST_TRACK, repostTrackAsync)
Expand Down Expand Up @@ -585,7 +583,8 @@ export function* watchRecordListen() {
yield* takeEvery(
socialActions.RECORD_LISTEN,
function* (action: ReturnType<typeof socialActions.recordListen>) {
if (NATIVE_MOBILE) return
const isNativeMobile = yield* getContext('isNativeMobile')
if (isNativeMobile) return
console.debug('Listen recorded for track', action.trackId)

yield* waitForAccount()
Expand Down
Loading