Skip to content

Commit cf6b006

Browse files
authored
Merge pull request #698 from nervosnetwork/rc/v0.1.0-alpha.11
[ᚬmaster] Release v0.1.0 alpha.11
2 parents 501f8b4 + c35277d commit cf6b006

File tree

25 files changed

+440
-38
lines changed

25 files changed

+440
-38
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "0.1.0-alpha.10",
5+
"version": "0.1.0-alpha.11",
66
"npmClient": "yarn",
77
"useWorkspaces": true
88
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@nervosnetwork/neuron",
33
"productName": "Neuron",
44
"description": "CKB Neuron Wallet",
5-
"version": "0.1.0-alpha.10",
5+
"version": "0.1.0-alpha.11",
66
"private": true,
77
"author": {
88
"name": "Nervos Core Dev",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import '@storybook/addon-actions/register'
22
import '@storybook/addon-links/register'
33
import '@storybook/addon-viewport/register'
4+
import '@storybook/addon-knobs/register';

packages/neuron-ui/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nervosnetwork/neuron-ui",
3-
"version": "0.1.0-alpha.10",
3+
"version": "0.1.0-alpha.11",
44
"private": true,
55
"author": {
66
"name": "Nervos Core Dev",
@@ -56,6 +56,7 @@
5656
},
5757
"devDependencies": {
5858
"@storybook/addon-actions": "5.1.9",
59+
"@storybook/addon-knobs": "5.1.9",
5960
"@storybook/addon-links": "5.1.9",
6061
"@storybook/addon-viewport": "5.1.9",
6162
"@storybook/addons": "5.1.9",
@@ -68,6 +69,7 @@
6869
"@types/react-dom": "16.8.4",
6970
"@types/react-router-dom": "4.3.3",
7071
"@types/storybook-react-router": "1.0.0",
72+
"@types/storybook__addon-knobs": "5.0.3",
7173
"@types/storybook__react": "4.0.2",
7274
"@types/styled-components": "4.1.16",
7375
"babel-jest": "24.8.0",

packages/neuron-ui/src/components/History/hooks.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ const backToTop = () => {
1414
}
1515
}
1616

17-
export const useSearch = (
18-
search: string = '',
19-
incomingKeywords: string = '',
20-
walletID: string = '',
21-
dispatch: React.Dispatch<any>
22-
) => {
17+
export const useSearch = (search: string = '', walletID: string = '', dispatch: React.Dispatch<any>) => {
2318
const [keywords, setKeywords] = useState('')
2419

2520
const onKeywordsChange = (_e?: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>, newValue?: string) => {
@@ -28,10 +23,6 @@ export const useSearch = (
2823
}
2924
}
3025

31-
useEffect(() => {
32-
setKeywords(incomingKeywords)
33-
}, [incomingKeywords, setKeywords])
34-
3526
useEffect(() => {
3627
backToTop()
3728
const params = queryParsers.history(search)

packages/neuron-ui/src/components/History/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ registerIcons({
3434
const History = ({
3535
wallet: { id },
3636
chain: {
37-
transactions: { pageNo = 1, pageSize = 15, totalCount = 0, items = [], keywords: incomingKeywords = '' },
37+
transactions: { pageNo = 1, pageSize = 15, totalCount = 0, items = [] },
3838
},
3939
history,
4040
location: { search },
4141
dispatch,
4242
}: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps>) => {
4343
const [t] = useTranslation()
4444

45-
const { keywords, onKeywordsChange } = useSearch(search, incomingKeywords, id, dispatch)
45+
const { keywords, onKeywordsChange } = useSearch(search, id, dispatch)
4646
const onSearch = useCallback(() => history.push(`${Routes.History}?keywords=${keywords}`), [history, keywords])
4747

4848
return (

packages/neuron-ui/src/components/WalletWizard/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ const Mnemonic = ({
139139
if (isCreate) {
140140
history.push(`${rootPath}${WalletWizardPath.Mnemonic}/${MnemonicAction.Verify}`)
141141
} else {
142+
dispatch({
143+
type: 'imported',
144+
payload: imported.trim().replace(/(\s+|\n+)/g, ' '),
145+
})
142146
const isMnemonicValid = validateMnemonic(imported)
143147
if (isMnemonicValid) {
144148
history.push(
@@ -150,7 +154,7 @@ const Mnemonic = ({
150154
showErrorMessage(t('messages.error'), t('messages.invalid-mnemonic'))
151155
}
152156
}
153-
}, [isCreate, history, rootPath, type, imported, t])
157+
}, [isCreate, history, rootPath, type, imported, t, dispatch])
154158

155159
return (
156160
<Stack verticalFill verticalAlign="center" horizontalAlign="stretch" tokens={{ childrenGap: 15 }}>

packages/neuron-ui/src/containers/Main/hooks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ export const useSyncChainData = ({ chainURL, dispatch }: { chainURL: string; dis
468468
if (chainURL) {
469469
ckbCore.setNode(chainURL)
470470
syncTipNumber()
471+
syncBlockchainInfo()
471472
timer = setInterval(() => {
472473
syncTipNumber()
473474
syncBlockchainInfo()

packages/neuron-ui/src/states/stateProvider/reducer.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,13 @@ export const reducer = (
8989
...payload,
9090
},
9191
}
92-
newState.chain.transactions.items = newState.chain.transactions.items.sort(
93-
(item1, item2) => +(item2.timestamp || item2.createdAt) - +(item1.timestamp || item1.createdAt)
94-
)
92+
const pendingTxs = newState.chain.transactions.items
93+
.filter(item => item.status === 'pending')
94+
.sort((item1, item2) => +(item2.timestamp || item2.createdAt) - +(item1.timestamp || item1.createdAt))
95+
const determinedTxs = newState.chain.transactions.items
96+
.filter(item => item.status !== 'pending')
97+
.sort((item1, item2) => +(item2.timestamp || item2.createdAt) - +(item1.timestamp || item1.createdAt))
98+
newState.chain.transactions.items = [...pendingTxs, ...determinedTxs]
9599
return newState
96100
}
97101
case NeuronWalletActions.Settings: {
@@ -136,6 +140,15 @@ export const reducer = (
136140
},
137141
}
138142
}
143+
case AppActions.UpdateChainInfo: {
144+
return {
145+
...state,
146+
app: {
147+
...app,
148+
...payload,
149+
},
150+
}
151+
}
139152
case AppActions.UpdateTransactionID: {
140153
return {
141154
...state,

packages/neuron-ui/src/stories/Addresses.stories.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import { Route, RouteComponentProps } from 'react-router-dom'
33
import StoryRouter from 'storybook-react-router'
44
import { storiesOf } from '@storybook/react'
5+
import { withKnobs, text, number } from '@storybook/addon-knobs'
56
import Addresses from 'components/Addresses'
67
import initStates from 'states/initStates'
78
import addressesStates from './data/addresses'
@@ -20,3 +21,15 @@ const stories = storiesOf('Addresses', module).addDecorator(StoryRouter())
2021
Object.entries(addressesStates).forEach(([title, list]) => {
2122
stories.add(title, () => <AddressWithRouteProps addresses={list} />)
2223
})
24+
25+
stories.addDecorator(withKnobs).add('With knobs', () => {
26+
const addrs = addressesStates['Content List'].map((addr, idx) => ({
27+
address: text(`${idx}-Address`, addr.address),
28+
identifier: text(`${idx}-Identifier`, addr.identifier),
29+
description: text(`${idx}-Description`, addr.description),
30+
type: number(`${idx}-Type`, addr.type) as 0 | 1,
31+
txCount: number(`${idx}-Tx count`, addr.txCount),
32+
balance: text(`${idx}-Balance`, addr.balance),
33+
}))
34+
return <AddressWithRouteProps addresses={addrs} />
35+
})

0 commit comments

Comments
 (0)