You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-05 23:10:41 +03:00
Switch rooms documentation and polishing
This commit is contained in:
@@ -83,7 +83,7 @@ import { objectHasDiff } from "../../utils/objects";
|
||||
import SpaceRoomView from "./SpaceRoomView";
|
||||
import { IOpts } from "../../createRoom";
|
||||
import {replaceableComponent} from "../../utils/replaceableComponent";
|
||||
import _ from 'lodash';
|
||||
import { omit } from 'lodash';
|
||||
|
||||
const DEBUG = false;
|
||||
let debuglog = function(msg: string) {};
|
||||
@@ -532,14 +532,16 @@ export default class RoomView extends React.Component<IProps, IState> {
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
const hasPropsDiff = objectHasDiff(this.props, nextProps);
|
||||
|
||||
// React only shallow comparison and we only want to trigger
|
||||
// a component re-render if a room requires an upgrade
|
||||
const newUpgradeRecommendation = nextState.upgradeRecommendation || {}
|
||||
|
||||
const state = _.omit(this.state, ['upgradeRecommendation']);
|
||||
const newState = _.omit(nextState, ['upgradeRecommendation'])
|
||||
const state = omit(this.state, ['upgradeRecommendation']);
|
||||
const newState = omit(nextState, ['upgradeRecommendation'])
|
||||
|
||||
const hasStateDiff =
|
||||
objectHasDiff(state, newState) ||
|
||||
(newUpgradeRecommendation && newUpgradeRecommendation.needsUpgrade === true)
|
||||
(newUpgradeRecommendation.needsUpgrade === true)
|
||||
|
||||
return hasPropsDiff || hasStateDiff;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user