[FIX] "Allow Reaction" does not work properly on "Read Only" rooms (#4864)

* [FIX] "Allow Reaction" does not work properly on "Read Only" rooms

* fix the handle of message box

---------

Co-authored-by: Gleidson Daniel Silva <gleidson10daniel@hotmail.com>
This commit is contained in:
Reinaldo Neto 2023-02-24 11:37:56 -03:00 committed by Diego Mello
parent 26ca0d043f
commit da5e06fec4
1 changed files with 15 additions and 6 deletions

View File

@ -785,13 +785,22 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
}); });
}; };
handleCloseEmoji = (action?: Function, params?: any) => {
if (this.messagebox?.current) {
return this.messagebox?.current.closeEmojiAndAction(action, params);
}
if (action) {
return action(params);
}
};
errorActionsShow = (message: TAnyMessageModel) => { errorActionsShow = (message: TAnyMessageModel) => {
this.messagebox?.current?.closeEmojiAndAction(this.messageErrorActions?.showMessageErrorActions, message); this.handleCloseEmoji(this.messageErrorActions?.showMessageErrorActions, message);
}; };
showActionSheet = (options: any) => { showActionSheet = (options: any) => {
const { showActionSheet } = this.props; const { showActionSheet } = this.props;
this.messagebox?.current?.closeEmojiAndAction(showActionSheet, options); this.handleCloseEmoji(showActionSheet, options);
}; };
onEditInit = (message: TAnyMessageModel) => { onEditInit = (message: TAnyMessageModel) => {
@ -850,7 +859,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
}; };
onReactionInit = (message: TAnyMessageModel) => { onReactionInit = (message: TAnyMessageModel) => {
this.messagebox?.current?.closeEmojiAndAction(() => { this.handleCloseEmoji(() => {
this.setState({ selectedMessage: message }, this.showReactionPicker); this.setState({ selectedMessage: message }, this.showReactionPicker);
}); });
}; };
@ -865,7 +874,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
if (message.tmid && !this.tmid) { if (message.tmid && !this.tmid) {
return; return;
} }
this.messagebox?.current?.closeEmojiAndAction(this.messageActions?.showMessageActions, message); this.handleCloseEmoji(this.messageActions?.showMessageActions, message);
}; };
showAttachment = (attachment: IAttachment) => { showAttachment = (attachment: IAttachment) => {
@ -894,7 +903,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
this.setState({ selectedMessage: message }); this.setState({ selectedMessage: message });
const { showActionSheet } = this.props; const { showActionSheet } = this.props;
const { selectedMessage } = this.state; const { selectedMessage } = this.state;
this.messagebox?.current?.closeEmojiAndAction(showActionSheet, { this.handleCloseEmoji(showActionSheet, {
children: <ReactionsList reactions={selectedMessage?.reactions} getCustomEmoji={this.getCustomEmoji} />, children: <ReactionsList reactions={selectedMessage?.reactions} getCustomEmoji={this.getCustomEmoji} />,
snaps: ['50%', '80%'], snaps: ['50%', '80%'],
enableContentPanningGesture: false enableContentPanningGesture: false
@ -1380,7 +1389,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
jumpToMessage={this.jumpToMessageByUrl} jumpToMessage={this.jumpToMessageByUrl}
highlighted={highlightedMessage === item.id} highlighted={highlightedMessage === item.id}
theme={theme} theme={theme}
closeEmojiAndAction={this.messagebox?.current?.closeEmojiAndAction} closeEmojiAndAction={this.handleCloseEmoji}
/> />
); );
} }