From 4336f0db40af18049b8ebb933e0767043e187d2d Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Fri, 24 Feb 2023 11:37:56 -0300 Subject: [PATCH] [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 --- app/views/RoomView/index.tsx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index 0e6f2d4e..586c9dde 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -785,13 +785,22 @@ class RoomView extends React.Component { }); }; + handleCloseEmoji = (action?: Function, params?: any) => { + if (this.messagebox?.current) { + return this.messagebox?.current.closeEmojiAndAction(action, params); + } + if (action) { + return action(params); + } + }; + errorActionsShow = (message: TAnyMessageModel) => { - this.messagebox?.current?.closeEmojiAndAction(this.messageErrorActions?.showMessageErrorActions, message); + this.handleCloseEmoji(this.messageErrorActions?.showMessageErrorActions, message); }; showActionSheet = (options: any) => { const { showActionSheet } = this.props; - this.messagebox?.current?.closeEmojiAndAction(showActionSheet, options); + this.handleCloseEmoji(showActionSheet, options); }; onEditInit = (message: TAnyMessageModel) => { @@ -850,7 +859,7 @@ class RoomView extends React.Component { }; onReactionInit = (message: TAnyMessageModel) => { - this.messagebox?.current?.closeEmojiAndAction(() => { + this.handleCloseEmoji(() => { this.setState({ selectedMessage: message }, this.showReactionPicker); }); }; @@ -865,7 +874,7 @@ class RoomView extends React.Component { if (message.tmid && !this.tmid) { return; } - this.messagebox?.current?.closeEmojiAndAction(this.messageActions?.showMessageActions, message); + this.handleCloseEmoji(this.messageActions?.showMessageActions, message); }; showAttachment = (attachment: IAttachment) => { @@ -894,7 +903,7 @@ class RoomView extends React.Component { this.setState({ selectedMessage: message }); const { showActionSheet } = this.props; const { selectedMessage } = this.state; - this.messagebox?.current?.closeEmojiAndAction(showActionSheet, { + this.handleCloseEmoji(showActionSheet, { children: , snaps: ['50%', '80%'], enableContentPanningGesture: false @@ -1380,7 +1389,7 @@ class RoomView extends React.Component { jumpToMessage={this.jumpToMessageByUrl} highlighted={highlightedMessage === item.id} theme={theme} - closeEmojiAndAction={this.messagebox?.current?.closeEmojiAndAction} + closeEmojiAndAction={this.handleCloseEmoji} /> ); }