Skip to content

Commit

Permalink
Merge pull request wso2#4339 from sandushi/duplicate-load-issue
Browse files Browse the repository at this point in the history
Fix double loading issue in alternative Login Identifiers
  • Loading branch information
sandushi authored Nov 13, 2023
2 parents 0484b46 + d805503 commit 5fa8f22
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-countries-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/console": patch
---

Fix duplicate loading issue in alternative login identifiers
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ export const AlternativeLoginIdentifierEditPage: FunctionComponent<AlternativeLo
const [ isApplicationRedirect, setApplicationRedirect ] = useState<boolean>(false);
const [ connector, setConnector ] = useState<GovernanceConnectorInterface>(undefined);
const [ availableClaims, setAvailableClaims ] = useState<ExtendedClaimInterface[]>([]);
const [ isClaimRequestLoading, setIsClaimRequestLoading ] = useState(false);
const [ isConnectorRequestLoading, setConnectorRequestLoading ] = useState<boolean>(false);
const [ isLoading, setIsLoading ] = useState(false);
const [ isSubmitting, setIsSubmitting ] = useState<boolean>(false);
const [ initialFormValues, setInitialFormValues ] = useState<AlternativeLoginIdentifierFormInterface>(undefined);
const availiableLoginIdentifierAttributes: string[] =
Expand Down Expand Up @@ -144,8 +143,6 @@ export const AlternativeLoginIdentifierEditPage: FunctionComponent<AlternativeLo
*/
const loadConnectorDetails = () => {

setConnectorRequestLoading(true);

getConnectorDetails(categoryId, connectorId)
.then((response: GovernanceConnectorInterface) => {
setConnector(response);
Expand Down Expand Up @@ -182,9 +179,6 @@ export const AlternativeLoginIdentifierEditPage: FunctionComponent<AlternativeLo
})
);
}
})
.finally(() => {
setConnectorRequestLoading(false);
});
};

Expand All @@ -193,7 +187,6 @@ export const AlternativeLoginIdentifierEditPage: FunctionComponent<AlternativeLo
*/
const getClaims = () => {

setIsClaimRequestLoading(true);
const params: ClaimsGetParams = {
"exclude-identity-claims": applicationConfig.excludeIdentityClaims,
filter: null,
Expand All @@ -217,8 +210,6 @@ export const AlternativeLoginIdentifierEditPage: FunctionComponent<AlternativeLo
message: t("console:manage.features.claims.local.notifications.fetchLocalClaims." +
"genericError.message")
}));
}).finally(() => {
setIsClaimRequestLoading(false);
});
};

Expand Down Expand Up @@ -358,6 +349,7 @@ export const AlternativeLoginIdentifierEditPage: FunctionComponent<AlternativeLo
});
}
setIsSubmitting(true);
setIsLoading(true);
updateGovernanceConnector(data, categoryId, connectorId)
.then(() => {
updateClaims(checkedClaims);
Expand All @@ -369,6 +361,7 @@ export const AlternativeLoginIdentifierEditPage: FunctionComponent<AlternativeLo
})
.finally(() => {
setIsSubmitting(false);
setIsLoading(false);
});
};

Expand Down Expand Up @@ -457,16 +450,15 @@ export const AlternativeLoginIdentifierEditPage: FunctionComponent<AlternativeLo
}, []);

useEffect(() => {
if (isClaimRequestLoading && isConnectorRequestLoading) {
if (isLoading) {
return;
}

initializeForm();
}, [
availableClaims,
isClaimRequestLoading,
connector,
isConnectorRequestLoading
isLoading
]);

/**
Expand All @@ -482,14 +474,16 @@ export const AlternativeLoginIdentifierEditPage: FunctionComponent<AlternativeLo
* Load multiattribute login and claim data.
*/
useEffect(() => {
setIsLoading(true);
getClaims();
loadConnectorDetails();
setIsLoading(false);
}, []);

return (
<>
{
!isClaimRequestLoading && !isConnectorRequestLoading && initialFormValues
!isLoading && initialFormValues
? (
<PageLayout
pageTitle={ t("extensions:manage.accountLogin.alternativeLoginIdentifierPage.pageTitle") }
Expand Down

0 comments on commit 5fa8f22

Please sign in to comment.