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 4b5983a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
8 changes: 6 additions & 2 deletions 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 @@ -726,8 +726,12 @@ export const constructMessageActionButtons = (args: {|
) {
buttons.push(editMessage);
}
if (message.sender_id === ownUser.user_id && messageNotDeleted(message)) {
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
7 changes: 5 additions & 2 deletions src/chat/ChatScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ 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 +167,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
12 changes: 4 additions & 8 deletions src/compose/ComposeBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,10 @@ const ComposeBox: React$AbstractComponent<Props, ImperativeHandle> = forwardRef(
}

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

if (numUploading > 0) {
Expand All @@ -561,19 +564,12 @@ const ComposeBox: React$AbstractComponent<Props, ImperativeHandle> = forwardRef(
}

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

const submitButtonDisabled = validationErrors.length > 0;

const handleSubmit = useCallback(() => {
const { value: messageInputValue } = messageInputState;

if (validationErrors.length > 0) {
const msg = validationErrors
.map(error => {
Expand Down

0 comments on commit 4b5983a

Please sign in to comment.