check overflow and restore sizes in more places inside RoomList:

check overflow on mount
restore size on query change (in case a sublist appeared)
check overflow when updating rooms

avoid duplicating for restoring size and checking overflow
pull/21833/head
Bruno Windels 2018-12-18 14:26:33 +01:00
parent b359a2edee
commit cdcb3c1a55
1 changed files with 30 additions and 11 deletions

View File

@ -152,6 +152,8 @@ module.exports = React.createClass({
} }
this.subListSizes[id] = newSize; this.subListSizes[id] = newSize;
window.localStorage.setItem("mx_roomlist_sizes", JSON.stringify(this.subListSizes)); window.localStorage.setItem("mx_roomlist_sizes", JSON.stringify(this.subListSizes));
// update overflow indicators
this._checkSubListsOverflow();
}, },
componentDidMount: function() { componentDidMount: function() {
@ -167,12 +169,10 @@ module.exports = React.createClass({
}); });
// load stored sizes // load stored sizes
Object.entries(this.subListSizes).forEach(([id, size]) => { Object.keys(this.subListSizes).forEach((key) => {
const handle = this.resizer.forHandleWithId(id); this._restoreSubListSize(key);
if (handle) {
handle.resize(size);
}
}); });
this._checkSubListsOverflow();
this.resizer.attach(); this.resizer.attach();
this.mounted = true; this.mounted = true;
@ -181,7 +181,11 @@ module.exports = React.createClass({
componentDidUpdate: function(prevProps) { componentDidUpdate: function(prevProps) {
this._repositionIncomingCallBox(undefined, false); this._repositionIncomingCallBox(undefined, false);
if (this.props.searchFilter !== prevProps.searchFilter) { if (this.props.searchFilter !== prevProps.searchFilter) {
Object.values(this._subListRefs).forEach(l => l.checkOverflow()); // restore sizes
Object.keys(this.subListSizes).forEach((key) => {
this._restoreSubListSize(key);
});
this._checkSubListsOverflow();
} }
}, },
@ -354,6 +358,12 @@ module.exports = React.createClass({
// Do this here so as to not render every time the selected tags // Do this here so as to not render every time the selected tags
// themselves change. // themselves change.
selectedTags: TagOrderStore.getSelectedTags(), selectedTags: TagOrderStore.getSelectedTags(),
}, () => {
// we don't need to restore any size here, do we?
// i guess we could have triggered a new group to appear
// that already an explicit size the last time it appeared ...
//
this._checkSubListsOverflow();
}); });
// this._lastRefreshRoomListTs = Date.now(); // this._lastRefreshRoomListTs = Date.now();
@ -491,14 +501,23 @@ module.exports = React.createClass({
window.localStorage.setItem("mx_roomlist_collapsed", JSON.stringify(this.collapsedState)); window.localStorage.setItem("mx_roomlist_collapsed", JSON.stringify(this.collapsedState));
// load the persisted size configuration of the expanded sub list // load the persisted size configuration of the expanded sub list
if (!collapsed) { if (!collapsed) {
this._restoreSubListSize(key);
}
// check overflow, as sub lists sizes have changed
// important this happens after calling resize above
this._checkSubListsOverflow();
},
_restoreSubListSize(key) {
const size = this.subListSizes[key]; const size = this.subListSizes[key];
const handle = this.resizer.forHandleWithId(key); const handle = this.resizer.forHandleWithId(key);
if (handle) { if (handle) {
handle.resize(size); handle.resize(size);
} }
} },
// check overflow, as sub lists sizes have changed
// important this happens after calling resize above // check overflow for scroll indicator gradient
_checkSubListsOverflow() {
Object.values(this._subListRefs).forEach(l => l.checkOverflow()); Object.values(this._subListRefs).forEach(l => l.checkOverflow());
}, },