fix msg event permission check (#1315)
This commit is contained in:
parent
b6283b3469
commit
f14d70ea35
3 changed files with 6 additions and 3 deletions
|
@ -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',
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Loading…
Reference in a new issue