Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

WIP: New memberlist + MVVM #12948

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ module.exports = {
"src/components/views/messages/MVoiceMessageBody.tsx",
"src/components/views/right_panel/EncryptionPanel.tsx",
"src/components/views/rooms/EntityTile.tsx",
"src/components/views/rooms/EntityTileRefactored.tsx",
"src/components/views/rooms/LinkPreviewGroup.tsx",
"src/components/views/rooms/MemberList.tsx",
"src/components/views/rooms/MessageComposer.tsx",
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"@matrix-org/spec": "^1.7.0",
"@sentry/browser": "^8.0.0",
"@testing-library/react-hooks": "^8.0.1",
"@types/react-virtualized": "^9.21.30",
"@vector-im/compound-design-tokens": "^1.8.0",
"@vector-im/compound-web": "^5.5.0",
"@zxcvbn-ts/core": "^3.0.4",
Expand Down Expand Up @@ -120,6 +121,7 @@
"matrix-widget-api": "^1.8.2",
"memoize-one": "^6.0.0",
"minimist": "^1.2.5",
"observable-hooks": "^4.2.3",
"oidc-client-ts": "^3.0.1",
"opus-recorder": "^8.0.3",
"pako": "^2.0.3",
Expand All @@ -133,7 +135,9 @@
"react-dom": "17.0.2",
"react-focus-lock": "^2.5.1",
"react-transition-group": "^4.4.1",
"react-virtualized": "^9.22.5",
"rfc4648": "^1.4.0",
"rxjs": "^7.8.1",
"sanitize-filename": "^1.6.3",
"sanitize-html": "2.13.0",
"tar-js": "^0.3.0",
Expand Down
5 changes: 5 additions & 0 deletions res/css/structures/_RightPanel.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@ limitations under the License.
order: 2;
margin: auto;
}

.mx_MemberList_container {
height: 100%;
}

64 changes: 41 additions & 23 deletions src/components/structures/RightPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import RoomSummaryCard from "../views/right_panel/RoomSummaryCard";
import WidgetCard from "../views/right_panel/WidgetCard";
import SettingsStore from "../../settings/SettingsStore";
import MemberList from "../views/rooms/MemberList";
import UserInfo from "../views/right_panel/UserInfo";
import ThirdPartyMemberInfo from "../views/rooms/ThirdPartyMemberInfo";
import FilePanel from "./FilePanel";
Expand All @@ -42,6 +41,11 @@
import { IRightPanelCard, IRightPanelCardState } from "../../stores/right-panel/RightPanelStoreIPanelState";
import { Action } from "../../dispatcher/actions";
import { XOR } from "../../@types/common";
import { MatrixClientPeg } from "../../MatrixClientPeg";
import { inviteToRoom } from "../../utils/room/inviteToRoom";
import MemberList from "../views/rooms/MemberList";

Check failure on line 46 in src/components/structures/RightPanel.tsx

View workflow job for this annotation

GitHub Actions / ESLint

'MemberList' is defined but never used

Check failure on line 46 in src/components/structures/RightPanel.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

'MemberList' is declared but its value is never read.
import { SpaceScopeHeader } from "../views/rooms/SpaceScopeHeader";

Check failure on line 47 in src/components/structures/RightPanel.tsx

View workflow job for this annotation

GitHub Actions / ESLint

'SpaceScopeHeader' is defined but never used

Check failure on line 47 in src/components/structures/RightPanel.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

'SpaceScopeHeader' is declared but its value is never read.

Check failure on line 47 in src/components/structures/RightPanel.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Cannot find module '../views/rooms/SpaceScopeHeader' or its corresponding type declarations.
import MemberListNext from "../views/rooms/MemberListNext";
import { RightPanelTabs } from "../views/right_panel/RightPanelTabs";
import ExtensionsCard from "../views/right_panel/ExtensionsCard";

Expand All @@ -67,7 +71,6 @@

interface IState {
phase?: RightPanelPhases;
searchQuery: string;
cardState?: IRightPanelCardState;
}

