mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 09:46:09 +03:00
use ResizeNotifier as well to relayout room list
This commit is contained in:
parent
58f26ee9b0
commit
9541cc175f
4 changed files with 16 additions and 6 deletions
|
@ -234,7 +234,7 @@ const LeftPanel = React.createClass({
|
|||
<CallPreview ConferenceHandler={VectorConferenceHandler} />
|
||||
<RoomList
|
||||
ref={this.collectRoomList}
|
||||
toolbarShown={this.props.toolbarShown}
|
||||
resizeNotifier={this.props.resizeNotifier}
|
||||
collapsed={this.props.collapsed}
|
||||
searchFilter={this.state.searchFilter}
|
||||
ConferenceHandler={VectorConferenceHandler} />
|
||||
|
|
|
@ -543,7 +543,7 @@ const LoggedInView = React.createClass({
|
|||
<DragDropContext onDragEnd={this._onDragEnd}>
|
||||
<div ref={this._setResizeContainerRef} className={bodyClasses}>
|
||||
<LeftPanel
|
||||
toolbarShown={!!topBar}
|
||||
resizeNotifier={this.props.resizeNotifier}
|
||||
collapsed={this.props.collapseLhs || false}
|
||||
disabled={this.props.leftDisabled}
|
||||
/>
|
||||
|
|
|
@ -212,7 +212,7 @@ module.exports = React.createClass({
|
|||
this._checkSubListsOverflow();
|
||||
|
||||
this.resizer.attach();
|
||||
window.addEventListener("resize", this.onWindowResize);
|
||||
this.props.resizeNotifier.on("leftPanelResized", this.onResize);
|
||||
this.mounted = true;
|
||||
},
|
||||
|
||||
|
@ -260,7 +260,6 @@ module.exports = React.createClass({
|
|||
componentWillUnmount: function() {
|
||||
this.mounted = false;
|
||||
|
||||
window.removeEventListener("resize", this.onWindowResize);
|
||||
dis.unregister(this.dispatcherRef);
|
||||
if (MatrixClientPeg.get()) {
|
||||
MatrixClientPeg.get().removeListener("Room", this.onRoom);
|
||||
|
@ -272,6 +271,8 @@ module.exports = React.createClass({
|
|||
MatrixClientPeg.get().removeListener("Group.myMembership", this._onGroupMyMembership);
|
||||
MatrixClientPeg.get().removeListener("RoomState.events", this.onRoomStateEvents);
|
||||
}
|
||||
this.props.resizeNotifier.removeListener("leftPanelResized", this.onResize);
|
||||
|
||||
|
||||
if (this._tagStoreToken) {
|
||||
this._tagStoreToken.remove();
|
||||
|
@ -293,13 +294,14 @@ module.exports = React.createClass({
|
|||
this._delayedRefreshRoomList.cancelPendingCall();
|
||||
},
|
||||
|
||||
onWindowResize: function() {
|
||||
|
||||
onResize: function() {
|
||||
if (this.mounted && this._layout && this.resizeContainer &&
|
||||
Array.isArray(this._layoutSections)
|
||||
) {
|
||||
this._layout.update(
|
||||
this._layoutSections,
|
||||
this.resizeContainer.offsetHeight
|
||||
this.resizeContainer.offsetHeight,
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -31,11 +31,13 @@ export default class ResizeNotifier extends EventEmitter {
|
|||
}
|
||||
|
||||
notifyBannersChanged() {
|
||||
this.emit("leftPanelResized");
|
||||
this.emit("middlePanelResized");
|
||||
}
|
||||
|
||||
// can be called in quick succession
|
||||
notifyLeftHandleResized() {
|
||||
// don't emit event for own region
|
||||
this._throttledMiddlePanel();
|
||||
}
|
||||
|
||||
|
@ -46,6 +48,12 @@ export default class ResizeNotifier extends EventEmitter {
|
|||
|
||||
// can be called in quick succession
|
||||
notifyWindowResized() {
|
||||
// no need to throttle this one,
|
||||
// also it could make scrollbars appear for
|
||||
// a split second when the room list manual layout is now
|
||||
// taller than the available space
|
||||
this.emit("leftPanelResized");
|
||||
|
||||
this._throttledMiddlePanel();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue