Skip to content

Commit 4b5983a

Browse files
committed
Removed delete message option for message and allowed empty content during editing message
1 parent 77b7e9c commit 4b5983a

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/action-sheets/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ export const constructMessageActionButtons = (args: {|
697697
if (message.isOutbox === true) {
698698
buttons.push(copyToClipboard);
699699
buttons.push(shareMessage);
700-
buttons.push(deleteMessage);
700+
// buttons.push(deleteMessage);
701701
buttons.push(cancel);
702702
return buttons;
703703
}
@@ -726,8 +726,12 @@ export const constructMessageActionButtons = (args: {|
726726
) {
727727
buttons.push(editMessage);
728728
}
729-
if (message.sender_id === ownUser.user_id && messageNotDeleted(message)) {
729+
if (message.sender_id === ownUser.user_id && messageNotDeleted(message)) {
730730
// TODO(#2793): Don't show if message isn't deletable.
731+
// buttons.push(deleteMessage);
732+
}
733+
if (ownUser.role === 200 && messageNotDeleted(message))
734+
{
731735
buttons.push(deleteMessage);
732736
}
733737
if (

src/chat/ChatScreen.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ export default function ChatScreen(props: Props): Node {
131131

132132
const { narrow, editMessage } = route.params;
133133
const setEditMessage = useCallback(
134-
(value: EditMessage | null) => navigation.setParams({ editMessage: value }),
134+
(value: EditMessage | null) =>
135+
{
136+
navigation.setParams({ editMessage: value });
137+
},
135138
[navigation],
136139
);
137140

@@ -164,7 +167,7 @@ export default function ChatScreen(props: Props): Node {
164167
() => undefined,
165168
);
166169

167-
if ((content !== undefined && content !== '') || (topic !== undefined && topic !== '')) {
170+
if ((content !== undefined) || (topic !== undefined && topic !== '')) {
168171
api.updateMessage(auth, editMessage.id, { content, subject: topic }).catch(error => {
169172
showErrorAlert(_('Failed to edit message'), error.message);
170173
});

src/compose/ComposeBox.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,10 @@ const ComposeBox: React$AbstractComponent<Props, ImperativeHandle> = forwardRef(
549549
}
550550

551551
if (messageInputValue.trim().length === 0) {
552+
if (!isEditing)
553+
{
552554
result.push('message-empty');
555+
}
553556
}
554557

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

563566
return result;
564-
}, [
565-
destinationNarrow,
566-
mandatoryTopics,
567-
numUploading,
568-
anyQuoteAndReplyInProgress,
569-
messageInputState,
570-
]);
567+
}, [messageInputState, destinationNarrow, mandatoryTopics, numUploading, anyQuoteAndReplyInProgress, isEditing]);
571568

572569
const submitButtonDisabled = validationErrors.length > 0;
573570

574571
const handleSubmit = useCallback(() => {
575572
const { value: messageInputValue } = messageInputState;
576-
577573
if (validationErrors.length > 0) {
578574
const msg = validationErrors
579575
.map(error => {

0 commit comments

Comments
 (0)