forked from LaconicNetwork/icns-frontend
Minor fix
This commit is contained in:
parent
5d48012133
commit
53ecf825a0
@ -16,7 +16,23 @@ interface Props {
|
|||||||
export const ChainItem: FunctionComponent<Props> = (props) => {
|
export const ChainItem: FunctionComponent<Props> = (props) => {
|
||||||
const { chainItem, checkedItemHandler, checkedItems } = props;
|
const { chainItem, checkedItemHandler, checkedItems } = props;
|
||||||
const disabled = "disabled" in chainItem && chainItem.disabled;
|
const disabled = "disabled" in chainItem && chainItem.disabled;
|
||||||
const [checked, setChecked] = useState(!!disabled);
|
// XXX: Currently, this component can't handle `checked` state well,
|
||||||
|
// If chain is disabled, it should be disabled in general.
|
||||||
|
// However, if it is disabled due to the limitation of ethermint and ledger,
|
||||||
|
// it should be not checked.
|
||||||
|
// To solve this problem, for now, just use dumb way.
|
||||||
|
// If chain is disabled with explicit reason, it should be unchecked.
|
||||||
|
const [checked, setChecked] = useState(!!disabled && !chainItem.reason);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (disabled) {
|
||||||
|
if (chainItem.reason) {
|
||||||
|
setChecked(false);
|
||||||
|
} else {
|
||||||
|
setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [chainItem, disabled]);
|
||||||
|
|
||||||
const checkHandler = () => {
|
const checkHandler = () => {
|
||||||
if (!disabled) {
|
if (!disabled) {
|
||||||
|
@ -30,7 +30,7 @@ export const ChainList: FunctionComponent<Props> = (props) => {
|
|||||||
<ChainContainer color={color.grey["900"]}>
|
<ChainContainer color={color.grey["900"]}>
|
||||||
{chainList.map((chainItem) => (
|
{chainList.map((chainItem) => (
|
||||||
<ChainItem
|
<ChainItem
|
||||||
key={chainItem.address}
|
key={chainItem.chainId}
|
||||||
chainItem={chainItem}
|
chainItem={chainItem}
|
||||||
checkedItemHandler={checkedItemHandler}
|
checkedItemHandler={checkedItemHandler}
|
||||||
checkedItems={checkedItems}
|
checkedItems={checkedItems}
|
||||||
@ -38,7 +38,7 @@ export const ChainList: FunctionComponent<Props> = (props) => {
|
|||||||
))}
|
))}
|
||||||
{disabledChainList.map((chainItem) => (
|
{disabledChainList.map((chainItem) => (
|
||||||
<ChainItem
|
<ChainItem
|
||||||
key={chainItem.address}
|
key={chainItem.chainId}
|
||||||
chainItem={chainItem}
|
chainItem={chainItem}
|
||||||
checkedItemHandler={checkedItemHandler}
|
checkedItemHandler={checkedItemHandler}
|
||||||
checkedItems={checkedItems}
|
checkedItems={checkedItems}
|
||||||
|
Loading…
Reference in New Issue
Block a user