const userPL = room.getMember(userId)?.powerLevel || 0;
const canIKick = room.currentState.hasSufficientPowerLevelFor('kick', myPowerlevel) && userPL < myPowerlevel;
+ const isBanned = member?.membership === 'ban';
+
const onCreated = (dmRoomId) => {
if (isMountedRef.current === false) return;
setIsCreatingDM(false);
setIsInviting(false);
}, [userId]);
- async function openDM() {
+ const openDM = async () => {
const directIds = [...initMatrix.roomList.directs];
// Check and open if user already have a DM with userId.
if (isMountedRef.current === false) return;
setIsCreatingDM(false);
}
- }
+ };
- async function toggleIgnore() {
+ const toggleIgnore = async () => {
const ignoredUsers = mx.getIgnoredUsers();
const uIndex = ignoredUsers.indexOf(userId);
if (uIndex >= 0) {
} catch {
setIsIgnoring(false);
}
- }
+ };
- async function toggleInvite() {
+ const toggleInvite = async () => {
try {
setIsInviting(true);
let isInviteSent = false;
} catch {
setIsInviting(false);
}
- }
+ };
return (
<div className="profile-viewer__buttons">
>
{isCreatingDM ? 'Creating room...' : 'Message'}
</Button>
+ { isBanned && canIKick && (
+ <Button
+ variant="positive"
+ onClick={() => roomActions.unban(roomId, userId)}
+ >
+ Unban
+ </Button>
+ )}
{ (isInvited ? canIKick : room.canInvite(mx.getUserId())) && isInvitable && (
<Button
onClick={toggleInvite}
return result;
}
+async function unban(roomId, userId) {
+ const mx = initMatrix.matrixClient;
+
+ const result = await mx.unban(roomId, userId);
+ return result;
+}
+
async function setPowerLevel(roomId, userId, powerLevel) {
const mx = initMatrix.matrixClient;
const room = mx.getRoom(roomId);
export {
join, leave,
- create, invite, kick, ban,
+ create, invite, kick, ban, unban,
setPowerLevel,
createSpaceShortcut, deleteSpaceShortcut,
};