Enable the new room list by default and trigger an initial render

We have to trigger an initial render because during the login process the user will have started syncing (causing lists to generate) but the RoomList component won't be mounted & listening and therefore won't receive the initial lists. By generating them on mount, we ensure that the lists are present once the user gets through the login process.
pull/21833/head
Travis Ralston 2020-07-02 14:23:56 -06:00
parent 9fec5c98af
commit 1b782ce5f2
2 changed files with 19 additions and 12 deletions

View File

@ -166,8 +166,16 @@ export default class RoomList2 extends React.Component<IProps, IState> {
} }
public componentDidMount(): void { public componentDidMount(): void {
RoomListStore.instance.on(LISTS_UPDATE_EVENT, (store: RoomListStore2) => { RoomListStore.instance.on(LISTS_UPDATE_EVENT, this.updateLists);
const newLists = store.orderedLists; this.updateLists(); // trigger the first update
}
public componentWillUnmount() {
RoomListStore.instance.off(LISTS_UPDATE_EVENT, this.updateLists);
}
private updateLists = () => {
const newLists = RoomListStore.instance.orderedLists;
console.log("new lists", newLists); console.log("new lists", newLists);
const layoutMap = new Map<TagID, ListLayout>(); const layoutMap = new Map<TagID, ListLayout>();
@ -176,8 +184,7 @@ export default class RoomList2 extends React.Component<IProps, IState> {
} }
this.setState({sublists: newLists, layouts: layoutMap}); this.setState({sublists: newLists, layouts: layoutMap});
}); };
}
private renderCommunityInvites(): React.ReactElement[] { private renderCommunityInvites(): React.ReactElement[] {
// TODO: Put community invites in a more sensible place (not in the room list) // TODO: Put community invites in a more sensible place (not in the room list)

View File

@ -150,7 +150,7 @@ export const SETTINGS = {
isFeature: true, isFeature: true,
displayName: _td("Use the improved room list (will refresh to apply changes)"), displayName: _td("Use the improved room list (will refresh to apply changes)"),
supportedLevels: LEVELS_FEATURE, supportedLevels: LEVELS_FEATURE,
default: false, default: true,
controller: new ReloadOnChangeController(), controller: new ReloadOnChangeController(),
}, },
"feature_custom_themes": { "feature_custom_themes": {