Remove "delete for everyone" option from failed messages
This commit is contained in:
parent
f82639dc3a
commit
1891375c6c
2 changed files with 114 additions and 17 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue