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 7e1a196
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/action-sheets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ export const constructMessageActionButtons = (args: {|
|}): Button<MessageArgs>[] => {
const { backgroundData, message, narrow, canStartQuoteAndReply } = args;
const { ownUser, flags } = backgroundData;
const { role } = ownUser;
const buttons = [];

if (message.isOutbox === true) {
Expand Down Expand Up @@ -730,6 +731,9 @@ export const constructMessageActionButtons = (args: {|
// TODO(#2793): Don't show if message isn't deletable.
buttons.push(deleteMessage);
}
if (roleIsAtLeast(role, Role.Admin) && messageNotDeleted(message)) {
buttons.push(deleteMessage);
}
if (
// When do we offer "Mark as unread from here"? This logic parallels
// `should_display_mark_as_unread` in web's static/js/popovers.js .
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
3 changes: 2 additions & 1 deletion 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 @@ -540,6 +540,7 @@ const ComposeBox: React$AbstractComponent<Props, ImperativeHandle> = forwardRef(
numUploading,
anyQuoteAndReplyInProgress,
messageInputState,
isEditing,
]);

const submitButtonDisabled = validationErrors.length > 0;
Expand Down

0 comments on commit 7e1a196

Please sign in to comment.