-
{this.props.label}
- {rooms}
+
+ {({onFocus, isActive, ref}) => {
+ const tabIndex = isActive ? 0 : -1;
+
+ let badge;
+ if (true) { // !isCollapsed
+ const badgeClasses = classNames({
+ 'mx_RoomSubList_badge': true,
+ 'mx_RoomSubList_badgeHighlight': notifHighlight,
+ });
+ // Wrap the contents in a div and apply styles to the child div so that the browser default outline works
+ if (notifCount > 0) {
+ badge = (
+
+
+ {FormattingUtils.formatCount(notifCount)}
+
+
+ );
+ } else if (this.props.isInvite && this.hasTiles()) {
+ // Render the `!` badge for invites
+ badge = (
+
+
+ {FormattingUtils.formatCount(this.numTiles)}
+
+
+ );
+ }
+ }
+
+ let addRoomButton = null;
+ if (!!this.props.onAddRoom) {
+ addRoomButton = (
+
+ );
+ }
+
+ // TODO: a11y
+ return (
+
+
+ {chevron}
+ {this.props.label}
+
+ {badge}
+ {addRoomButton}
+
+ );
+ }}
+
+ );
+ }
+
+ public render(): React.ReactElement {
+ // TODO: Proper rendering
+ // TODO: Error boundary
+
+ const tiles = this.renderTiles();
+
+ const classes = classNames({
+ // TODO: Proper collapse support
+ 'mx_RoomSubList': true,
+ 'mx_RoomSubList_hidden': false, // len && isCollapsed
+ 'mx_RoomSubList_nonEmpty': this.hasTiles(), // len && !isCollapsed
+ });
+
+ let content = null;
+ if (tiles.length > 0) {
+ // TODO: Lazy list rendering
+ // TODO: Whatever scrolling magic needs to happen here
+ content = (
+
+ {tiles}
+
+ )
+ }
+
+ // TODO: onKeyDown support
+ return (
+
+ {this.renderHeader()}
+ {content}
);
}
diff --git a/src/components/views/rooms/RoomTile2.tsx b/src/components/views/rooms/RoomTile2.tsx
new file mode 100644
index 0000000000..cb9ce5cf1a
--- /dev/null
+++ b/src/components/views/rooms/RoomTile2.tsx
@@ -0,0 +1,118 @@
+/*
+Copyright 2015, 2016 OpenMarket Ltd
+Copyright 2017 New Vector Ltd
+Copyright 2018 Michael Telatynski <7t3chguy@gmail.com>
+Copyright 2019, 2020 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+import React, { createRef } from "react";
+import { Room } from "matrix-js-sdk/src/models/room";
+import classNames from "classnames";
+import { RovingTabIndexWrapper } from "../../../accessibility/RovingTabIndex";
+import AccessibleButton from "../../views/elements/AccessibleButton";
+import RoomAvatar from "../../views/avatars/RoomAvatar";
+
+interface IProps {
+ room: Room;
+
+ // TODO: Allow faslifying counts (for invites and stuff)
+ // TODO: Transparency?
+ // TODO: Incoming call?
+ // TODO: onClick
+}
+
+interface IState {
+}
+
+// TODO: Finish stub
+export default class RoomTile2 extends React.Component
{
+ private roomTile = createRef();
+
+ // TODO: Custom status
+ // TODO: Lock icon
+ // TODO: DM indicator
+ // TODO: Presence indicator
+ // TODO: e2e shields
+ // TODO: Handle changes to room aesthetics (name, join rules, etc)
+ // TODO: scrollIntoView?
+ // TODO: hover, badge, etc
+ // TODO: isSelected for hover effects
+ // TODO: Context menu
+ // TODO: a11y
+
+ public render(): React.ReactElement {
+ // TODO: Collapsed state
+ // TODO: Invites
+ // TODO: a11y proper
+ // TODO: Render more than bare minimum
+
+ const classes = classNames({
+ 'mx_RoomTile': true,
+ // 'mx_RoomTile_selected': this.state.selected,
+ // 'mx_RoomTile_unread': this.props.unread,
+ // 'mx_RoomTile_unreadNotify': notifBadges,
+ // 'mx_RoomTile_highlight': mentionBadges,
+ // 'mx_RoomTile_invited': isInvite,
+ // 'mx_RoomTile_menuDisplayed': isMenuDisplayed,
+ 'mx_RoomTile_noBadges': true, // !badges
+ // 'mx_RoomTile_transparent': this.props.transparent,
+ // 'mx_RoomTile_hasSubtext': subtext && !this.props.collapsed,
+ });
+
+ const avatarClasses = classNames({
+ 'mx_RoomTile_avatar': true,
+ });
+
+ // TODO: the original RoomTile uses state for the room name. Do we need to?
+ let name = this.props.room.name;
+ if (typeof name !== 'string') name = '';
+ name = name.replace(":", ":\u200b"); // add a zero-width space to allow linewrapping after the colon
+
+ const nameClasses = classNames({
+ 'mx_RoomTile_name': true,
+ 'mx_RoomTile_invite': false,
+ 'mx_RoomTile_badgeShown': false,
+ });
+
+ return (
+
+
+ {({onFocus, isActive, ref}) =>
+
+
+
+
+ }
+
+
+ );
+ }
+}
From df3d5c415917324a3784535c23fc695f5e3ff1ff Mon Sep 17 00:00:00 2001
From: Travis Ralston
Date: Mon, 11 May 2020 14:25:30 -0600
Subject: [PATCH 18/52] Update i18n for room list
---
src/i18n/strings/en_EN.json | 10 +++++-----
src/settings/Settings.js | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index fd474f378c..d6ff5f70eb 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -406,7 +406,7 @@
"Render simple counters in room header": "Render simple counters in room header",
"Multiple integration managers": "Multiple integration managers",
"Try out new ways to ignore people (experimental)": "Try out new ways to ignore people (experimental)",
- "Use the improved room list component (refresh to apply changes)": "Use the improved room list component (refresh to apply changes)",
+ "Use the improved room list component (refresh to apply changes, in development)": "Use the improved room list component (refresh to apply changes, in development)",
"Support adding custom themes": "Support adding custom themes",
"Enable cross-signing to verify per-user instead of per-session": "Enable cross-signing to verify per-user instead of per-session",
"Show info about bridges in room settings": "Show info about bridges in room settings",
@@ -1117,7 +1117,7 @@
"Low priority": "Low priority",
"Historical": "Historical",
"System Alerts": "System Alerts",
- "TODO": "TODO",
+ "Create room": "Create room",
"This room": "This room",
"Joining room …": "Joining room …",
"Loading …": "Loading …",
@@ -1161,6 +1161,9 @@
"Securely back up your keys to avoid losing them. Learn more.": "Securely back up your keys to avoid losing them. Learn more.",
"Not now": "Not now",
"Don't ask me again": "Don't ask me again",
+ "Jump to first unread room.": "Jump to first unread room.",
+ "Jump to first invite.": "Jump to first invite.",
+ "Add room": "Add room",
"Options": "Options",
"%(count)s unread messages including mentions.|other": "%(count)s unread messages including mentions.",
"%(count)s unread messages including mentions.|one": "1 unread mention.",
@@ -2052,9 +2055,6 @@
"Sent messages will be stored until your connection has returned.": "Sent messages will be stored until your connection has returned.",
"Active call": "Active call",
"There's no one else here! Would you like to invite others or stop warning about the empty room?": "There's no one else here! Would you like to invite others or stop warning about the empty room?",
- "Jump to first unread room.": "Jump to first unread room.",
- "Jump to first invite.": "Jump to first invite.",
- "Add room": "Add room",
"You seem to be uploading files, are you sure you want to quit?": "You seem to be uploading files, are you sure you want to quit?",
"You seem to be in a call, are you sure you want to quit?": "You seem to be in a call, are you sure you want to quit?",
"Search failed": "Search failed",
diff --git a/src/settings/Settings.js b/src/settings/Settings.js
index 554cf6b968..110fd4238b 100644
--- a/src/settings/Settings.js
+++ b/src/settings/Settings.js
@@ -133,7 +133,7 @@ export const SETTINGS = {
},
"feature_new_room_list": {
isFeature: true,
- displayName: _td("Use the improved room list component (refresh to apply changes)"),
+ displayName: _td("Use the improved room list component (refresh to apply changes, in development)"),
supportedLevels: LEVELS_FEATURE,
default: false,
},
From 9f0810240f6ae8d627708d8d51e4f058d0173f55 Mon Sep 17 00:00:00 2001
From: Travis Ralston
Date: Mon, 11 May 2020 16:12:45 -0600
Subject: [PATCH 19/52] Clean up imports and other minor lints
---
src/components/views/rooms/RoomList2.tsx | 2 +-
src/stores/room-list/RoomListStore2.ts | 5 ++---
src/stores/room-list/RoomListStoreTempProxy.ts | 4 +---
src/stores/room-list/algorithms/tag_sorting/index.ts | 2 +-
src/stores/room-list/membership.ts | 3 +--
src/stores/room-list/models.ts | 1 +
6 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/src/components/views/rooms/RoomList2.tsx b/src/components/views/rooms/RoomList2.tsx
index 9b0d4579f0..402a7af014 100644
--- a/src/components/views/rooms/RoomList2.tsx
+++ b/src/components/views/rooms/RoomList2.tsx
@@ -27,7 +27,7 @@ import { DefaultTagID, TagID } from "../../../stores/room-list/models";
import { Dispatcher } from "flux";
import { ActionPayload } from "../../../dispatcher-types";
import dis from "../../../dispatcher";
-import RoomSublist2 from "./RoomSublist2";
+import RoomSublist2 from "./RoomSublist2";
interface IProps {
onKeyDown: (ev: React.KeyboardEvent) => void;
diff --git a/src/stores/room-list/RoomListStore2.ts b/src/stores/room-list/RoomListStore2.ts
index 3a6d911dde..8bbcfc3c8d 100644
--- a/src/stores/room-list/RoomListStore2.ts
+++ b/src/stores/room-list/RoomListStore2.ts
@@ -21,11 +21,10 @@ import SettingsStore from "../../settings/SettingsStore";
import { DefaultTagID, OrderedDefaultTagIDs, RoomUpdateCause, TagID } from "./models";
import { Algorithm } from "./algorithms/list_ordering/Algorithm";
import TagOrderStore from "../TagOrderStore";
-import { getListAlgorithmInstance } from "./algorithms/list_ordering";
import { AsyncStore } from "../AsyncStore";
-import { ITagMap, ITagSortingMap, ListAlgorithm, SortAlgorithm } from "./algorithms/models";
import { Room } from "matrix-js-sdk/src/models/room";
-import { MatrixEvent } from "matrix-js-sdk/src/models/event";
+import { ITagMap, ITagSortingMap, ListAlgorithm, SortAlgorithm } from "./algorithms/models";
+import { getListAlgorithmInstance } from "./algorithms/list_ordering";
interface IState {
tagsEnabled?: boolean;
diff --git a/src/stores/room-list/RoomListStoreTempProxy.ts b/src/stores/room-list/RoomListStoreTempProxy.ts
index 4edca2b9cd..0268cf0a46 100644
--- a/src/stores/room-list/RoomListStoreTempProxy.ts
+++ b/src/stores/room-list/RoomListStoreTempProxy.ts
@@ -14,13 +14,11 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import { TagID } from "./models";
-import { Room } from "matrix-js-sdk/src/models/room";
import SettingsStore from "../../settings/SettingsStore";
import RoomListStore from "./RoomListStore2";
import OldRoomListStore from "../RoomListStore";
-import { ITagMap } from "./algorithms/models";
import { UPDATE_EVENT } from "../AsyncStore";
+import { ITagMap } from "./algorithms/models";
/**
* Temporary RoomListStore proxy. Should be replaced with RoomListStore2 when
diff --git a/src/stores/room-list/algorithms/tag_sorting/index.ts b/src/stores/room-list/algorithms/tag_sorting/index.ts
index 07f8f484d8..155c0f0118 100644
--- a/src/stores/room-list/algorithms/tag_sorting/index.ts
+++ b/src/stores/room-list/algorithms/tag_sorting/index.ts
@@ -19,7 +19,7 @@ import { SortAlgorithm } from "../models";
import { ManualAlgorithm } from "./ManualAlgorithm";
import { IAlgorithm } from "./IAlgorithm";
import { TagID } from "../../models";
-import {Room} from "matrix-js-sdk/src/models/room";
+import { Room } from "matrix-js-sdk/src/models/room";
const ALGORITHM_INSTANCES: { [algorithm in SortAlgorithm]: IAlgorithm } = {
[SortAlgorithm.Recent]: new ChaoticAlgorithm(),
diff --git a/src/stores/room-list/membership.ts b/src/stores/room-list/membership.ts
index 884e2a4a04..3cb4bf146c 100644
--- a/src/stores/room-list/membership.ts
+++ b/src/stores/room-list/membership.ts
@@ -14,8 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import {Room} from "matrix-js-sdk/src/models/room";
-import {Event} from "matrix-js-sdk/src/models/event";
+import { Room } from "matrix-js-sdk/src/models/room";
/**
* Approximation of a membership status for a given room.
diff --git a/src/stores/room-list/models.ts b/src/stores/room-list/models.ts
index 5294680773..428378a7aa 100644
--- a/src/stores/room-list/models.ts
+++ b/src/stores/room-list/models.ts
@@ -23,6 +23,7 @@ export enum DefaultTagID {
DM = "im.vector.fake.direct",
ServerNotice = "m.server_notice",
}
+
export const OrderedDefaultTagIDs = [
DefaultTagID.Invite,
DefaultTagID.Favourite,
From 715dd7e1b6126ec0f858d80af1873917d9ebe714 Mon Sep 17 00:00:00 2001
From: Travis Ralston
Date: Mon, 11 May 2020 16:20:26 -0600
Subject: [PATCH 20/52] Prepare tooltip for collapsed support
---
src/components/views/rooms/RoomTile2.tsx | 28 ++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/components/views/rooms/RoomTile2.tsx b/src/components/views/rooms/RoomTile2.tsx
index cb9ce5cf1a..21ba32ae75 100644
--- a/src/components/views/rooms/RoomTile2.tsx
+++ b/src/components/views/rooms/RoomTile2.tsx
@@ -23,6 +23,7 @@ import classNames from "classnames";
import { RovingTabIndexWrapper } from "../../../accessibility/RovingTabIndex";
import AccessibleButton from "../../views/elements/AccessibleButton";
import RoomAvatar from "../../views/avatars/RoomAvatar";
+import Tooltip from "../../views/elements/Tooltip";
interface IProps {
room: Room;
@@ -34,6 +35,7 @@ interface IProps {
}
interface IState {
+ hover: boolean;
}
// TODO: Finish stub
@@ -52,6 +54,22 @@ export default class RoomTile2 extends React.Component {
// TODO: Context menu
// TODO: a11y
+ constructor(props: IProps) {
+ super(props);
+
+ this.state = {
+ hover: false,
+ };
+ }
+
+ private onTileMouseEnter = () => {
+ this.setState({hover: true});
+ };
+
+ private onTileMouseLeave = () => {
+ this.setState({hover: false});
+ };
+
public render(): React.ReactElement {
// TODO: Collapsed state
// TODO: Invites
@@ -86,6 +104,13 @@ export default class RoomTile2 extends React.Component {
'mx_RoomTile_badgeShown': false,
});
+ let tooltip = null;
+ if (false) { // isCollapsed
+ if (this.state.hover) {
+ tooltip =
+ }
+ }
+
return (
@@ -95,6 +120,8 @@ export default class RoomTile2 extends React.Component {
tabIndex={isActive ? 0 : -1}
inputRef={ref}
className={classes}
+ onMouseEnter={this.onTileMouseEnter}
+ onMouseLeave={this.onTileMouseLeave}
role="treeitem"
>
@@ -109,6 +136,7 @@ export default class RoomTile2 extends React.Component {