From: Ajay Bura Date: Wed, 24 Nov 2021 04:38:51 +0000 (+0530) Subject: Fix bug in creating dm X-Git-Tag: v1.6.0~38 X-Git-Url: https://git.wafflesoft.org/?a=commitdiff_plain;h=16f35d9a34a0bbc999f0aea9fb9042a2c014a047;p=rainny.git Fix bug in creating dm Signed-off-by: Ajay Bura --- diff --git a/src/app/organisms/profile-viewer/ProfileViewer.jsx b/src/app/organisms/profile-viewer/ProfileViewer.jsx index 41a43fc..c8191ff 100644 --- a/src/app/organisms/profile-viewer/ProfileViewer.jsx +++ b/src/app/organisms/profile-viewer/ProfileViewer.jsx @@ -95,7 +95,8 @@ function ProfileFooter({ roomId, userId, onRequestClose }) { const [isInvited, setIsInvited] = useState(member?.membership === 'invite'); const myPowerlevel = room.getMember(mx.getUserId()).powerLevel; - const canIKick = room.currentState.hasSufficientPowerLevelFor('kick', myPowerlevel); + const userPL = room.getMember(userId).powerLevel || 0; + const canIKick = room.currentState.hasSufficientPowerLevelFor('kick', myPowerlevel) && userPL < myPowerlevel; const onCreated = (dmRoomId) => { if (isMountedRef.current === false) return; @@ -104,11 +105,11 @@ function ProfileFooter({ roomId, userId, onRequestClose }) { onRequestClose(); }; - useEffect(() => () => { - isMountedRef.current = false; + useEffect(() => { const { roomList } = initMatrix; roomList.on(cons.events.roomList.ROOM_CREATED, onCreated); return () => { + isMountedRef.current = false; roomList.removeListener(cons.events.roomList.ROOM_CREATED, onCreated); }; }, []);