mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
🐛 Added undefined
error handling to failed uploads (#15982)
fixes https://github.com/TryGhost/Team/issues/2320 - Adds error handling when undefined objects are passed to certain upload functions such as `videoUploadCompleted`.
This commit is contained in:
parent
e14520115a
commit
4407e8e49e
5 changed files with 15 additions and 3 deletions
|
@ -198,9 +198,11 @@ export default class KoenigCardAudioComponent extends Component {
|
|||
|
||||
@action
|
||||
async audioUploadCompleted([audio]) {
|
||||
if (!audio.url && !audio.fileName) {
|
||||
return; // prevents undefined error when upload fails due to connection or server error
|
||||
}
|
||||
this.previewPayload.src = audio.url;
|
||||
this.previewPayload.title = prettifyFileName(audio.fileName);
|
||||
|
||||
// upload can complete before metadata is extracted when running locally
|
||||
await this.extractAudioMetadataTask.last;
|
||||
|
||||
|
|
|
@ -137,6 +137,9 @@ export default class KoenigCardFileComponent extends Component {
|
|||
|
||||
@action
|
||||
async fileUploadCompleted([uploadedFile]) {
|
||||
if (!uploadedFile || !uploadedFile.url && !uploadedFile.fileName) {
|
||||
return; // upload failed
|
||||
}
|
||||
this.previewPayload.src = uploadedFile.url;
|
||||
this.previewPayload.fileName = uploadedFile.fileName;
|
||||
this.previewPayload.fileTitle = prettifyFileName(uploadedFile.fileName);
|
||||
|
|
|
@ -156,6 +156,9 @@ export default class KoenigCardGallery extends Component {
|
|||
|
||||
@action
|
||||
setImageSrc(uploadResult) {
|
||||
if (!uploadResult.fileName && !uploadResult.url) {
|
||||
return; // upload failed
|
||||
}
|
||||
let image = this.images.findBy('fileName', uploadResult.fileName);
|
||||
|
||||
image.set('src', uploadResult.url);
|
||||
|
|
|
@ -196,6 +196,9 @@ export default class KoenigCardImage extends Component {
|
|||
|
||||
@action
|
||||
updateSrc(images) {
|
||||
if (!images) {
|
||||
return;
|
||||
}
|
||||
let [image] = images;
|
||||
|
||||
// create undo snapshot when image finishes uploading
|
||||
|
|
|
@ -188,10 +188,11 @@ export default class KoenigCardVideoComponent extends Component {
|
|||
|
||||
@action
|
||||
async videoUploadCompleted([video]) {
|
||||
if (!video?.url && !video?.fileName || !video) {
|
||||
return; // prevents undefined error when upload fails, due to connection or server error.
|
||||
}
|
||||
this.previewPayload.src = video.url;
|
||||
this.previewPayload.fileName = video.fileName;
|
||||
|
||||
// upload can complete before thumbnail is extracted when running locally
|
||||
await this.extractVideoMetadataTask.last;
|
||||
|
||||
if (this._thumbnailBlob) {
|
||||
|
|
Loading…
Add table
Reference in a new issue