tidy AuxPanel TS

pull/21833/head
Michael Telatynski 2021-06-16 12:07:58 +01:00
parent d87325ae6a
commit 626d575820
1 changed files with 10 additions and 10 deletions

View File

@ -15,18 +15,18 @@ limitations under the License.
*/ */
import React from 'react'; import React from 'react';
import {MatrixClientPeg} from "../../../MatrixClientPeg"; import { MatrixClientPeg } from "../../../MatrixClientPeg";
import { Room } from 'matrix-js-sdk/src/models/room' import { Room } from 'matrix-js-sdk/src/models/room'
import AppsDrawer from './AppsDrawer'; import AppsDrawer from './AppsDrawer';
import classNames from 'classnames'; import classNames from 'classnames';
import RateLimitedFunc from '../../../ratelimitedfunc'; import RateLimitedFunc from '../../../ratelimitedfunc';
import SettingsStore from "../../../settings/SettingsStore"; import SettingsStore from "../../../settings/SettingsStore";
import AutoHideScrollbar from "../../structures/AutoHideScrollbar"; import AutoHideScrollbar from "../../structures/AutoHideScrollbar";
import {UIFeature} from "../../../settings/UIFeature"; import { UIFeature } from "../../../settings/UIFeature";
import { ResizeNotifier } from "../../../utils/ResizeNotifier"; import { ResizeNotifier } from "../../../utils/ResizeNotifier";
import CallViewForRoom from '../voip/CallViewForRoom'; import CallViewForRoom from '../voip/CallViewForRoom';
import {objectHasDiff} from "../../../utils/objects"; import { objectHasDiff } from "../../../utils/objects";
import {replaceableComponent} from "../../../utils/replaceableComponent"; import { replaceableComponent } from "../../../utils/replaceableComponent";
interface IProps { interface IProps {
// js-sdk room object // js-sdk room object
@ -68,21 +68,21 @@ export default class AuxPanel extends React.Component<IProps, IState> {
super(props); super(props);
this.state = { this.state = {
counters: this._computeCounters(), counters: this.computeCounters(),
}; };
} }
componentDidMount() { componentDidMount() {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
if (SettingsStore.getValue("feature_state_counters")) { if (SettingsStore.getValue("feature_state_counters")) {
cli.on("RoomState.events", this._rateLimitedUpdate); cli.on("RoomState.events", this.rateLimitedUpdate);
} }
} }
componentWillUnmount() { componentWillUnmount() {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
if (cli && SettingsStore.getValue("feature_state_counters")) { if (cli && SettingsStore.getValue("feature_state_counters")) {
cli.removeListener("RoomState.events", this._rateLimitedUpdate); cli.removeListener("RoomState.events", this.rateLimitedUpdate);
} }
} }
@ -97,11 +97,11 @@ export default class AuxPanel extends React.Component<IProps, IState> {
} }
} }
_rateLimitedUpdate = new RateLimitedFunc(() => { private rateLimitedUpdate = new RateLimitedFunc(() => {
this.setState({ counters: this._computeCounters() }); this.setState({ counters: this.computeCounters() });
}, 500); }, 500);
_computeCounters() { private computeCounters() {
const counters = []; const counters = [];
if (this.props.room && SettingsStore.getValue("feature_state_counters")) { if (this.props.room && SettingsStore.getValue("feature_state_counters")) {