From 13491e797dbf32c7bbfbcb1b095ddf3f383f5103 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 3 Dec 2018 10:39:31 +0100 Subject: [PATCH 1/2] persists & load collapsed room sub lists --- src/components/views/rooms/RoomList.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index d4599e5d8a9..10fce0ccf02 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -72,8 +72,9 @@ module.exports = React.createClass({ getInitialState: function() { const sizesJson = window.localStorage.getItem("mx_roomlist_sizes"); + const collapsedJson = window.localStorage.getItem("mx_roomlist_collapsed"); this.subListSizes = sizesJson ? JSON.parse(sizesJson) : {}; - + this.collapsedState = collapsedJson ? JSON.parse(collapsedJson) : {}; return { isLoadingLeftRooms: false, totalRoomCount: null, @@ -474,6 +475,11 @@ module.exports = React.createClass({ (filter[0] === '#' && room.getAliases().some((alias) => alias.toLowerCase().startsWith(lcFilter)))); }, + _persistCollapsedState: function(key, collapsed) { + this.collapsedState[key] = collapsed; + window.localStorage.setItem("mx_roomlist_collapsed", JSON.stringify(this.collapsedState)); + }, + _mapSubListProps: function(subListsProps) { const defaultProps = { collapsed: this.props.collapsed, @@ -493,10 +499,23 @@ module.exports = React.createClass({ return subListsProps.reduce((components, props, i) => { props = Object.assign({}, defaultProps, props); const isLast = i === subListsProps.length - 1; - const {key, label, ... otherProps} = props; + const {key, label, onHeaderClick, ... otherProps} = props; const chosenKey = key || label; + const onSubListHeaderClick = (collapsed) => { + this._persistCollapsedState(chosenKey, collapsed); + if (onHeaderClick) { + onHeaderClick(collapsed); + } + }; + const startAsHidden = props.startAsHidden || this.collapsedState[chosenKey]; + + let subList = (); - let subList = ; if (!isLast) { return components.concat( subList, From 541b0011ac91608ce2fd3114a7ebeb927a5061b8 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 3 Dec 2018 10:43:35 +0100 Subject: [PATCH 2/2] actually persist right panel width on resize --- src/components/structures/MainSplit.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/structures/MainSplit.js b/src/components/structures/MainSplit.js index a55feb65e44..ea3a97e161c 100644 --- a/src/components/structures/MainSplit.js +++ b/src/components/structures/MainSplit.js @@ -23,6 +23,11 @@ export default class MainSplit extends React.Component { constructor(props) { super(props); this._setResizeContainerRef = this._setResizeContainerRef.bind(this); + this._onResized = this._onResized.bind(this); + } + + _onResized(size) { + window.localStorage.setItem("mx_rhs_size", size); } _createResizer() { @@ -33,7 +38,9 @@ export default class MainSplit extends React.Component { }; const resizer = new Resizer( this.resizeContainer, - FixedDistributor); + FixedDistributor, + {onResized: this._onResized}, + ); resizer.setClassNames(classNames); const rhsSize = window.localStorage.getItem("mx_rhs_size"); if (rhsSize !== null) {