Remove "delete for everyone" option from failed messages

This commit is contained in:
Evan Hahn 2021-08-02 14:26:48 -05:00 committed by GitHub
parent f82639dc3a
commit 1891375c6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 114 additions and 17 deletions

View file

@ -38,6 +38,7 @@ import { AttachmentType, isVoiceMessage } from '../../types/Attachment';
import { CallingNotificationType } from '../../util/callingNotification';
import { missingCaseError } from '../../util/missingCaseError';
import { isNotNil } from '../../util/isNotNil';
import { isMoreRecentThan } from '../../util/timestamp';
import { ConversationType } from '../ducks/conversations';
@ -1153,23 +1154,25 @@ export function canReply(
return false;
}
export function canDeleteForEveryone(message: MessageAttributesType): boolean {
// is someone else's message
if (isIncoming(message)) {
return false;
}
// has already been deleted for everyone
if (message.deletedForEveryone) {
return false;
}
// is too old to delete
if (Date.now() - message.sent_at > THREE_HOURS) {
return false;
}
return true;
export function canDeleteForEveryone(
message: Pick<
MessageAttributesType,
'type' | 'deletedForEveryone' | 'sent_at' | 'sendStateByConversationId'
>
): boolean {
return (
// Is this a message I sent?
isOutgoing(message) &&
// Has the message already been deleted?
!message.deletedForEveryone &&
// Is it too old to delete?
isMoreRecentThan(message.sent_at, THREE_HOURS) &&
// Is it pending/sent to anyone?
someSendStatus(
message.sendStateByConversationId,
sendStatus => sendStatus !== SendStatus.Failed
)
);
}
export function canDownload(