Skip to content

Commit cfe26ad

Browse files
committed
Readded Delete Message Button for own user and outBox, and ensured delete message is avaliable for all roles above admin
1 parent e4d162c commit cfe26ad

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/action-sheets/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ export const constructMessageActionButtons = (args: {|
693693
const { backgroundData, message, narrow, canStartQuoteAndReply } = args;
694694
const { ownUser, flags } = backgroundData;
695695
const buttons = [];
696+
let deleteMessageAdded = false;
696697

697698
if (message.isOutbox === true) {
698699
buttons.push(copyToClipboard);
@@ -729,6 +730,15 @@ export const constructMessageActionButtons = (args: {|
729730
if (message.sender_id === ownUser.user_id && messageNotDeleted(message)) {
730731
// TODO(#2793): Don't show if message isn't deletable.
731732
buttons.push(deleteMessage);
733+
deleteMessageAdded = true;
734+
}
735+
if (
736+
ownUser.role !== undefined
737+
&& roleIsAtLeast(ownUser.role, Role.Admin)
738+
&& messageNotDeleted(message)
739+
&& !deleteMessageAdded
740+
) {
741+
buttons.push(deleteMessage);
732742
}
733743
if (
734744
// When do we offer "Mark as unread from here"? This logic parallels

src/chat/ChatScreen.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export default function ChatScreen(props: Props): Node {
164164
() => undefined,
165165
);
166166

167-
if ((content !== undefined && content !== '') || (topic !== undefined && topic !== '')) {
167+
if (content !== undefined || topic !== undefined) {
168168
api.updateMessage(auth, editMessage.id, { content, subject: topic }).catch(error => {
169169
showErrorAlert(_('Failed to edit message'), error.message);
170170
});

src/compose/ComposeBox.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ const ComposeBox: React$AbstractComponent<Props, ImperativeHandle> = forwardRef(
521521
result.push('mandatory-topic-empty');
522522
}
523523

524-
if (messageInputValue.trim().length === 0) {
524+
if (messageInputValue.trim().length === 0 && !isEditing) {
525525
result.push('message-empty');
526526
}
527527

@@ -535,11 +535,12 @@ const ComposeBox: React$AbstractComponent<Props, ImperativeHandle> = forwardRef(
535535

536536
return result;
537537
}, [
538+
messageInputState,
538539
destinationNarrow,
539540
mandatoryTopics,
541+
isEditing,
540542
numUploading,
541543
anyQuoteAndReplyInProgress,
542-
messageInputState,
543544
]);
544545

545546
const submitButtonDisabled = validationErrors.length > 0;

0 commit comments

Comments
 (0)