Skip to content

Commit 01e53c6

Browse files
committed
feat: detach dashboard access event from login list api
1 parent f94f49b commit 01e53c6

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/components/login/Login.tsx

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const Login = () => {
6060
const location = useLocation()
6161
const history = useHistory()
6262

63-
const [initLoading, initResult] = useAsync(() => Promise.allSettled([getSSOConfigList(), dashboardAccessed()]), [])
63+
const [ssoListLoading, ssoListResponse] = useAsync(getSSOConfigList, [])
6464

6565
const setLoginNavigationURL = () => {
6666
let queryParam = searchParams.continue
@@ -96,25 +96,15 @@ const Login = () => {
9696

9797
useEffect(() => {
9898
setLoginNavigationURL()
99+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
100+
dashboardAccessed()
99101
}, [])
100102

101103
useEffect(() => {
102-
if (initResult && !initLoading) {
103-
const [ssoLoginListResponse, dashboardAccessesResponse] = initResult
104-
if (ssoLoginListResponse.status === 'fulfilled' && ssoLoginListResponse.value.result) {
105-
setLoginList(ssoLoginListResponse.value.result as SSOConfigLoginList[])
106-
}
107-
108-
if (
109-
typeof Storage !== 'undefined' &&
110-
!localStorage.getItem('isDashboardAccessed') &&
111-
dashboardAccessesResponse.status === 'fulfilled' &&
112-
dashboardAccessesResponse.value.result
113-
) {
114-
localStorage.setItem('isDashboardAccessed', 'true')
115-
}
104+
if (ssoListResponse?.result && !ssoListLoading) {
105+
setLoginList(ssoListResponse.result as SSOConfigLoginList[])
116106
}
117-
}, [initLoading, initResult])
107+
}, [ssoListLoading, ssoListResponse])
118108

119109
const onClickSSO = () => {
120110
if (typeof Storage !== 'undefined') {
@@ -127,7 +117,7 @@ const Login = () => {
127117

128118
const renderSSOLoginPage = () => (
129119
<div className="flexbox-col dc__gap-12 p-36">
130-
{initLoading && !loginList.length && (
120+
{ssoListLoading && !loginList.length && (
131121
<Button
132122
variant={ButtonVariantType.secondary}
133123
text="Checking SSO"

0 commit comments

Comments
 (0)