Skip to content

Commit

Permalink
Merge pull request #6476 from kidroca/kidroca/add-splash-related-logs
Browse files Browse the repository at this point in the history
Add splash screen related logs
  • Loading branch information
NikkiWines authored Dec 2, 2021
2 parents 970c2d5 + ae6568d commit f92580d
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/Expensify.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'underscore';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React, {PureComponent} from 'react';
Expand Down Expand Up @@ -74,6 +75,8 @@ class Expensify extends PureComponent {
}

componentDidMount() {
setTimeout(() => this.reportBootSplashStatus(), 30 * 1000);

// This timer is set in the native layer when launching the app and we stop it here so we can measure how long
// it took for the main app itself to load.
StartupTimer.stop();
Expand Down Expand Up @@ -107,7 +110,7 @@ class Expensify extends PureComponent {
// that we can remove it again once the content is ready
const previousAuthToken = lodashGet(prevProps, 'session.authToken', null);
if (this.getAuthToken() && !previousAuthToken) {
BootSplash.show({fade: true});
this.showSplash();
}

if (this.getAuthToken() && this.props.initialReportDataLoaded && this.props.isSidebarLoaded) {
Expand All @@ -131,8 +134,28 @@ class Expensify extends PureComponent {
ActiveClientManager.init();
}

showSplash() {
Log.info('[BootSplash] showing splash screen', false);
BootSplash.show({fade: true});
}

hideSplash() {
BootSplash.hide({fade: true});
Log.info('[BootSplash] hiding splash screen', false);
BootSplash.hide({fade: true})
.catch(error => Log.alert('[BootSplash] hiding failed', {message: error.message, error}, false));
}

reportBootSplashStatus() {
BootSplash.getVisibilityStatus()
.then((status) => {
Log.info('[BootSplash] splash screen status', false, {status});

if (status === 'visible') {
const props = _.omit(this.props, ['children', 'session']);
props.hasAuthToken = !_.isEmpty(this.getAuthToken());
Log.alert('[BootSplash] splash screen is still visible', {props}, false);
}
});
}

render() {
Expand Down

0 comments on commit f92580d

Please sign in to comment.