mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Send/reply: Be resilient to errors making attachment thumbnail (#2468)
* Show generic file icon if we fail to make attachment thumbnail * Be resilient to thumbnail creation errors when creating quote
This commit is contained in:
parent
8eeaad8e18
commit
a4603807e1
2 changed files with 30 additions and 10 deletions
|
@ -735,13 +735,25 @@
|
||||||
const willMakeThumbnail =
|
const willMakeThumbnail =
|
||||||
Signal.Util.GoogleChrome.isImageTypeSupported(contentType) ||
|
Signal.Util.GoogleChrome.isImageTypeSupported(contentType) ||
|
||||||
Signal.Util.GoogleChrome.isVideoTypeSupported(contentType);
|
Signal.Util.GoogleChrome.isVideoTypeSupported(contentType);
|
||||||
|
const makeThumbnail = async () => {
|
||||||
|
try {
|
||||||
|
if (willMakeThumbnail) {
|
||||||
|
return await this.makeThumbnailAttachment(attachment);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(
|
||||||
|
'Failed to create quote thumbnail',
|
||||||
|
error && error.stack ? error.stack : error
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
contentType,
|
contentType,
|
||||||
fileName: attachment.fileName,
|
fileName: attachment.fileName,
|
||||||
thumbnail: willMakeThumbnail
|
thumbnail: makeThumbnail(),
|
||||||
? await this.makeThumbnailAttachment(attachment)
|
|
||||||
: null,
|
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
|
|
@ -274,13 +274,21 @@
|
||||||
this.addThumb(dataUrl);
|
this.addThumb(dataUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Signal.Util.GoogleChrome.isImageTypeSupported(contentType)) {
|
try {
|
||||||
renderImagePreview();
|
if (Signal.Util.GoogleChrome.isImageTypeSupported(contentType)) {
|
||||||
} else if (Signal.Util.GoogleChrome.isVideoTypeSupported(contentType)) {
|
await renderImagePreview();
|
||||||
renderVideoPreview();
|
} else if (Signal.Util.GoogleChrome.isVideoTypeSupported(contentType)) {
|
||||||
} else if (MIME.isAudio(contentType)) {
|
await renderVideoPreview();
|
||||||
this.addThumb('images/audio.svg');
|
} else if (MIME.isAudio(contentType)) {
|
||||||
} else {
|
this.addThumb('images/audio.svg');
|
||||||
|
} else {
|
||||||
|
this.addThumb('images/file.svg');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(
|
||||||
|
`Was unable to generate thumbnail for file type ${contentType}`,
|
||||||
|
e && e.stack ? e.stack : e
|
||||||
|
);
|
||||||
this.addThumb('images/file.svg');
|
this.addThumb('images/file.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue