Skip to content

Commit

Permalink
update onReconnect registered functions'
Browse files Browse the repository at this point in the history
  • Loading branch information
luacmartins committed May 2, 2022
1 parent 980420e commit 054bb14
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/libs/actions/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as Report from './Report';
import * as GeoLocation from './GeoLocation';
import UnreadIndicatorUpdater from '../UnreadIndicatorUpdater';
import * as BankAccounts from './BankAccounts';
import NetworkConnection from '../NetworkConnection';

let currentUserAccountID;
Onyx.connect({
Expand Down Expand Up @@ -90,8 +91,10 @@ function triggerUpdateAvailable() {
Onyx.set(ONYXKEYS.UPDATE_AVAILABLE, true);
}

/**
* Fetches data needed for app initialization
*/
function getAppData() {
// Fetch some data we need on initialization
NameValuePair.get(CONST.NVP.PRIORITY_MODE, ONYXKEYS.NVP_PRIORITY_MODE, 'default');
NameValuePair.get(CONST.NVP.IS_FIRST_TIME_NEW_EXPENSIFY_USER, ONYXKEYS.NVP_IS_FIRST_TIME_NEW_EXPENSIFY_USER, true);
getLocale();
Expand All @@ -107,6 +110,9 @@ function getAppData() {
BankAccounts.fetchUserWallet();
}

// When the app reconnects from being offline, fetch all initialization data
NetworkConnection.onReconnect(getAppData);

export {
setCurrentURL,
setLocale,
Expand Down
4 changes: 0 additions & 4 deletions src/libs/actions/PersonalDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Onyx from 'react-native-onyx';
import Str from 'expensify-common/lib/str';
import ONYXKEYS from '../../ONYXKEYS';
import CONST from '../../CONST';
import NetworkConnection from '../NetworkConnection';
import * as API from '../API';
import NameValuePair from './NameValuePair';
import * as LoginUtils from '../LoginUtils';
Expand Down Expand Up @@ -371,9 +370,6 @@ function deleteAvatar(defaultAvatarURL) {
mergeLocalPersonalDetails({avatar: defaultAvatarURL});
}

// When the app reconnects from being offline, fetch all of the personal details
NetworkConnection.onReconnect(fetchPersonalDetails);

export {
fetchPersonalDetails,
formatPersonalDetails,
Expand Down
3 changes: 0 additions & 3 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1380,9 +1380,6 @@ Onyx.connect({
callback: handleReportChanged,
});

// When the app reconnects from being offline, fetch all of the reports and their actions
NetworkConnection.onReconnect(fetchAllReports);

/**
* Saves a new message for a comment. Marks the comment as edited, which will be reflected in the UI.
*
Expand Down

0 comments on commit 054bb14

Please sign in to comment.