Skip to content

Commit

Permalink
fix: comments
Browse files Browse the repository at this point in the history
  • Loading branch information
devchenyan committed Jul 17, 2024
1 parent d3b036b commit b434a85
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const useOnSubmit = ({
createNetwork({
name,
remote,
networkType,
type: networkType,
})(dispatch, callback)
return
}
Expand Down
15 changes: 8 additions & 7 deletions packages/neuron-ui/src/components/NetworkSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,17 @@ const NetworkSetting = ({ chain = chainState, settings: { networks = [] } }: Sta
}
}, [currentId, networks])

// packages/neuron-wallet/src/services/networks.ts#L39
const isInternalLightClient = (id: string) => id.includes('light_client')
const isInternalLightClient = (network?: State.Network) =>
network && network.readonly && network.type === NetworkType.Light

const showNetworks = useMemo(() => {
const internalLightNodeId = lastShowInternalNodeIds.get(NetworkType.Light)
if (isInternalLightClient(internalLightNodeId)) {
return networks.filter(network => !isInternalLightClient(network.id) || network.id === internalLightNodeId)
const lastShowNetwork = networks.find(v => v.id === internalLightNodeId)
if (isInternalLightClient(lastShowNetwork)) {
return networks.filter(network => !isInternalLightClient(network) || network.id === internalLightNodeId)
}
const index = networks.findIndex(network => isInternalLightClient(network.id))
return networks.filter((network, i) => !isInternalLightClient(network.id) || index === i)
const index = networks.findIndex(network => isInternalLightClient(network))
return networks.filter((network, i) => !isInternalLightClient(network) || index === i)
}, [currentId, networks])

return (
Expand All @@ -118,7 +119,7 @@ const NetworkSetting = ({ chain = chainState, settings: { networks = [] } }: Sta
),
suffix: (
<div className={styles.suffix}>
{currentId === network.id && isInternalLightClient(network.id) && network.type === NetworkType.Light ? (
{currentId === network.id && isInternalLightClient(network) ? (
<Tooltip
tip={
<div>
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/types/Controller/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ declare namespace Controller {
interface CreateNetworkParams {
name: string
remote: string
networkType: NetworkType
type: NetworkType
}

interface UpdateNetworkParams {
Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-wallet/src/services/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ export default class NetworksService extends Store {
.then(info => info.chain)
.catch(() => '')
} else if (network.chain === 'ckb_dev') {
if (genesisHash === TESTNET_GENESIS_HASH) network.chain = LIGHT_CLIENT_TESTNET
if (genesisHash === MAINNET_GENESIS_HASH) network.chain = LIGHT_CLIENT_MAINNET
if (genesisHash === TESTNET_GENESIS_HASH) chain = LIGHT_CLIENT_TESTNET
if (genesisHash === MAINNET_GENESIS_HASH) chain = LIGHT_CLIENT_MAINNET
}
if (genesisHash !== network.genesisHash && chain !== '') {
network.genesisHash = genesisHash
Expand Down

1 comment on commit b434a85

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 9969643826

Please sign in to comment.