extract always visible logic to RoomList
This commit is contained in:
parent
b9f80b49ad
commit
f1453e8d2b
2 changed files with 10 additions and 6 deletions
|
@ -86,6 +86,10 @@ const TAG_ORDER: TagID[] = [
|
||||||
DefaultTagID.Archived,
|
DefaultTagID.Archived,
|
||||||
];
|
];
|
||||||
const CUSTOM_TAGS_BEFORE_TAG = DefaultTagID.LowPriority;
|
const CUSTOM_TAGS_BEFORE_TAG = DefaultTagID.LowPriority;
|
||||||
|
const ALWAYS_VISIBLE_TAGS: TagID[] = [
|
||||||
|
DefaultTagID.DM,
|
||||||
|
DefaultTagID.Untagged,
|
||||||
|
];
|
||||||
|
|
||||||
interface ITagAesthetics {
|
interface ITagAesthetics {
|
||||||
sectionLabel: string;
|
sectionLabel: string;
|
||||||
|
@ -526,6 +530,9 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
||||||
: this.tagAesthetics[orderedTagId];
|
: this.tagAesthetics[orderedTagId];
|
||||||
if (!aesthetics) throw new Error(`Tag ${orderedTagId} does not have aesthetics`);
|
if (!aesthetics) throw new Error(`Tag ${orderedTagId} does not have aesthetics`);
|
||||||
|
|
||||||
|
// The cost of mounting/unmounting this component all the time
|
||||||
|
// offsets the memory cost of keeping it at all time and hiding
|
||||||
|
// it when no results are found
|
||||||
components.push(<RoomSublist
|
components.push(<RoomSublist
|
||||||
key={`sublist-${orderedTagId}`}
|
key={`sublist-${orderedTagId}`}
|
||||||
tagId={orderedTagId}
|
tagId={orderedTagId}
|
||||||
|
@ -539,6 +546,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
||||||
onResize={this.props.onResize}
|
onResize={this.props.onResize}
|
||||||
showSkeleton={showSkeleton}
|
showSkeleton={showSkeleton}
|
||||||
extraTiles={extraTiles}
|
extraTiles={extraTiles}
|
||||||
|
alwaysVisible={!ALWAYS_VISIBLE_TAGS.includes(orderedTagId)}
|
||||||
/>);
|
/>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,11 +60,6 @@ export const HEADER_HEIGHT = 32; // As defined by CSS
|
||||||
|
|
||||||
const MAX_PADDING_HEIGHT = SHOW_N_BUTTON_HEIGHT + RESIZE_HANDLE_HEIGHT;
|
const MAX_PADDING_HEIGHT = SHOW_N_BUTTON_HEIGHT + RESIZE_HANDLE_HEIGHT;
|
||||||
|
|
||||||
const ALWAYS_VISIBLE_TAGS: TagID[] = [
|
|
||||||
DefaultTagID.DM,
|
|
||||||
DefaultTagID.Untagged,
|
|
||||||
];
|
|
||||||
|
|
||||||
// HACK: We really shouldn't have to do this.
|
// HACK: We really shouldn't have to do this.
|
||||||
polyfillTouchEvent();
|
polyfillTouchEvent();
|
||||||
|
|
||||||
|
@ -79,6 +74,7 @@ interface IProps {
|
||||||
tagId: TagID;
|
tagId: TagID;
|
||||||
onResize: () => void;
|
onResize: () => void;
|
||||||
showSkeleton?: boolean;
|
showSkeleton?: boolean;
|
||||||
|
alwaysVisible?: boolean;
|
||||||
|
|
||||||
extraTiles?: ReactComponentElement<typeof ExtraTile>[];
|
extraTiles?: ReactComponentElement<typeof ExtraTile>[];
|
||||||
|
|
||||||
|
@ -767,7 +763,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
||||||
'mx_RoomSublist': true,
|
'mx_RoomSublist': true,
|
||||||
'mx_RoomSublist_hasMenuOpen': !!this.state.contextMenuPosition,
|
'mx_RoomSublist_hasMenuOpen': !!this.state.contextMenuPosition,
|
||||||
'mx_RoomSublist_minimized': this.props.isMinimized,
|
'mx_RoomSublist_minimized': this.props.isMinimized,
|
||||||
'mx_RoomSublist_hidden': !this.state.rooms.length && !ALWAYS_VISIBLE_TAGS.includes(this.props.tagId),
|
'mx_RoomSublist_hidden': !this.state.rooms.length && this.props.alwaysVisible !== true,
|
||||||
});
|
});
|
||||||
|
|
||||||
let content = null;
|
let content = null;
|
||||||
|
|
Loading…
Reference in a new issue