Fix for 0 accounts on access (#1109)
This commit is contained in:
parent
585840320b
commit
5227206fd6
@ -31,14 +31,14 @@ function AccountManagement ({ className }: Props): React.ReactElement<Props> {
|
|||||||
|
|
||||||
setSelectedAccounts && setSelectedAccounts(list[url].authorizedAccounts);
|
setSelectedAccounts && setSelectedAccounts(list[url].authorizedAccounts);
|
||||||
})
|
})
|
||||||
.catch((e) => console.error(e));
|
.catch(console.error);
|
||||||
}, [setSelectedAccounts, url]);
|
}, [setSelectedAccounts, url]);
|
||||||
|
|
||||||
const _onApprove = useCallback(
|
const _onApprove = useCallback(
|
||||||
(): void => {
|
(): void => {
|
||||||
updateAuthorization(selectedAccounts, url)
|
updateAuthorization(selectedAccounts, url)
|
||||||
.then(() => onAction('/auth-list'))
|
.then(() => onAction('/auth-list'))
|
||||||
.catch((error: Error) => console.error(error));
|
.catch(console.error);
|
||||||
},
|
},
|
||||||
[onAction, selectedAccounts, url]
|
[onAction, selectedAccounts, url]
|
||||||
);
|
);
|
||||||
|
|||||||
@ -18,11 +18,13 @@ interface Props extends ThemeProps {
|
|||||||
url: string;
|
url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function WebsiteEntry ({ className = '', info, removeAuth, url }: Props): React.ReactElement<Props> {
|
function WebsiteEntry ({ className = '', info: { authorizedAccounts }, removeAuth, url }: Props): React.ReactElement<Props> {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const _removeAuth = useCallback(() => {
|
|
||||||
removeAuth(url);
|
const _removeAuth = useCallback(
|
||||||
}, [removeAuth, url]);
|
() => removeAuth(url),
|
||||||
|
[removeAuth, url]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
@ -34,11 +36,13 @@ function WebsiteEntry ({ className = '', info, removeAuth, url }: Props): React.
|
|||||||
className='connectedAccounts'
|
className='connectedAccounts'
|
||||||
to={`/url/manage/${url}`}
|
to={`/url/manage/${url}`}
|
||||||
>{
|
>{
|
||||||
t('{{total}} accounts', {
|
authorizedAccounts && authorizedAccounts.length
|
||||||
replace: {
|
? t('{{total}} accounts', {
|
||||||
total: info.authorizedAccounts.length
|
replace: {
|
||||||
}
|
total: authorizedAccounts.length
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
: t('no accounts')
|
||||||
}</Link>
|
}</Link>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import type { ThemeProps } from '../../types';
|
import type { ThemeProps } from '../../types';
|
||||||
|
|
||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import { AuthUrlInfo, AuthUrls } from '@polkadot/extension-base/background/handlers/State';
|
import { AuthUrlInfo, AuthUrls } from '@polkadot/extension-base/background/handlers/State';
|
||||||
@ -29,6 +29,11 @@ function AuthManagement ({ className }: Props): React.ReactElement<Props> {
|
|||||||
.catch((e) => console.error(e));
|
.catch((e) => console.error(e));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const hasAuthList = useMemo(
|
||||||
|
() => !!authList && !!Object.keys(authList).length,
|
||||||
|
[authList]
|
||||||
|
);
|
||||||
|
|
||||||
const _onChangeFilter = useCallback((filter: string) => {
|
const _onChangeFilter = useCallback((filter: string) => {
|
||||||
setFilter(filter);
|
setFilter(filter);
|
||||||
}, []);
|
}, []);
|
||||||
@ -55,23 +60,25 @@ function AuthManagement ({ className }: Props): React.ReactElement<Props> {
|
|||||||
withReset
|
withReset
|
||||||
/>
|
/>
|
||||||
{
|
{
|
||||||
!authList || !Object.entries(authList)?.length
|
!authList || !hasAuthList
|
||||||
? <div className='empty-list'>{t<string>('No website request yet!')}</div>
|
? <div className='empty-list'>{t<string>('No website request yet!')}</div>
|
||||||
: <>
|
: (
|
||||||
<div className='website-list'>
|
<>
|
||||||
{Object.entries(authList)
|
<div className='website-list'>
|
||||||
.filter(([url]: [string, AuthUrlInfo]) => url.includes(filter))
|
{Object
|
||||||
.map(
|
.entries<AuthUrlInfo>(authList)
|
||||||
([url, info]: [string, AuthUrlInfo]) =>
|
.filter(([url]) => url.includes(filter))
|
||||||
|
.map(([url, info]) =>
|
||||||
<WebsiteEntry
|
<WebsiteEntry
|
||||||
info={info}
|
info={info}
|
||||||
key={url}
|
key={url}
|
||||||
removeAuth={removeAuth}
|
removeAuth={removeAuth}
|
||||||
url={url}
|
url={url}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -171,5 +171,6 @@
|
|||||||
"{{total}} accounts": "",
|
"{{total}} accounts": "",
|
||||||
"Account connection request": "",
|
"Account connection request": "",
|
||||||
"Understood": "",
|
"Understood": "",
|
||||||
"Ask again later": ""
|
"Ask again later": "",
|
||||||
|
"no accounts": ""
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user