Skip to content
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
6 changes: 1 addition & 5 deletions src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ class AuthScreens extends React.Component {

componentDidMount() {
NetworkConnection.listenForReconnect();
NetworkConnection.onReconnect(() => {
App.getAppData();
App.reconnectApp();
});
NetworkConnection.onReconnect(() => App.reconnectApp());
PusherConnectionManager.init();
Pusher.init({
appKey: CONFIG.PUSHER.APP_KEY,
Expand All @@ -120,7 +117,6 @@ class AuthScreens extends React.Component {

// Listen for report changes and fetch some data we need on initialization
UnreadIndicatorUpdater.listenForReportChanges();
App.getAppData();
App.openApp();

App.fixAccountAndReloadData();
Expand Down
10 changes: 0 additions & 10 deletions src/libs/actions/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import CONST from '../../CONST';
import Log from '../Log';
import Performance from '../Performance';
import Timing from './Timing';
import * as BankAccounts from './BankAccounts';
import * as Policy from './Policy';
import Navigation from '../Navigation/Navigation';
import ROUTES from '../../ROUTES';
Expand Down Expand Up @@ -98,13 +97,6 @@ AppState.addEventListener('change', (nextAppState) => {
appState = nextAppState;
});

/**
* Fetches data needed for app initialization
*/
function getAppData() {
BankAccounts.fetchUserWallet();
}

/**
* Fetches data needed for app initialization
*/
Expand Down Expand Up @@ -162,7 +154,6 @@ function fixAccountAndReloadData() {
return;
}
Log.info('FixAccount found updates for this user, so data will be reinitialized', true, response);
getAppData();
});
}

Expand Down Expand Up @@ -257,7 +248,6 @@ function openProfile() {
export {
setLocale,
setSidebarLoaded,
getAppData,
fixAccountAndReloadData,
setUpPoliciesAndNavigate,
openProfile,
Expand Down
1 change: 0 additions & 1 deletion src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export {
export {
fetchOnfidoToken,
activateWallet,
fetchUserWallet,
verifyIdentity,
acceptWalletTerms,
} from './Wallet';
Expand Down
28 changes: 17 additions & 11 deletions src/libs/actions/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,24 +476,29 @@ function acceptWalletTerms(parameters) {
}

/**
* Fetches information about a user's Expensify Wallet
* Fetches data when the user opens the InitialSettingsPage
*
* @typedef {Object} UserWallet
* @property {Number} availableBalance
* @property {Number} currentBalance
* @property {String} currentStep - used to track which step of the "activate wallet" flow a user is in
* @property {('SILVER'|'GOLD')} tierName - will be GOLD when fully activated. SILVER is able to recieve funds only.
*/
function fetchUserWallet() {
DeprecatedAPI.Get({returnValueList: 'userWallet'})
.then((response) => {
if (response.jsonCode !== 200) {
return;
}
function openInitialSettingsPage() {
API.read('OpenInitialSettingsPage');
}

// When refreshing the wallet, we should not show the failed KYC page anymore, as we should allow them to retry.
Onyx.merge(ONYXKEYS.USER_WALLET, {...response.userWallet, shouldShowFailedKYC: false});
});
/**
* Fetches data when the user opens the EnablePaymentsPage
*
* @typedef {Object} UserWallet
* @property {Number} availableBalance
* @property {Number} currentBalance
* @property {String} currentStep - used to track which step of the "activate wallet" flow a user is in
* @property {('SILVER'|'GOLD')} tierName - will be GOLD when fully activated. SILVER is able to recieve funds only.
*/
function openEnablePaymentsPage() {
API.read('OpenEnablePaymentsPage');
}

/**
Expand All @@ -513,7 +518,8 @@ function updateCurrentStep(currentStep) {
export {
fetchOnfidoToken,
activateWallet,
fetchUserWallet,
openInitialSettingsPage,
openEnablePaymentsPage,
setAdditionalDetailsErrors,
updateAdditionalDetailsDraft,
setAdditionalDetailsErrorMessage,
Expand Down
10 changes: 3 additions & 7 deletions src/pages/EnablePayments/EnablePaymentsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import ScreenWrapper from '../../components/ScreenWrapper';
import * as BankAccounts from '../../libs/actions/BankAccounts';
import * as Wallet from '../../libs/actions/Wallet';
import ONYXKEYS from '../../ONYXKEYS';
import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator';
import CONST from '../../CONST';
Expand Down Expand Up @@ -39,19 +39,15 @@ const defaultProps = {

class EnablePaymentsPage extends React.Component {
componentDidMount() {
this.fetchData();
Wallet.openEnablePaymentsPage();
}

componentDidUpdate(prevProps) {
if (!prevProps.network.isOffline || this.props.network.isOffline) {
return;
}

this.fetchData();
}

fetchData() {
BankAccounts.fetchUserWallet();
Wallet.openEnablePaymentsPage();
}

render() {
Expand Down
Loading