diff --git a/src/components/views/rooms/NewRoomIntro.tsx b/src/components/views/rooms/NewRoomIntro.tsx index be4ecaffb3..9be3d6be18 100644 --- a/src/components/views/rooms/NewRoomIntro.tsx +++ b/src/components/views/rooms/NewRoomIntro.tsx @@ -60,8 +60,9 @@ const NewRoomIntro = () => { { caption &&
{ caption }
} ; } else { + const inRoom = room && room.getMyMembership() === "join"; const topic = room.currentState.getStateEvents(EventType.RoomTopic, "")?.getContent()?.topic; - const canAddTopic = room.currentState.maySendStateEvent(EventType.RoomTopic, cli.getUserId()); + const canAddTopic = inRoom && room.currentState.maySendStateEvent(EventType.RoomTopic, cli.getUserId()); const onTopicClick = () => { dis.dispatch({ @@ -99,9 +100,25 @@ const NewRoomIntro = () => { }); } - const onInviteClick = () => { - dis.dispatch({ action: "view_invite", roomId }); - }; + let canInvite = inRoom; + const powerLevels = room.currentState.getStateEvents(EventType.RoomPowerLevels, "")?.getContent(); + const me = room.getMember(cli.getUserId()); + if (powerLevels && me && powerLevels.invite > me.powerLevel) { + canInvite = false; + } + + let buttons; + if (canInvite) { + const onInviteClick = () => { + dis.dispatch({ action: "view_invite", roomId }); + }; + + buttons ={topicText}
-