From 5a44a0f3c45e5a94426c755a3a4b3f68a3cbecb7 Mon Sep 17 00:00:00 2001 From: Mikhail Aheichyk Date: Mon, 13 Feb 2023 21:02:56 +0300 Subject: [PATCH 01/11] Room joining via module is possible with any 'history_visibility' Signed-off-by: Mikhail Aheichyk --- src/components/structures/RoomView.tsx | 5 +++++ src/components/views/rooms/RoomPreviewBar.tsx | 11 +++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 6e2b72cf9f0..5ace5b2bb63 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -1903,6 +1903,7 @@ export class RoomView extends React.Component { loading={loading} joining={this.state.joining} oobData={this.props.oobData} + roomId={this.state.roomId} /> @@ -1933,6 +1934,7 @@ export class RoomView extends React.Component { oobData={this.props.oobData} signUrl={this.props.threepidInvite?.signUrl} room={this.state.room} + roomId={this.state.roomId} /> @@ -1969,6 +1971,7 @@ export class RoomView extends React.Component { error={this.state.roomLoadError} joining={this.state.joining} rejecting={this.state.rejecting} + roomId={this.state.roomId} /> ); @@ -1998,6 +2001,7 @@ export class RoomView extends React.Component { canPreview={false} joining={this.state.joining} room={this.state.room} + roomId={this.state.roomId} /> @@ -2090,6 +2094,7 @@ export class RoomView extends React.Component { oobData={this.props.oobData} canPreview={this.state.canPeek} room={this.state.room} + roomId={this.state.roomId} /> ); if (!this.state.canPeek && !this.state.room?.isSpaceRoom()) { diff --git a/src/components/views/rooms/RoomPreviewBar.tsx b/src/components/views/rooms/RoomPreviewBar.tsx index 84a88791444..89d832956f3 100644 --- a/src/components/views/rooms/RoomPreviewBar.tsx +++ b/src/components/views/rooms/RoomPreviewBar.tsx @@ -57,6 +57,7 @@ enum MessageCase { } interface IProps { + roomId: string; // if inviterName is specified, the preview bar will shown an invite to the room. // You should also specify onRejectClick if specifying inviterName inviterName?: string; @@ -310,18 +311,12 @@ export default class RoomPreviewBar extends React.Component { } case MessageCase.NotLoggedIn: { const opts: RoomPreviewOpts = { canJoin: false }; - if (this.props.room?.roomId) { - ModuleRunner.instance.invoke( - RoomViewLifecycle.PreviewRoomNotLoggedIn, - opts, - this.props.room.roomId, - ); - } + ModuleRunner.instance.invoke(RoomViewLifecycle.PreviewRoomNotLoggedIn, opts, this.props.roomId); if (opts.canJoin) { title = _t("Join the room to participate"); primaryActionLabel = _t("Join"); primaryActionHandler = () => { - ModuleRunner.instance.invoke(RoomViewLifecycle.JoinFromRoomPreview, this.props.room.roomId); + ModuleRunner.instance.invoke(RoomViewLifecycle.JoinFromRoomPreview, this.props.roomId); }; } else { title = _t("Join the conversation with an account"); From cf18de7674ec7d6364f0a437b4fcb1f5210d5cca Mon Sep 17 00:00:00 2001 From: Mikhail Aheichyk Date: Tue, 14 Feb 2023 22:17:29 +0300 Subject: [PATCH 02/11] test fix, field comment update Signed-off-by: Mikhail Aheichyk --- src/components/views/rooms/RoomPreviewBar.tsx | 4 ++++ test/components/views/rooms/RoomPreviewBar-test.tsx | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/RoomPreviewBar.tsx b/src/components/views/rooms/RoomPreviewBar.tsx index 89d832956f3..b06492d619f 100644 --- a/src/components/views/rooms/RoomPreviewBar.tsx +++ b/src/components/views/rooms/RoomPreviewBar.tsx @@ -57,7 +57,9 @@ enum MessageCase { } interface IProps { + // The id of the room to be previewed roomId: string; + // if inviterName is specified, the preview bar will shown an invite to the room. // You should also specify onRejectClick if specifying inviterName inviterName?: string; @@ -77,6 +79,8 @@ interface IProps { canPreview?: boolean; previewLoading?: boolean; + + // The room to be previewed room?: Room; loading?: boolean; diff --git a/test/components/views/rooms/RoomPreviewBar-test.tsx b/test/components/views/rooms/RoomPreviewBar-test.tsx index ae8a388c249..c335d8c6e14 100644 --- a/test/components/views/rooms/RoomPreviewBar-test.tsx +++ b/test/components/views/rooms/RoomPreviewBar-test.tsx @@ -71,8 +71,9 @@ describe("", () => { const inviterUserId = "@inviter:test.com"; const otherUserId = "@othertester:test.com"; - const getComponent = (props: ComponentProps = {}) => { + const getComponent = (props: Omit, 'roomId'> = {}) => { const defaultProps = { + roomId, room: createRoom(roomId, userId), }; return render(); From a75326086b54547b0c039c36259eb2c9f3a2eaa0 Mon Sep 17 00:00:00 2001 From: Mikhail Aheichyk Date: Tue, 14 Feb 2023 23:40:33 +0300 Subject: [PATCH 03/11] test fix Signed-off-by: Mikhail Aheichyk --- test/components/views/rooms/RoomPreviewBar-test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/components/views/rooms/RoomPreviewBar-test.tsx b/test/components/views/rooms/RoomPreviewBar-test.tsx index c335d8c6e14..bfd21041fce 100644 --- a/test/components/views/rooms/RoomPreviewBar-test.tsx +++ b/test/components/views/rooms/RoomPreviewBar-test.tsx @@ -325,7 +325,7 @@ describe("", () => { { medium: "not-email", address: "address 2" }, ]; - const testJoinButton = (props: ComponentProps) => async () => { + const testJoinButton = (props: Omit, 'roomId'>) => async () => { const onJoinClick = jest.fn(); const onRejectClick = jest.fn(); const component = getComponent({ ...props, onJoinClick, onRejectClick }); From e0c119cb23fd8e965d0c1fc60c4fc8bb579ff1ea Mon Sep 17 00:00:00 2001 From: Mikhail Aheichyk Date: Fri, 17 Feb 2023 11:51:42 +0300 Subject: [PATCH 04/11] RoomPreviewBar roomId is optional Signed-off-by: Mikhail Aheichyk --- src/components/views/rooms/RoomPreviewBar.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/RoomPreviewBar.tsx b/src/components/views/rooms/RoomPreviewBar.tsx index b06492d619f..d27f7f10b71 100644 --- a/src/components/views/rooms/RoomPreviewBar.tsx +++ b/src/components/views/rooms/RoomPreviewBar.tsx @@ -58,7 +58,7 @@ enum MessageCase { interface IProps { // The id of the room to be previewed - roomId: string; + roomId?: string; // if inviterName is specified, the preview bar will shown an invite to the room. // You should also specify onRejectClick if specifying inviterName @@ -315,7 +315,9 @@ export default class RoomPreviewBar extends React.Component { } case MessageCase.NotLoggedIn: { const opts: RoomPreviewOpts = { canJoin: false }; - ModuleRunner.instance.invoke(RoomViewLifecycle.PreviewRoomNotLoggedIn, opts, this.props.roomId); + if (this.props.roomId) { + ModuleRunner.instance.invoke(RoomViewLifecycle.PreviewRoomNotLoggedIn, opts, this.props.roomId); + } if (opts.canJoin) { title = _t("Join the room to participate"); primaryActionLabel = _t("Join"); From 56afd78f914e6e475108ab61612e3f2aa1aec3d0 Mon Sep 17 00:00:00 2001 From: Mikhail Aheichyk Date: Fri, 17 Feb 2023 11:55:43 +0300 Subject: [PATCH 05/11] room prop not needed, this.state.room is falsey in this case Signed-off-by: Mikhail Aheichyk --- src/components/structures/RoomView.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 5ace5b2bb63..1a29d2f8668 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -1933,7 +1933,6 @@ export class RoomView extends React.Component { invitedEmail={invitedEmail} oobData={this.props.oobData} signUrl={this.props.threepidInvite?.signUrl} - room={this.state.room} roomId={this.state.roomId} /> From 7bb6f64fdac87ec5e7ed8807d85851e8950a5fb4 Mon Sep 17 00:00:00 2001 From: Mikhail Aheichyk Date: Tue, 21 Feb 2023 11:21:02 +0300 Subject: [PATCH 06/11] prettier Signed-off-by: Mikhail Aheichyk --- test/components/views/rooms/RoomPreviewBar-test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/components/views/rooms/RoomPreviewBar-test.tsx b/test/components/views/rooms/RoomPreviewBar-test.tsx index bfd21041fce..ff2b8664372 100644 --- a/test/components/views/rooms/RoomPreviewBar-test.tsx +++ b/test/components/views/rooms/RoomPreviewBar-test.tsx @@ -71,7 +71,7 @@ describe("", () => { const inviterUserId = "@inviter:test.com"; const otherUserId = "@othertester:test.com"; - const getComponent = (props: Omit, 'roomId'> = {}) => { + const getComponent = (props: Omit, "roomId"> = {}) => { const defaultProps = { roomId, room: createRoom(roomId, userId), @@ -325,7 +325,7 @@ describe("", () => { { medium: "not-email", address: "address 2" }, ]; - const testJoinButton = (props: Omit, 'roomId'>) => async () => { + const testJoinButton = (props: Omit, "roomId">) => async () => { const onJoinClick = jest.fn(); const onRejectClick = jest.fn(); const component = getComponent({ ...props, onJoinClick, onRejectClick }); From 4a8d6e4767aa5c2712c90fb3c2b5a6042c8f2c74 Mon Sep 17 00:00:00 2001 From: Mikhail Aheichyk Date: Tue, 21 Feb 2023 12:59:07 +0300 Subject: [PATCH 07/11] comment updated Signed-off-by: Mikhail Aheichyk --- src/components/views/rooms/RoomPreviewBar.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/views/rooms/RoomPreviewBar.tsx b/src/components/views/rooms/RoomPreviewBar.tsx index abe5b801730..16350ffa696 100644 --- a/src/components/views/rooms/RoomPreviewBar.tsx +++ b/src/components/views/rooms/RoomPreviewBar.tsx @@ -81,6 +81,7 @@ interface IProps { previewLoading?: boolean; // The room to be previewed + // If given, the room passed is peekable room?: Room; loading?: boolean; From 0dc08071f34fe860ab1c3830603499426ec904c7 Mon Sep 17 00:00:00 2001 From: maheichyk Date: Tue, 21 Feb 2023 18:07:35 +0300 Subject: [PATCH 08/11] Update src/components/views/rooms/RoomPreviewBar.tsx roomId description update Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- src/components/views/rooms/RoomPreviewBar.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/RoomPreviewBar.tsx b/src/components/views/rooms/RoomPreviewBar.tsx index 16350ffa696..b45e73857a1 100644 --- a/src/components/views/rooms/RoomPreviewBar.tsx +++ b/src/components/views/rooms/RoomPreviewBar.tsx @@ -57,7 +57,8 @@ enum MessageCase { } interface IProps { - // The id of the room to be previewed + // The id of the room to be previewed, if it is known. + // (It may be unknown if we are waiting for an alias to be resolved.) roomId?: string; // if inviterName is specified, the preview bar will shown an invite to the room. From 82ca0acaabbbda0d21f0646cef94a5d2da7ef6fc Mon Sep 17 00:00:00 2001 From: maheichyk Date: Tue, 21 Feb 2023 18:08:50 +0300 Subject: [PATCH 09/11] Update src/components/views/rooms/RoomPreviewBar.tsx room description update Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- src/components/views/rooms/RoomPreviewBar.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/views/rooms/RoomPreviewBar.tsx b/src/components/views/rooms/RoomPreviewBar.tsx index b45e73857a1..c32d552a48a 100644 --- a/src/components/views/rooms/RoomPreviewBar.tsx +++ b/src/components/views/rooms/RoomPreviewBar.tsx @@ -81,8 +81,7 @@ interface IProps { canPreview?: boolean; previewLoading?: boolean; - // The room to be previewed - // If given, the room passed is peekable + // A `Room` object for the room to be previewed, if we have one. room?: Room; loading?: boolean; From d8ed26e1e2f992328dc27a2e238e9f39d62dd684 Mon Sep 17 00:00:00 2001 From: Mikhail Aheichyk Date: Tue, 21 Feb 2023 18:18:38 +0300 Subject: [PATCH 10/11] reverted not needed lines of RoomPreviewBar-test.tsx Signed-off-by: Mikhail Aheichyk --- test/components/views/rooms/RoomPreviewBar-test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/components/views/rooms/RoomPreviewBar-test.tsx b/test/components/views/rooms/RoomPreviewBar-test.tsx index 301cdbc2c04..b6566132ac6 100644 --- a/test/components/views/rooms/RoomPreviewBar-test.tsx +++ b/test/components/views/rooms/RoomPreviewBar-test.tsx @@ -71,7 +71,7 @@ describe("", () => { const inviterUserId = "@inviter:test.com"; const otherUserId = "@othertester:test.com"; - const getComponent = (props: Omit, "roomId"> = {}) => { + const getComponent = (props: ComponentProps = {}) => { const defaultProps = { roomId, room: createRoom(roomId, userId), @@ -325,7 +325,7 @@ describe("", () => { { medium: "not-email", address: "address 2" }, ]; - const testJoinButton = (props: Omit, "roomId">) => async () => { + const testJoinButton = (props: ComponentProps) => async () => { const onJoinClick = jest.fn(); const onRejectClick = jest.fn(); const component = getComponent({ ...props, onJoinClick, onRejectClick }); From eac3e4ae051301eb228eb795a28414292543c21a Mon Sep 17 00:00:00 2001 From: Mikhail Aheichyk Date: Tue, 21 Feb 2023 18:20:54 +0300 Subject: [PATCH 11/11] roomId is moved to the room Signed-off-by: Mikhail Aheichyk --- src/components/views/rooms/RoomPreviewBar.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/views/rooms/RoomPreviewBar.tsx b/src/components/views/rooms/RoomPreviewBar.tsx index c32d552a48a..b209e26024d 100644 --- a/src/components/views/rooms/RoomPreviewBar.tsx +++ b/src/components/views/rooms/RoomPreviewBar.tsx @@ -57,10 +57,6 @@ enum MessageCase { } interface IProps { - // The id of the room to be previewed, if it is known. - // (It may be unknown if we are waiting for an alias to be resolved.) - roomId?: string; - // if inviterName is specified, the preview bar will shown an invite to the room. // You should also specify onRejectClick if specifying inviterName inviterName?: string; @@ -81,6 +77,10 @@ interface IProps { canPreview?: boolean; previewLoading?: boolean; + // The id of the room to be previewed, if it is known. + // (It may be unknown if we are waiting for an alias to be resolved.) + roomId?: string; + // A `Room` object for the room to be previewed, if we have one. room?: Room;