Skip to content

Commit

Permalink
fix msg event permission check (cinnyapp#1315)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbura authored Jun 28, 2023
1 parent b6283b3 commit f14d70e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/components/emoji-board/EmojiBoard.css.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/app/hooks/usePowerLevels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/app/organisms/room/RoomView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit f14d70e

Please sign in to comment.