diff --git a/src/app/components/knock-room-prompt/KnockRoomPrompt.tsx b/src/app/components/knock-room-prompt/KnockRoomPrompt.tsx
index 1de35f74..a7948e9a 100644
--- a/src/app/components/knock-room-prompt/KnockRoomPrompt.tsx
+++ b/src/app/components/knock-room-prompt/KnockRoomPrompt.tsx
@@ -18,6 +18,7 @@ import {
Spinner,
} from 'folds';
import { MatrixError } from '$types/matrix-sdk';
+
import { useMatrixClient } from '$hooks/useMatrixClient';
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
import { stopPropagation } from '$utils/keyboard';
@@ -27,7 +28,7 @@ const debugLog = createDebugLogger('KnockRoomPrompt');
type KnockRoomProps = {
roomId: string;
- via?: string;
+ via?: string | string[];
onDone: () => void;
onCancel: () => void;
};
@@ -80,7 +81,7 @@ export function KnockRoomPrompt({ roomId, via, onDone, onCancel }: KnockRoomProp
size="500"
>
- Knock on Room
+ Knock On Room
diff --git a/src/app/components/room-card/RoomCard.tsx b/src/app/components/room-card/RoomCard.tsx
index afd66d3c..0d1e580b 100644
--- a/src/app/components/room-card/RoomCard.tsx
+++ b/src/app/components/room-card/RoomCard.tsx
@@ -1,5 +1,5 @@
import { ReactNode, useCallback, useRef, useState } from 'react';
-import { MatrixError, Room } from '$types/matrix-sdk';
+import { JoinRule, MatrixError, Room } from '$types/matrix-sdk';
import {
Avatar,
Badge,
@@ -31,6 +31,7 @@ import { useElementSizeObserver } from '$hooks/useElementSizeObserver';
import { getRoomAvatarUrl, getStateEvent } from '$utils/room';
import { useStateEventCallback } from '$hooks/useStateEventCallback';
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
+import { KnockRoomPrompt } from '$components/knock-room-prompt';
import { RoomAvatar } from '$components/room-avatar';
import * as css from './style.css';
@@ -143,6 +144,7 @@ type RoomCardProps = {
topic?: string;
memberCount?: number;
roomType?: string;
+ joinRule?: JoinRule;
viaServers?: string[];
onView?: (roomId: string) => void;
renderTopicViewer: (name: string, topic: string, requestClose: () => void) => ReactNode;
@@ -158,6 +160,7 @@ export const RoomCard = as<'div', RoomCardProps>(
topic,
memberCount,
roomType,
+ joinRule,
viaServers,
onView,
renderTopicViewer,
@@ -172,7 +175,7 @@ export const RoomCard = as<'div', RoomCardProps>(
const [topicEvent, setTopicEvent] = useState(() =>
joinedRoom ? getStateEvent(joinedRoom, StateEvent.RoomTopic) : undefined
);
-
+ const [knocking, setKnocking] = useState(false);
const fallbackName = getMxIdLocalPart(roomIdOrAlias) ?? roomIdOrAlias;
const fallbackTopic = roomIdOrAlias;
@@ -271,19 +274,38 @@ export const RoomCard = as<'div', RoomCardProps>(
)}
- {typeof joinedRoomId !== 'string' && joinState.status !== AsyncStatus.Error && (
- }
- >
-
- {joining ? 'Joining' : 'Join'}
-
-
- )}
+ {typeof joinedRoomId !== 'string' &&
+ joinState.status !== AsyncStatus.Error &&
+ (joinRule === JoinRule.Knock ? (
+ <>
+
+
+ {knocking && (
+ setKnocking(false)}
+ onCancel={() => setKnocking(false)}
+ />
+ )}
+ >
+ ) : (
+ }
+ >
+
+ {joining ? 'Joining' : 'Join'}
+
+
+ ))}
{typeof joinedRoomId !== 'string' && joinState.status === AsyncStatus.Error && (
+ )}
+
);
}
+type RoomJoinOrKnockButtonProps = {
+ roomId: string;
+ via?: string[];
+ joinRule?: JoinRule;
+};
+function RoomJoinOrKnockButton({ roomId, via, joinRule }: RoomJoinOrKnockButtonProps) {
+ if (joinRule === JoinRule.Knock) {
+ return ;
+ }
+ return ;
+}
+
function RoomProfileLoading() {
return (
@@ -212,7 +208,7 @@ function RoomProfileError({ roomId, suggested, inaccessibleRoom, via }: RoomProf
)}
- {!inaccessibleRoom && }
+ {!inaccessibleRoom && }
);
}
@@ -409,7 +405,11 @@ export const RoomItemCard = as<'div', RoomItemCardProps>(
) : (
-
+
)
}
/>
@@ -453,7 +453,13 @@ export const RoomItemCard = as<'div', RoomItemCardProps>(
memberCount={summary.num_joined_members}
suggested={content.suggested}
joinRule={summary.join_rule}
- options={}
+ options={
+
+ }
/>
)}
>
diff --git a/src/app/pages/client/explore/Featured.tsx b/src/app/pages/client/explore/Featured.tsx
index e7095772..f3dba342 100644
--- a/src/app/pages/client/explore/Featured.tsx
+++ b/src/app/pages/client/explore/Featured.tsx
@@ -67,6 +67,7 @@ export function FeaturedRooms() {
name={roomSummary?.name}
topic={roomSummary?.topic}
memberCount={roomSummary?.num_joined_members}
+ joinRule={roomSummary?.join_rule}
onView={navigateSpace}
renderTopicViewer={(name, topic, requestClose) => (
(