mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Fix undownloadable attachment check to require download error
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
getUrl,
|
||||
isDownloadable,
|
||||
isIncremental,
|
||||
isPermanentlyUndownloadable,
|
||||
isVideoAttachment,
|
||||
} from '../../types/Attachment';
|
||||
|
||||
@@ -157,6 +158,14 @@ export function ImageGrid({
|
||||
[startDownload]
|
||||
);
|
||||
|
||||
const showAttachmentOrNoLongerAvailableToast = React.useCallback(
|
||||
attachmentIndex =>
|
||||
isPermanentlyUndownloadable(attachments[attachmentIndex])
|
||||
? showMediaNoLongerAvailableToast
|
||||
: showVisualAttachment,
|
||||
[attachments, showVisualAttachment, showMediaNoLongerAvailableToast]
|
||||
);
|
||||
|
||||
if (!attachments || !attachments.length) {
|
||||
return null;
|
||||
}
|
||||
@@ -215,7 +224,7 @@ export function ImageGrid({
|
||||
}
|
||||
tabIndex={tabIndex}
|
||||
showMediaNoLongerAvailableToast={showMediaNoLongerAvailableToast}
|
||||
showVisualAttachment={showVisualAttachment}
|
||||
showVisualAttachment={showAttachmentOrNoLongerAvailableToast(0)}
|
||||
cancelDownload={cancelDownload}
|
||||
startDownload={startDownload}
|
||||
onError={onError}
|
||||
@@ -244,7 +253,7 @@ export function ImageGrid({
|
||||
cropWidth={GAP}
|
||||
url={getThumbnailUrl(attachments[0])}
|
||||
showMediaNoLongerAvailableToast={showMediaNoLongerAvailableToast}
|
||||
showVisualAttachment={showVisualAttachment}
|
||||
showVisualAttachment={showAttachmentOrNoLongerAvailableToast(0)}
|
||||
cancelDownload={cancelDownload}
|
||||
startDownload={downloadPill ? undefined : startDownload}
|
||||
onError={onError}
|
||||
@@ -264,7 +273,7 @@ export function ImageGrid({
|
||||
attachment={attachments[1]}
|
||||
url={getThumbnailUrl(attachments[1])}
|
||||
showMediaNoLongerAvailableToast={showMediaNoLongerAvailableToast}
|
||||
showVisualAttachment={showVisualAttachment}
|
||||
showVisualAttachment={showAttachmentOrNoLongerAvailableToast(1)}
|
||||
cancelDownload={cancelDownload}
|
||||
startDownload={downloadPill ? undefined : startDownload}
|
||||
onError={onError}
|
||||
@@ -294,7 +303,7 @@ export function ImageGrid({
|
||||
cropWidth={GAP}
|
||||
url={getUrl(attachments[0])}
|
||||
showMediaNoLongerAvailableToast={showMediaNoLongerAvailableToast}
|
||||
showVisualAttachment={showVisualAttachment}
|
||||
showVisualAttachment={showAttachmentOrNoLongerAvailableToast(0)}
|
||||
cancelDownload={cancelDownload}
|
||||
startDownload={downloadPill ? undefined : startDownload}
|
||||
onError={onError}
|
||||
@@ -313,7 +322,7 @@ export function ImageGrid({
|
||||
playIconOverlay={isVideoAttachment(attachments[1])}
|
||||
url={getThumbnailUrl(attachments[1])}
|
||||
showMediaNoLongerAvailableToast={showMediaNoLongerAvailableToast}
|
||||
showVisualAttachment={showVisualAttachment}
|
||||
showVisualAttachment={showAttachmentOrNoLongerAvailableToast(1)}
|
||||
cancelDownload={cancelDownload}
|
||||
startDownload={downloadPill ? undefined : startDownload}
|
||||
onError={onError}
|
||||
@@ -332,7 +341,7 @@ export function ImageGrid({
|
||||
playIconOverlay={isVideoAttachment(attachments[2])}
|
||||
url={getThumbnailUrl(attachments[2])}
|
||||
showMediaNoLongerAvailableToast={showMediaNoLongerAvailableToast}
|
||||
showVisualAttachment={showVisualAttachment}
|
||||
showVisualAttachment={showAttachmentOrNoLongerAvailableToast(2)}
|
||||
cancelDownload={cancelDownload}
|
||||
startDownload={downloadPill ? undefined : startDownload}
|
||||
onError={onError}
|
||||
@@ -364,7 +373,7 @@ export function ImageGrid({
|
||||
cropWidth={GAP}
|
||||
url={getThumbnailUrl(attachments[0])}
|
||||
showMediaNoLongerAvailableToast={showMediaNoLongerAvailableToast}
|
||||
showVisualAttachment={showVisualAttachment}
|
||||
showVisualAttachment={showAttachmentOrNoLongerAvailableToast(0)}
|
||||
cancelDownload={cancelDownload}
|
||||
startDownload={downloadPill ? undefined : startDownload}
|
||||
onError={onError}
|
||||
@@ -383,7 +392,7 @@ export function ImageGrid({
|
||||
attachment={attachments[1]}
|
||||
url={getThumbnailUrl(attachments[1])}
|
||||
showMediaNoLongerAvailableToast={showMediaNoLongerAvailableToast}
|
||||
showVisualAttachment={showVisualAttachment}
|
||||
showVisualAttachment={showAttachmentOrNoLongerAvailableToast(1)}
|
||||
cancelDownload={cancelDownload}
|
||||
startDownload={downloadPill ? undefined : startDownload}
|
||||
onError={onError}
|
||||
@@ -405,7 +414,7 @@ export function ImageGrid({
|
||||
attachment={attachments[2]}
|
||||
url={getThumbnailUrl(attachments[2])}
|
||||
showMediaNoLongerAvailableToast={showMediaNoLongerAvailableToast}
|
||||
showVisualAttachment={showVisualAttachment}
|
||||
showVisualAttachment={showAttachmentOrNoLongerAvailableToast(2)}
|
||||
cancelDownload={cancelDownload}
|
||||
startDownload={downloadPill ? undefined : startDownload}
|
||||
onError={onError}
|
||||
@@ -424,7 +433,7 @@ export function ImageGrid({
|
||||
attachment={attachments[3]}
|
||||
url={getThumbnailUrl(attachments[3])}
|
||||
showMediaNoLongerAvailableToast={showMediaNoLongerAvailableToast}
|
||||
showVisualAttachment={showVisualAttachment}
|
||||
showVisualAttachment={showAttachmentOrNoLongerAvailableToast(3)}
|
||||
cancelDownload={cancelDownload}
|
||||
startDownload={downloadPill ? undefined : startDownload}
|
||||
onError={onError}
|
||||
|
||||
Reference in New Issue
Block a user