Skip to content

Commit

Permalink
Removed delete message option for message and allowed empty content d…
Browse files Browse the repository at this point in the history
…uring editing message
  • Loading branch information
KshitizSareen committed Dec 31, 2022
1 parent 77b7e9c commit c5cd6a7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/action-sheets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ export const constructMessageActionButtons = (args: {|
if (message.isOutbox === true) {
buttons.push(copyToClipboard);
buttons.push(shareMessage);
buttons.push(deleteMessage);
// buttons.push(deleteMessage);
buttons.push(cancel);
return buttons;
}
Expand Down Expand Up @@ -728,6 +728,9 @@ 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);
}
if (ownUser.role === 200 && messageNotDeleted(message)) {
buttons.push(deleteMessage);
}
if (
Expand Down
6 changes: 4 additions & 2 deletions src/chat/ChatScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ export default function ChatScreen(props: Props): Node {

const { narrow, editMessage } = route.params;
const setEditMessage = useCallback(
(value: EditMessage | null) => navigation.setParams({ editMessage: value }),
(value: EditMessage | null) => {
navigation.setParams({ editMessage: value });
},
[navigation],
);

Expand Down Expand Up @@ -164,7 +166,7 @@ export default function ChatScreen(props: Props): Node {
() => undefined,
);

if ((content !== undefined && content !== '') || (topic !== undefined && topic !== '')) {
if (content !== undefined || (topic !== undefined && topic !== '')) {
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 @@ -548,7 +548,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 @@ -567,6 +567,7 @@ const ComposeBox: React$AbstractComponent<Props, ImperativeHandle> = forwardRef(
numUploading,
anyQuoteAndReplyInProgress,
messageInputState,
isEditing,
]);

const submitButtonDisabled = validationErrors.length > 0;
Expand Down

0 comments on commit c5cd6a7

Please sign in to comment.