From f14d70ea3508a8467c0a27b9d61c8ab6661054ab Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Wed, 28 Jun 2023 17:27:28 +0530 Subject: [PATCH] fix msg event permission check (#1315) --- src/app/components/emoji-board/EmojiBoard.css.tsx | 2 +- src/app/hooks/usePowerLevels.ts | 2 +- src/app/organisms/room/RoomView.jsx | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/components/emoji-board/EmojiBoard.css.tsx b/src/app/components/emoji-board/EmojiBoard.css.tsx index adeb250..ba4ca4e 100644 --- a/src/app/components/emoji-board/EmojiBoard.css.tsx +++ b/src/app/components/emoji-board/EmojiBoard.css.tsx @@ -7,7 +7,7 @@ export const Base = style({ height: toRem(450), backgroundColor: color.Surface.Container, color: color.Surface.OnContainer, - border: `${config.borderWidth.B300} solid ${color.SurfaceVariant.ContainerLine}`, + border: `${config.borderWidth.B300} solid ${color.Surface.ContainerLine}`, borderRadius: config.radii.R400, boxShadow: config.shadow.E200, overflow: 'hidden', diff --git a/src/app/hooks/usePowerLevels.ts b/src/app/hooks/usePowerLevels.ts index 8f999d4..3ce75a2 100644 --- a/src/app/hooks/usePowerLevels.ts +++ b/src/app/hooks/usePowerLevels.ts @@ -47,7 +47,7 @@ export function usePowerLevels(room: Room) { const canSendEvent = useCallback( (eventType: string | undefined, powerLevel: number) => { const { events, events_default: eventsDefault } = powerLevels; - if (events && eventType && typeof events[eventType] === 'string') { + if (events && eventType && typeof events[eventType] === 'number') { return powerLevel >= events[eventType]; } return powerLevel >= (eventsDefault ?? DefaultPowerLevels.eventsDefault); diff --git a/src/app/organisms/room/RoomView.jsx b/src/app/organisms/room/RoomView.jsx index 591fcce..9b3ae76 100644 --- a/src/app/organisms/room/RoomView.jsx +++ b/src/app/organisms/room/RoomView.jsx @@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react'; import PropTypes from 'prop-types'; import './RoomView.scss'; import { Text, config } from 'folds'; +import { EventType } from 'matrix-js-sdk'; import EventEmitter from 'events'; @@ -32,7 +33,9 @@ function RoomView({ room, roomTimeline, eventId }) { const tombstoneEvent = useStateEvent(room, StateEvent.RoomTombstone); const { getPowerLevel, canSendEvent } = usePowerLevels(room); const myUserId = mx.getUserId(); - const canMessage = myUserId ? canSendEvent(undefined, getPowerLevel(myUserId)) : false; + const canMessage = myUserId + ? canSendEvent(EventType.RoomMessage, getPowerLevel(myUserId)) + : false; useEffect(() => { const settingsToggle = (isVisible) => {