From 783ae49d22d4e702469aed7e64bb2e71be4c6130 Mon Sep 17 00:00:00 2001 From: Oleksandr Hladchenko1 Date: Tue, 7 Nov 2023 18:22:49 +0200 Subject: [PATCH] UIIN-2647: Reduce the depth --- src/ViewInstance.js | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/ViewInstance.js b/src/ViewInstance.js index 5894ffd4f..d2abc5a3a 100644 --- a/src/ViewInstance.js +++ b/src/ViewInstance.js @@ -531,27 +531,28 @@ class ViewInstance extends React.Component { const { selectedInstance } = this.props; const authorityIds = getLinkedAuthorityIds(selectedInstance); - if (!isEmpty(authorityIds)) { - this.props.mutator.authorities.GET({ - params: { - query: `id==(${authorityIds.join(' or ')})`, - } - }).then(({ authorities }) => { - const localAuthorities = authorities.filter(authority => !authority.source.startsWith(CONSORTIUM_PREFIX)); - - if (localAuthorities.length) { - this.setState({ - linkedAuthoritiesLength: localAuthorities.length, - isShareLocalInstanceModalOpen: false, - isUnlinkAuthoritiesModalOpen: true, - }); - } else { - this.handleShareLocalInstance(selectedInstance); - } - }); - } else { + if (isEmpty(authorityIds)) { this.handleShareLocalInstance(selectedInstance); + return; } + + this.props.mutator.authorities.GET({ + params: { + query: `id==(${authorityIds.join(' or ')})`, + } + }).then(({ authorities }) => { + const localAuthorities = authorities.filter(authority => !authority.source.startsWith(CONSORTIUM_PREFIX)); + + if (localAuthorities.length) { + this.setState({ + linkedAuthoritiesLength: localAuthorities.length, + isShareLocalInstanceModalOpen: false, + isUnlinkAuthoritiesModalOpen: true, + }); + } else { + this.handleShareLocalInstance(selectedInstance); + } + }); } toggleCopyrightModal = () => {