delint Modal.js

pull/21833/head
David Baker 2019-04-05 10:18:41 +01:00
parent 590535c569
commit cd0dcc2668
2 changed files with 13 additions and 17 deletions

View File

@ -59,7 +59,6 @@ src/languageHandler.js
src/linkify-matrix.js src/linkify-matrix.js
src/Markdown.js src/Markdown.js
src/MatrixClientPeg.js src/MatrixClientPeg.js
src/Modal.js
src/notifications/ContentRules.js src/notifications/ContentRules.js
src/notifications/PushRuleVectorState.js src/notifications/PushRuleVectorState.js
src/notifications/VectorPushRulesDefinitions.js src/notifications/VectorPushRulesDefinitions.js

View File

@ -20,7 +20,6 @@ limitations under the License.
const React = require('react'); const React = require('react');
const ReactDOM = require('react-dom'); const ReactDOM = require('react-dom');
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import classNames from 'classnames';
import Analytics from './Analytics'; import Analytics from './Analytics';
import sdk from './index'; import sdk from './index';
import dis from './dispatcher'; import dis from './dispatcher';
@ -76,10 +75,9 @@ const AsyncWrapper = React.createClass({
}, },
render: function() { render: function() {
const {loader, ...otherProps} = this.props;
if (this.state.component) { if (this.state.component) {
const Component = this.state.component; const Component = this.state.component;
return <Component {...otherProps} />; return <Component {...this.props} />;
} else if (this.state.error) { } else if (this.state.error) {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const DialogButtons = sdk.getComponent('views.elements.DialogButtons'); const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
@ -194,36 +192,35 @@ class ModalManager {
* also be removed from the stack. This is not compatible * also be removed from the stack. This is not compatible
* with being a priority modal. Only one modal can be * with being a priority modal. Only one modal can be
* static at a time. * static at a time.
* @returns {object} Object with 'close' parameter being a function that will close the dialog
*/ */
createDialogAsync(prom, props, className, isPriorityModal, isStaticModal) { createDialogAsync(prom, props, className, isPriorityModal, isStaticModal) {
const self = this;
const modal = {}; const modal = {};
// never call this from onFinished() otherwise it will loop // never call this from onFinished() otherwise it will loop
// //
// nb explicit function() rather than arrow function, to get `arguments` const closeDialog = (...args) => {
const closeDialog = function() { if (props && props.onFinished) props.onFinished.apply(null, args);
if (props && props.onFinished) props.onFinished.apply(null, arguments); const i = this._modals.indexOf(modal);
const i = self._modals.indexOf(modal);
if (i >= 0) { if (i >= 0) {
self._modals.splice(i, 1); this._modals.splice(i, 1);
} }
if (self._priorityModal === modal) { if (this._priorityModal === modal) {
self._priorityModal = null; this._priorityModal = null;
// XXX: This is destructive // XXX: This is destructive
self._modals = []; this._modals = [];
} }
if (self._staticModal === modal) { if (this._staticModal === modal) {
self._staticModal = null; this._staticModal = null;
// XXX: This is destructive // XXX: This is destructive
self._modals = []; this._modals = [];
} }
self._reRender(); this._reRender();
}; };
// don't attempt to reuse the same AsyncWrapper for different dialogs, // don't attempt to reuse the same AsyncWrapper for different dialogs,