0
Fork 0
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:
Ronald Langeveld 2023-03-01 16:50:56 +08:00 committed by GitHub
parent e14520115a
commit 4407e8e49e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 3 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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

View file

@ -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) {