Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove full screen loading logs #14374

Merged
merged 4 commits into from
Jan 20, 2023
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
1 change: 0 additions & 1 deletion src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ const CONST = {
REPORT_ACTION_ITEM_LAYOUT_DEBOUNCE_TIME: 1500,
SHOW_LOADING_SPINNER_DEBOUNCE_TIME: 250,
TOOLTIP_SENSE: 1000,
SPINNER_TIMEOUT: 15 * 1000,
TRIE_INITIALIZATION: 'trie_initialization',
},
PRIORITY_MODE: {
Expand Down
61 changes: 8 additions & 53 deletions src/components/FullscreenLoadingIndicator.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,27 @@
import _ from 'underscore';
import React from 'react';
import PropTypes from 'prop-types';
import {ActivityIndicator, StyleSheet, View} from 'react-native';
import styles from '../styles/styles';
import themeColors from '../styles/themes/default';
import stylePropTypes from '../styles/stylePropTypes';
import Log from '../libs/Log';
import CONST from '../CONST';

const propTypes = {
/**
* Context info printed in timing log.
* Providing this prop would capture logs for mounting/unmounting and staying visible for too long
*/
logDetail: PropTypes.shape({
/** Name is used to distinct the loader in captured logs. */
name: PropTypes.string.isRequired,
}),

/** Additional style props */
style: stylePropTypes,
};

const defaultProps = {
style: [],
logDetail: null,
};

class FullScreenLoadingIndicator extends React.Component {
componentDidMount() {
if (!this.props.logDetail) {
return;
}

if (!this.props.logDetail.name) {
throw new Error('A name should be set to distinct logged messages. Please check the `logDetails` prop.');
}

Log.info('[LoadingIndicator] Became visible', false, this.props.logDetail);

this.timeoutID = setTimeout(
() => Log.alert(
`${CONST.ERROR.ENSURE_BUGBOT} [LoadingIndicator] Visible after timeout`,
{timeout: CONST.TIMING.SPINNER_TIMEOUT, ...this.props.logDetail},
false,
),
CONST.TIMING.SPINNER_TIMEOUT,
);
}

componentWillUnmount() {
if (!this.timeoutID) {
return;
}

clearTimeout(this.timeoutID);
Log.info('[LoadingIndicator] Disappeared', false, this.props.logDetail);
}

render() {
const additionalStyles = _.isArray(this.props.style) ? this.props.style : [this.props.style];
return (
<View style={[StyleSheet.absoluteFillObject, styles.fullScreenLoading, ...additionalStyles]}>
<ActivityIndicator color={themeColors.spinner} size="large" />
</View>
);
}
}
const FullScreenLoadingIndicator = (props) => {
const additionalStyles = _.isArray(props.style) ? props.style : [props.style];
return (
<View style={[StyleSheet.absoluteFillObject, styles.fullScreenLoading, ...additionalStyles]}>
<ActivityIndicator color={themeColors.spinner} size="large" />
</View>
);
};

FullScreenLoadingIndicator.propTypes = propTypes;
FullScreenLoadingIndicator.defaultProps = defaultProps;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/AppNavigator/MainDrawerNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class MainDrawerNavigator extends Component {
render() {
// Wait until reports are fetched and there is a reportID in initialParams
if (!this.initialParams.reportID) {
return <FullScreenLoadingIndicator logDetail={{name: 'Main Drawer Loader', initialParams: this.initialParams}} />;
return <FullScreenLoadingIndicator />;
}

// After the app initializes and reports are available the home navigation is mounted
Expand Down
1 change: 0 additions & 1 deletion src/libs/Navigation/NavigationRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const NavigationRoot = (props) => {
<NavigationContainer
fallback={(
<FullScreenLoadingIndicator
logDetail={{name: 'Navigation Fallback Loader', authenticated: props.authenticated}}
style={styles.navigatorFullScreenLoading}
/>
)}
Expand Down