Expand All @@ -78,9 +81,7 @@
public constructor(props: Props, context: React.ContextType<typeof MatrixClientContext>) {
super(props, context);

this.state = {
searchQuery: "",
};
this.state = {};
}

private readonly delayedUpdate = throttle(
Expand Down Expand Up @@ -157,8 +158,19 @@
}
};

private onSearchQueryChanged = (searchQuery: string): void => {
this.setState({ searchQuery });
private onThreePIDInviteClick = (eventId: string): void => {

Check failure on line 161 in src/components/structures/RightPanel.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

'onThreePIDInviteClick' is declared but its value is never read.
const inviteEvent = this.props.room?.findEventById(eventId);
if (!inviteEvent) return;
dis.dispatch({
action: Action.View3pidInvite,
event: inviteEvent,
});
};

private onInviteButtonClick = (roomId: string): void => {

Check failure on line 170 in src/components/structures/RightPanel.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

'onInviteButtonClick' is declared but its value is never read.
const cli = MatrixClientPeg.safeGet();
const room = cli.getRoom(roomId)!;
inviteToRoom(room);
};

public render(): React.ReactNode {
Expand All @@ -170,27 +182,33 @@
case RightPanelPhases.RoomMemberList:
if (!!roomId) {
card = (
<MemberList
roomId={roomId}
key={roomId}
hideHeaderButtons
onClose={this.onClose}
searchQuery={this.state.searchQuery}
onSearchQueryChanged={this.onSearchQueryChanged}
/>
<MemberListNext roomId={roomId} />
// <MemberList
// roomId={roomId}
// key={roomId}
// hideHeaderButtons
// onClose={this.onClose}
// searchQuery={this.state.searchQuery}
// onSearchQueryChanged={this.onSearchQueryChanged}
// />
);
}
break;
case RightPanelPhases.SpaceMemberList:
if (!!cardState?.spaceId || !!roomId) {
const targetRoomId = cardState?.spaceId ?? roomId

Check failure on line 198 in src/components/structures/RightPanel.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected lexical declaration in case block
if (!!targetRoomId) {
// const cli = MatrixClientPeg.safeGet();
// const room = cli.getRoom(roomId);
// const spaceHeader = room ? <SpaceScopeHeader room={room} /> : undefined;
card = (
<MemberList
roomId={cardState?.spaceId ?? roomId!}
key={cardState?.spaceId ?? roomId!}
onClose={this.onClose}
searchQuery={this.state.searchQuery}
onSearchQueryChanged={this.onSearchQueryChanged}
/>
<MemberListNext roomId={targetRoomId} />
// <MemberList
// roomId={cardState?.spaceId ?? roomId!}
// key={cardState?.spaceId ?? roomId!}
// onClose={this.onClose}
// searchQuery={this.state.searchQuery}
// onSearchQueryChanged={this.onSearchQueryChanged}
// />
);
}
break;
Expand Down
57 changes: 57 additions & 0 deletions src/components/views/avatars/MemberAvatarNext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Copyright 2024 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, { forwardRef, Ref } from "react";

import BaseAvatar from "./BaseAvatar";
import { _t } from "../../../languageHandler";
import { RoomMember } from "../../../models/rooms/RoomMember";
import { AvatarThumbnailData, avatarUrl } from "../../../models/rooms/AvatarThumbnailData";

interface IProps {
member: RoomMember;
size: string;
resizeMethod?: "crop" | "scale";
}

function MemberAvatarNext({ size, resizeMethod = "crop", member }: IProps, ref: Ref<HTMLElement>): JSX.Element {
let imageUrl = null;
const avatarThumbnailUrl = member.avatarThumbnailUrl;

if (!!avatarThumbnailUrl) {
const data: AvatarThumbnailData = {
src: avatarThumbnailUrl,
width: parseInt(size, 10),
height: parseInt(size, 10),
resizeMethod: resizeMethod,
};
imageUrl = avatarUrl(data);
}

return (
<BaseAvatar
size={size}
name={member.name}
idName={member.userId}
title={member.displayUserId}
url={imageUrl}
altText={_t("common|user_avatar")}
ref={ref}
/>
);
}

export default forwardRef(MemberAvatarNext);
3 changes: 2 additions & 1 deletion src/components/views/dialogs/UntrustedDeviceDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import { User } from "matrix-js-sdk/src/matrix";

import { _t } from "../../../languageHandler";
import { MatrixClientPeg } from "../../../MatrixClientPeg";
import E2EIcon, { E2EState } from "../rooms/E2EIcon";
import E2EIcon from "../rooms/E2EIcon";
import { E2EState } from "../../../models/rooms/E2EState";
import AccessibleButton from "../elements/AccessibleButton";
import BaseDialog from "./BaseDialog";
import { IDevice } from "../right_panel/UserInfo";
Expand Down
10 changes: 8 additions & 2 deletions src/components/views/messages/DisambiguatedProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ limitations under the License.
*/

import React from "react";
import { RoomMember } from "matrix-js-sdk/src/matrix";
import classNames from "classnames";

import { _t } from "../../../languageHandler";
import { getUserNameColorClass } from "../../../utils/FormattingUtils";
import UserIdentifier from "../../../customisations/UserIdentifier";

interface DisambiguatedMemberInfo {
userId: string;
roomId: string;
rawDisplayName?: string;
disambiguate: boolean;
}

interface IProps {
member?: RoomMember | null;
member?: DisambiguatedMemberInfo | null;
fallbackName: string;
onClick?(): void;
colored?: boolean;
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/right_panel/VerificationPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import { MatrixClientPeg } from "../../../MatrixClientPeg";
import VerificationQRCode from "../elements/crypto/VerificationQRCode";
import { _t } from "../../../languageHandler";
import SdkConfig from "../../../SdkConfig";
import E2EIcon, { E2EState } from "../rooms/E2EIcon";
import E2EIcon from "../rooms/E2EIcon";
import { E2EState } from "../../../models/rooms/E2EState";
import Spinner from "../elements/Spinner";
import AccessibleButton from "../elements/AccessibleButton";
import VerificationShowSas from "../verification/VerificationShowSas";
Expand Down
9 changes: 1 addition & 8 deletions src/components/views/rooms/E2EIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,7 @@ import { _t, _td, TranslationKey } from "../../../languageHandler";
import AccessibleButton from "../elements/AccessibleButton";
import { E2EStatus } from "../../../utils/ShieldUtils";
import { XOR } from "../../../@types/common";

export enum E2EState {
Verified = "verified",
Warning = "warning",
Unknown = "unknown",
Normal = "normal",
Unauthenticated = "unauthenticated",
}
import { E2EState } from "../../../models/rooms/E2EState";

const crossSigningUserTitles: { [key in E2EState]?: TranslationKey } = {
[E2EState.Warning]: _td("encryption|cross_signing_user_warning"),
Expand Down
6 changes: 3 additions & 3 deletions src/components/views/rooms/EntityTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import classNames from "classnames";

import AccessibleButton from "../elements/AccessibleButton";
import { _t, _td, TranslationKey } from "../../../languageHandler";
import E2EIcon, { E2EState } from "./E2EIcon";
import E2EIcon from "./E2EIcon";
import { E2EState } from "../../../models/rooms/E2EState";
import BaseAvatar from "../avatars/BaseAvatar";
import PresenceLabel from "./PresenceLabel";
import { PresenceState } from "../../../models/rooms/PresenceState";

export enum PowerStatus {
Admin = "admin",
Expand All @@ -35,8 +37,6 @@ const PowerLabel: Record<PowerStatus, TranslationKey> = {
[PowerStatus.Moderator]: _td("power_level|mod"),
};

export type PresenceState = "offline" | "online" | "unavailable" | "io.element.unreachable";

const PRESENCE_CLASS: Record<PresenceState, string> = {
"offline": "mx_EntityTile_offline",
"online": "mx_EntityTile_online",
Expand Down
Loading
Loading