Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Removed delete message option for message and allowed empty content during editing message #5632

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/action-sheets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,6 @@ 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);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general we try to avoid committing commented-out code, especially without a code comment explaining why and what it's about.

Do I understand correctly that you're trying to fix both #5528 and #4701 at the same time? I believe the way forward for the latter is #4701 (comment):

[…]

  • If you're an admin, you have permission.
  • Otherwise, if you didn't send the message, you don't have permission.
  • Otherwise (so, you sent the message but you're not an admin), it gets complicated -- you might have permission, and might not.

I think we can round off that third point to assuming you have permission, and showing the option in the UI. […]

The code in this revision doesn't match that:

Also, if your commit is meant to fix two issues at once, please put a Fixes: #… line for both issues in the commit message, and also in the PR description: https://github.com/zulip/zulip-mobile/blob/main/docs/style.md#github-prs-issues

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, and there is a role that's even more powerful than an admin: an owner. When admins have permission to do something, owners should too.

For an example of another admin role check in this file, see constructTopicActionButtons:

  if (roleIsAtLeast(ownUserRole, Role.Admin)) {
    buttons.push(deleteTopic);
  }

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 @@ -200,7 +200,7 @@ export default function ChatScreen(props: Props): Node {
() => undefined,
);

if ((content !== undefined && content !== '') || (topic !== undefined && topic !== '')) {
if (content !== undefined || topic !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should go in a separate commit that makes clear the reason for the change, as I mentioned in #5632 (comment).

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 @@ -541,7 +541,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 @@ -560,6 +560,7 @@ const ComposeBox: React$AbstractComponent<Props, ImperativeHandle> = forwardRef(
numUploading,
anyQuoteAndReplyInProgress,
messageInputState,
isEditing,
]);

const submitButtonDisabled = validationErrors.length > 0;
Expand Down