Merge pull request #6202 from matrix-org/t3chguy/fix/17669
commit
ccf30ed94c
|
@ -41,7 +41,7 @@ export function getUnsentMessages(room) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@replaceableComponent("structures.RoomStatusBar")
|
@replaceableComponent("structures.RoomStatusBar")
|
||||||
export default class RoomStatusBar extends React.Component {
|
export default class RoomStatusBar extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
// the room this statusbar is representing.
|
// the room this statusbar is representing.
|
||||||
room: PropTypes.object.isRequired,
|
room: PropTypes.object.isRequired,
|
||||||
|
|
|
@ -80,7 +80,6 @@ import { objectHasDiff } from "../../utils/objects";
|
||||||
import SpaceRoomView from "./SpaceRoomView";
|
import SpaceRoomView from "./SpaceRoomView";
|
||||||
import { IOpts } from "../../createRoom";
|
import { IOpts } from "../../createRoom";
|
||||||
import { replaceableComponent } from "../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../utils/replaceableComponent";
|
||||||
import { omit } from 'lodash';
|
|
||||||
import UIStore from "../../stores/UIStore";
|
import UIStore from "../../stores/UIStore";
|
||||||
|
|
||||||
const DEBUG = false;
|
const DEBUG = false;
|
||||||
|
@ -572,16 +571,12 @@ export default class RoomView extends React.Component<IProps, IState> {
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
const hasPropsDiff = objectHasDiff(this.props, nextProps);
|
const hasPropsDiff = objectHasDiff(this.props, nextProps);
|
||||||
|
|
||||||
// React only shallow comparison and we only want to trigger
|
const { upgradeRecommendation, ...state } = this.state;
|
||||||
// a component re-render if a room requires an upgrade
|
const { upgradeRecommendation: newUpgradeRecommendation, ...newState } = nextState;
|
||||||
const newUpgradeRecommendation = nextState.upgradeRecommendation || {}
|
|
||||||
|
|
||||||
const state = omit(this.state, ['upgradeRecommendation']);
|
|
||||||
const newState = omit(nextState, ['upgradeRecommendation'])
|
|
||||||
|
|
||||||
const hasStateDiff =
|
const hasStateDiff =
|
||||||
objectHasDiff(state, newState) ||
|
newUpgradeRecommendation?.needsUpgrade !== upgradeRecommendation?.needsUpgrade ||
|
||||||
(newUpgradeRecommendation.needsUpgrade === true)
|
objectHasDiff(state, newState);
|
||||||
|
|
||||||
return hasPropsDiff || hasStateDiff;
|
return hasPropsDiff || hasStateDiff;
|
||||||
}
|
}
|
||||||
|
@ -706,12 +701,6 @@ export default class RoomView extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private onLayoutChange = () => {
|
|
||||||
this.setState({
|
|
||||||
layout: SettingsStore.getValue("layout"),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
private onRightPanelStoreUpdate = () => {
|
private onRightPanelStoreUpdate = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
showRightPanel: RightPanelStore.getSharedInstance().isOpenForRoom,
|
showRightPanel: RightPanelStore.getSharedInstance().isOpenForRoom,
|
||||||
|
@ -1645,29 +1634,27 @@ export default class RoomView extends React.Component<IProps, IState> {
|
||||||
let auxPanelMaxHeight = UIStore.instance.windowHeight -
|
let auxPanelMaxHeight = UIStore.instance.windowHeight -
|
||||||
(54 + // height of RoomHeader
|
(54 + // height of RoomHeader
|
||||||
36 + // height of the status area
|
36 + // height of the status area
|
||||||
51 + // minimum height of the message compmoser
|
51 + // minimum height of the message composer
|
||||||
120); // amount of desired scrollback
|
120); // amount of desired scrollback
|
||||||
|
|
||||||
// XXX: this is a bit of a hack and might possibly cause the video to push out the page anyway
|
// XXX: this is a bit of a hack and might possibly cause the video to push out the page anyway
|
||||||
// but it's better than the video going missing entirely
|
// but it's better than the video going missing entirely
|
||||||
if (auxPanelMaxHeight < 50) auxPanelMaxHeight = 50;
|
if (auxPanelMaxHeight < 50) auxPanelMaxHeight = 50;
|
||||||
|
|
||||||
this.setState({auxPanelMaxHeight: auxPanelMaxHeight});
|
if (this.state.auxPanelMaxHeight !== auxPanelMaxHeight) {
|
||||||
|
this.setState({ auxPanelMaxHeight });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private onStatusBarVisible = () => {
|
private onStatusBarVisible = () => {
|
||||||
if (this.unmounted) return;
|
if (this.unmounted || this.state.statusBarVisible) return;
|
||||||
this.setState({
|
this.setState({ statusBarVisible: true });
|
||||||
statusBarVisible: true,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private onStatusBarHidden = () => {
|
private onStatusBarHidden = () => {
|
||||||
// This is currently not desired as it is annoying if it keeps expanding and collapsing
|
// This is currently not desired as it is annoying if it keeps expanding and collapsing
|
||||||
if (this.unmounted) return;
|
if (this.unmounted || !this.state.statusBarVisible) return;
|
||||||
this.setState({
|
this.setState({ statusBarVisible: false });
|
||||||
statusBarVisible: false,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -82,13 +82,6 @@ export default class AppsDrawer extends React.Component {
|
||||||
this.props.resizeNotifier.off("isResizing", this.onIsResizing);
|
this.props.resizeNotifier.off("isResizing", this.onIsResizing);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: [REACT-WARNING] Replace with appropriate lifecycle event
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
UNSAFE_componentWillReceiveProps(newProps) {
|
|
||||||
// Room has changed probably, update apps
|
|
||||||
this._updateApps();
|
|
||||||
}
|
|
||||||
|
|
||||||
onIsResizing = (resizing) => {
|
onIsResizing = (resizing) => {
|
||||||
// This one is the vertical, ie. change height of apps drawer
|
// This one is the vertical, ie. change height of apps drawer
|
||||||
this.setState({ resizingVertical: resizing });
|
this.setState({ resizingVertical: resizing });
|
||||||
|
@ -141,7 +134,10 @@ export default class AppsDrawer extends React.Component {
|
||||||
_getAppsHash = (apps) => apps.map(app => app.id).join("~");
|
_getAppsHash = (apps) => apps.map(app => app.id).join("~");
|
||||||
|
|
||||||
componentDidUpdate(prevProps, prevState) {
|
componentDidUpdate(prevProps, prevState) {
|
||||||
if (this._getAppsHash(this.state.apps) !== this._getAppsHash(prevState.apps)) {
|
if (prevProps.userId !== this.props.userId || prevProps.room !== this.props.room) {
|
||||||
|
// Room has changed, update apps
|
||||||
|
this._updateApps();
|
||||||
|
} else if (this._getAppsHash(this.state.apps) !== this._getAppsHash(prevState.apps)) {
|
||||||
this._loadResizerPreferences();
|
this._loadResizerPreferences();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,19 +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 dis from "../../../dispatcher/dispatcher";
|
|
||||||
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
|
||||||
|
@ -69,19 +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();
|
||||||
cli.on("RoomState.events", this._rateLimitedUpdate);
|
if (SettingsStore.getValue("feature_state_counters")) {
|
||||||
|
cli.on("RoomState.events", this.rateLimitedUpdate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
if (cli) {
|
if (cli && SettingsStore.getValue("feature_state_counters")) {
|
||||||
cli.removeListener("RoomState.events", this._rateLimitedUpdate);
|
cli.removeListener("RoomState.events", this.rateLimitedUpdate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,23 +97,11 @@ export default class AuxPanel extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onConferenceNotificationClick = (ev, type) => {
|
private rateLimitedUpdate = new RateLimitedFunc(() => {
|
||||||
dis.dispatch({
|
this.setState({ counters: this.computeCounters() });
|
||||||
action: 'place_call',
|
|
||||||
type: type,
|
|
||||||
room_id: this.props.room.roomId,
|
|
||||||
});
|
|
||||||
ev.stopPropagation();
|
|
||||||
ev.preventDefault();
|
|
||||||
};
|
|
||||||
|
|
||||||
_rateLimitedUpdate = new RateLimitedFunc(() => {
|
|
||||||
if (SettingsStore.getValue("feature_state_counters")) {
|
|
||||||
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")) {
|
||||||
|
@ -225,7 +214,7 @@ export default class AuxPanel extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AutoHideScrollbar className={classes} style={style} >
|
<AutoHideScrollbar className={classes} style={style}>
|
||||||
{ stateViews }
|
{ stateViews }
|
||||||
{ appsDrawer }
|
{ appsDrawer }
|
||||||
{ callView }
|
{ callView }
|
||||||
|
|
|
@ -24,7 +24,7 @@ import {MatrixClientPeg} from "../../../MatrixClientPeg";
|
||||||
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
||||||
|
|
||||||
@replaceableComponent("views.rooms.RoomUpgradeWarningBar")
|
@replaceableComponent("views.rooms.RoomUpgradeWarningBar")
|
||||||
export default class RoomUpgradeWarningBar extends React.Component {
|
export default class RoomUpgradeWarningBar extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
room: PropTypes.object.isRequired,
|
room: PropTypes.object.isRequired,
|
||||||
recommendation: PropTypes.object.isRequired,
|
recommendation: PropTypes.object.isRequired,
|
||||||
|
|
Loading…
Reference in New Issue