mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2025-12-30 19:32:27 +00:00
Up until now we relied on implicit loading of middlewares and reducers, through having imports in each feature's index.js. This leads to many complex import cycles which result in (sometimes) hard to fix bugs in addition to (often) breaking mobile because a web-only feature gets imported on mobile too, thanks to the implicit loading. This PR changes that to make the process explicit. Both middlewares and reducers are imported in a single place, the app entrypoint. They have been divided into 3 categories: any, web and native, which represent each of the platforms respectively. Ideally no feature should have an index.js exporting actions, action types and components, but that's a larger ordeal, so this is just the first step in getting there. In order to both set example and avoid large cycles the app feature has been refactored to not have an idex.js itself.
81 lines
1.8 KiB
JavaScript
81 lines
1.8 KiB
JavaScript
// @flow
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { reloadNow } from '../../../app/actions';
|
|
import { translate } from '../../../base/i18n';
|
|
import { connect } from '../../../base/redux';
|
|
|
|
/**
|
|
* The type of the React {@code Component} props of {@link ReloadButton}.
|
|
*/
|
|
type Props = {
|
|
|
|
/**
|
|
* Reloads the page.
|
|
*/
|
|
_reloadNow: Function,
|
|
|
|
/**
|
|
* The function to translate human-readable text.
|
|
*/
|
|
t: Function,
|
|
|
|
/**
|
|
* The translation key for the text in the button.
|
|
*/
|
|
textKey: string
|
|
};
|
|
|
|
/**
|
|
* Implements a React Component for button for the overlays that will reload
|
|
* the page.
|
|
*/
|
|
class ReloadButton extends Component<Props> {
|
|
/**
|
|
* Renders the button for relaod the page if necessary.
|
|
*
|
|
* @private
|
|
* @returns {ReactElement}
|
|
*/
|
|
render() {
|
|
const className
|
|
= 'button-control button-control_overlay button-control_center';
|
|
|
|
/* eslint-disable react/jsx-handler-names */
|
|
|
|
return (
|
|
<button
|
|
className = { className }
|
|
onClick = { this.props._reloadNow }>
|
|
{ this.props.t(this.props.textKey) }
|
|
</button>
|
|
);
|
|
|
|
/* eslint-enable react/jsx-handler-names */
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Maps part of redux actions to component's props.
|
|
*
|
|
* @param {Function} dispatch - Redux's {@code dispatch} function.
|
|
* @private
|
|
* @returns {Object}
|
|
*/
|
|
function _mapDispatchToProps(dispatch: Function): Object {
|
|
return {
|
|
/**
|
|
* Dispatches the redux action to reload the page.
|
|
*
|
|
* @protected
|
|
* @returns {Object} Dispatched action.
|
|
*/
|
|
_reloadNow() {
|
|
dispatch(reloadNow());
|
|
}
|
|
};
|
|
}
|
|
|
|
export default translate(connect(undefined, _mapDispatchToProps)(ReloadButton));
|