mirror of https://github.com/jitsi/jitsi-meet
The basic indicator is extracted into a LoadingIndicator component, which then NetworkActivityIndicator displays (or not) based on network activity.pull/1984/head
parent
21d419e517
commit
35da39becf
@ -0,0 +1,24 @@ |
||||
/* @flow */ |
||||
|
||||
import React, { Component } from 'react'; |
||||
import { ActivityIndicator } from 'react-native'; |
||||
|
||||
/** |
||||
* Simple wrapper around React Native's {@code ActivityIndicator}, which |
||||
* displays an animated (large) loading indicator. |
||||
*/ |
||||
export default class LoadingIndicator extends Component { |
||||
/** |
||||
* Implements React's {@link Component#render()}. |
||||
* |
||||
* @inheritdoc |
||||
* @returns {ReactElement} |
||||
*/ |
||||
render() { |
||||
return ( |
||||
<ActivityIndicator |
||||
animating = { true } |
||||
size = { 'large' } /> |
||||
); |
||||
} |
||||
} |
@ -1,3 +1,4 @@ |
||||
export { default as Container } from './Container'; |
||||
export { default as Link } from './Link'; |
||||
export { default as LoadingIndicator } from './LoadingIndicator'; |
||||
export { default as Text } from './Text'; |
||||
|
@ -0,0 +1,58 @@ |
||||
/* @flow */ |
||||
|
||||
import PropTypes from 'prop-types'; |
||||
import React, { Component } from 'react'; |
||||
import { connect } from 'react-redux'; |
||||
|
||||
import { LoadingIndicator } from '../../../base/react'; |
||||
|
||||
/** |
||||
* The React <tt>Component</tt> which renders a progress indicator when there |
||||
* are ongoing network requests. |
||||
*/ |
||||
class NetworkActivityIndicator extends Component { |
||||
/** |
||||
* <tt>NetworkActivityIndicator</tt> React <tt>Component</tt>'s prop types. |
||||
* |
||||
* @static |
||||
*/ |
||||
static propTypes = { |
||||
/** |
||||
* Indicates whether there is network activity i.e. ongoing network |
||||
* requests. |
||||
* |
||||
* @private |
||||
*/ |
||||
_networkActivity: PropTypes.bool |
||||
}; |
||||
|
||||
/** |
||||
* Implements React's {@link Component#render()}. |
||||
* |
||||
* @inheritdoc |
||||
* @returns {ReactElement} |
||||
*/ |
||||
render() { |
||||
return this.props._networkActivity ? <LoadingIndicator /> : null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Maps (parts of) the redux state to the React <tt>Component</tt> props of |
||||
* <tt>NetworkActivityIndicator</tt>. |
||||
* |
||||
* @param {Object} state - The redux state. |
||||
* @private |
||||
* @returns {{ |
||||
* _networkActivity: boolean |
||||
* }} |
||||
*/ |
||||
function _mapStateToProps(state) { |
||||
const { requests } = state['features/network-activity']; |
||||
|
||||
return { |
||||
_networkActivity: Boolean(requests && requests.size) |
||||
}; |
||||
} |
||||
|
||||
export default connect(_mapStateToProps)(NetworkActivityIndicator); |
@ -0,0 +1,3 @@ |
||||
export { |
||||
default as NetworkActivityIndicator |
||||
} from './NetworkActivityIndicator'; |
@ -1,2 +1,4 @@ |
||||
export * from './components'; |
||||
|
||||
import './middleware'; |
||||
import './reducer'; |
||||
|
Loading…
Reference in new issue