Only show download button if message has attachments to download
This commit is contained in:
parent
86026bd66a
commit
12a9ecfd35
2 changed files with 11 additions and 16 deletions
|
@ -109,7 +109,6 @@ export function TimelineMessage(props: Props): JSX.Element {
|
||||||
i18n,
|
i18n,
|
||||||
id,
|
id,
|
||||||
isTargeted,
|
isTargeted,
|
||||||
isSticker,
|
|
||||||
isTapToView,
|
isTapToView,
|
||||||
kickOffAttachmentDownload,
|
kickOffAttachmentDownload,
|
||||||
payment,
|
payment,
|
||||||
|
@ -259,15 +258,7 @@ export function TimelineMessage(props: Props): JSX.Element {
|
||||||
const shouldShowAdditional =
|
const shouldShowAdditional =
|
||||||
doesMessageBodyOverflow(text || '') || !isWindowWidthNotNarrow;
|
doesMessageBodyOverflow(text || '') || !isWindowWidthNotNarrow;
|
||||||
|
|
||||||
const hasPendingAttachments =
|
const handleDownload = canDownload ? openGenericAttachment : undefined;
|
||||||
attachments?.length && attachments.some(attachment => attachment.pending);
|
|
||||||
|
|
||||||
// If any of the conditions is not given -> undefined is returned
|
|
||||||
// --> download menu icon is not rendered
|
|
||||||
const handleDownload =
|
|
||||||
canDownload && !isSticker && !isTapToView && !hasPendingAttachments
|
|
||||||
? openGenericAttachment
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const handleReplyToMessage = useCallback(() => {
|
const handleReplyToMessage = useCallback(() => {
|
||||||
if (!canReply) {
|
if (!canReply) {
|
||||||
|
|
|
@ -2068,15 +2068,19 @@ export function canDownload(
|
||||||
message: MessageWithUIFieldsType,
|
message: MessageWithUIFieldsType,
|
||||||
conversationSelector: GetConversationByIdType
|
conversationSelector: GetConversationByIdType
|
||||||
): boolean {
|
): boolean {
|
||||||
if (isOutgoing(message)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const conversation = getConversation(message, conversationSelector);
|
const conversation = getConversation(message, conversationSelector);
|
||||||
const isAccepted = Boolean(
|
const isAccepted = Boolean(
|
||||||
conversation && conversation.acceptedMessageRequest
|
conversation && conversation.acceptedMessageRequest
|
||||||
);
|
);
|
||||||
if (!isAccepted) {
|
if (isIncoming(message) && !isAccepted) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.sticker) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isTapToView(message)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2086,7 +2090,7 @@ export function canDownload(
|
||||||
return attachments.every(attachment => Boolean(attachment.path));
|
return attachments.every(attachment => Boolean(attachment.path));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLastChallengeError(
|
export function getLastChallengeError(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue