From 16efaad606dc6de6312c68a287a4ec74241b223f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Fri, 18 Jun 2021 12:38:21 +0200 Subject: [PATCH] Fix chain condition of responses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- src/components/ContactDetails.vue | 2 +- src/components/ContactDetails/ContactDetailsAvatar.vue | 4 ++-- src/components/MembersList/MembersListItem.vue | 2 +- src/store/contacts.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/ContactDetails.vue b/src/components/ContactDetails.vue index 405d49a79..1ef81ccb0 100644 --- a/src/components/ContactDetails.vue +++ b/src/components/ContactDetails.vue @@ -573,7 +573,7 @@ export default { } catch (error) { if (error.name === 'ParserError') { showError(t('contacts', 'Syntax error. Cannot open the contact.')) - } else if (error.status === 404) { + } else if (error?.status === 404) { showError(t('contacts', 'The contact doesn\'t exists anymore on the server.')) } else { showError(t('contacts', 'Unable to retrieve the contact from the server, please check your network connection.')) diff --git a/src/components/ContactDetails/ContactDetailsAvatar.vue b/src/components/ContactDetails/ContactDetailsAvatar.vue index e8708743e..abc7d64ec 100644 --- a/src/components/ContactDetails/ContactDetailsAvatar.vue +++ b/src/components/ContactDetails/ContactDetailsAvatar.vue @@ -427,7 +427,7 @@ export default { id: this.contact.addressbook.id, uid: this.contact.uid, })) - if (response.status !== 200) { + if (response?.status !== 200) { throw new URIError('Download of social profile avatar failed') } @@ -441,7 +441,7 @@ export default { // Notify user showSuccess(t('contacts', 'Avatar downloaded from social network')) } catch (error) { - if (error.response.status === 304) { + if (error?.response?.status === 304) { showInfo(t('contacts', 'Avatar already up to date')) } else { showError(t('contacts', 'Avatar download failed')) diff --git a/src/components/MembersList/MembersListItem.vue b/src/components/MembersList/MembersListItem.vue index 51961a0d7..47795d008 100644 --- a/src/components/MembersList/MembersListItem.vue +++ b/src/components/MembersList/MembersListItem.vue @@ -240,7 +240,7 @@ export default { leave: this.isCurrentUser, }) } catch (error) { - if (error.response.status === 404) { + if (error?.response?.status === 404) { this.logger.debug('Member is not in circle') return } diff --git a/src/store/contacts.js b/src/store/contacts.js index 0e8eb6909..fd79b5a1d 100644 --- a/src/store/contacts.js +++ b/src/store/contacts.js @@ -370,7 +370,7 @@ const actions = { console.error(error) // wrong etag, we most likely have a conflict - if (error && error.status === 412) { + if (error && error?.status === 412) { // saving the new etag so that the user can manually // trigger a fetchCompleteData without any further errors context.commit('setContactAsConflict', { contact, etag: error.xhr.getResponseHeader('etag') })