Skip to content

Commit

Permalink
Readded Delete Message Button for own user and outBox, and ensured de…
Browse files Browse the repository at this point in the history
…lete message is avaliable for all roles above admin
  • Loading branch information
KshitizSareen committed Jan 17, 2023
1 parent e4d162c commit cfe26ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/action-sheets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ export const constructMessageActionButtons = (args: {|
const { backgroundData, message, narrow, canStartQuoteAndReply } = args;
const { ownUser, flags } = backgroundData;
const buttons = [];
let deleteMessageAdded = false;

if (message.isOutbox === true) {
buttons.push(copyToClipboard);
Expand Down Expand Up @@ -729,6 +730,15 @@ export const constructMessageActionButtons = (args: {|
if (message.sender_id === ownUser.user_id && messageNotDeleted(message)) {
// TODO(#2793): Don't show if message isn't deletable.
buttons.push(deleteMessage);
deleteMessageAdded = true;
}
if (
ownUser.role !== undefined
&& roleIsAtLeast(ownUser.role, Role.Admin)
&& messageNotDeleted(message)
&& !deleteMessageAdded
) {
buttons.push(deleteMessage);
}
if (
// When do we offer "Mark as unread from here"? This logic parallels
Expand Down
2 changes: 1 addition & 1 deletion src/chat/ChatScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default function ChatScreen(props: Props): Node {
() => undefined,
);

if ((content !== undefined && content !== '') || (topic !== undefined && topic !== '')) {
if (content !== undefined || topic !== undefined) {
api.updateMessage(auth, editMessage.id, { content, subject: topic }).catch(error => {
showErrorAlert(_('Failed to edit message'), error.message);
});
Expand Down
5 changes: 3 additions & 2 deletions src/compose/ComposeBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ const ComposeBox: React$AbstractComponent<Props, ImperativeHandle> = forwardRef(
result.push('mandatory-topic-empty');
}

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

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

return result;
}, [
messageInputState,
destinationNarrow,
mandatoryTopics,
isEditing,
numUploading,
anyQuoteAndReplyInProgress,
messageInputState,
]);

const submitButtonDisabled = validationErrors.length > 0;
Expand Down

0 comments on commit cfe26ad

Please sign in to comment.