From 2559ae7935f52548a66b5d0a6371e0ecd0a46e48 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Sun, 1 Nov 2020 17:19:13 +0100 Subject: [PATCH] Revert usage of the optional chaining operator (?.) --- files_wcf/js/Bastelstu.be/Chat/Ui/Attachment/Upload.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/files_wcf/js/Bastelstu.be/Chat/Ui/Attachment/Upload.js b/files_wcf/js/Bastelstu.be/Chat/Ui/Attachment/Upload.js index b7c3adc..a7e7776 100644 --- a/files_wcf/js/Bastelstu.be/Chat/Ui/Attachment/Upload.js +++ b/files_wcf/js/Bastelstu.be/Chat/Ui/Attachment/Upload.js @@ -155,18 +155,20 @@ define([ 'WoltLabSuite/Core/Language' * @see WoltLabSuite/Core/Upload#_success */ _success(uploadId, data, responseText, xhr, requestOptions) { - if (data.returnValues?.errors?.[0]) { + if (data.returnValues.errors && data.returnValues.errors[0]) { const error = data.returnValues.errors[0] elInnerError(this._button, Language.get(`wcf.attachment.upload.error.${error.errorType}`, { filename: error.filename })) + + return } else { elInnerError(this._button, '') } - if (data.returnValues?.attachments?.[uploadId]) { + if (data.returnValues.attachments && data.returnValues.attachments[uploadId]) { this._removeButton() elHide(this.uploadDescription) @@ -198,6 +200,10 @@ define([ 'WoltLabSuite/Core/Language' this.createButtonGroup(uploadId, attachment.attachmentID, this.tmpHash) } + else { + console.error("Received neither an error nor an attachment response") + console.error(data.returnValues) + } } } UiAttachmentUpload.DEPENDENCIES = DEPENDENCIES