Revert usage of the optional chaining operator (?.)

This commit is contained in:
Maximilian Mader 2020-11-01 17:19:13 +01:00
parent f8dafa2583
commit 2559ae7935
Signed by: Max
GPG Key ID: F71D56A3151C4FB3
1 changed files with 8 additions and 2 deletions

View File

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