Skip to content

Commit ff61c51

Browse files
authored
Merge pull request #680 from nervosnetwork/rc/v0.1.0-alpha.9
[ᚬmaster] Release v0.1.0 alpha.9
2 parents 9fea146 + 6e3e0f8 commit ff61c51

File tree

29 files changed

+231
-50
lines changed

29 files changed

+231
-50
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.8",
5+
"version": "0.1.0-alpha.9",
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.8",
5+
"version": "0.1.0-alpha.9",
66
"private": true,
77
"author": {
88
"name": "Nervos Core Dev",

packages/neuron-ui/package.json

Lines changed: 1 addition & 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.8",
3+
"version": "0.1.0-alpha.9",
44
"private": true,
55
"author": {
66
"name": "Nervos Core Dev",
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, { Component } from 'react'
2+
import { appCalls } from 'services/UILayer'
3+
import { Stack, Spinner } from 'office-ui-fabric-react'
4+
5+
const handleError = (error: Error) => {
6+
appCalls.handleViewError(error.toString())
7+
setTimeout(() => {
8+
window.location.reload()
9+
}, 0)
10+
return { hasError: true }
11+
}
12+
13+
class ErrorBoundary extends Component<{ children: React.ReactChild }, { hasError: boolean }> {
14+
state = {
15+
hasError: false,
16+
}
17+
18+
static getDerivedStateFromError(error: Error) {
19+
return handleError(error)
20+
}
21+
22+
public componentDidCatch(error: Error) {
23+
this.setState(handleError(error))
24+
}
25+
26+
render() {
27+
const { hasError } = this.state
28+
const { children } = this.props
29+
return hasError ? (
30+
<Stack verticalFill verticalAlign="center">
31+
<Spinner />
32+
</Stack>
33+
) : (
34+
children
35+
)
36+
}
37+
}
38+
39+
export default ErrorBoundary

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ const History = ({
5050
<Stack horizontal horizontalAlign="end" tokens={{ childrenGap: 15 }}>
5151
<SearchBox
5252
value={keywords}
53-
styles={{ root: { width: 200 } }}
54-
placeholder="Search"
53+
styles={{ root: { width: 500 } }}
54+
placeholder={t('history.search.placeholder')}
5555
onChange={onKeywordsChange}
5656
onSearch={onSearch}
5757
iconProps={{ iconName: 'Search', styles: { root: { height: '18px' } } }}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ const TransactionList = ({
8989
key: 'hash',
9090
fieldName: 'hash',
9191
minWidth: 100,
92-
maxWidth: 500,
92+
maxWidth: 600,
9393
onRender: (item?: FormatTransaction) => {
9494
if (item) {
9595
return (
96-
<span className="text-overflow" title={item.hash}>
96+
<span className="text-overflow fixedWidth" title={item.hash}>
9797
{item.hash}
9898
</span>
9999
)
@@ -187,7 +187,7 @@ const TransactionList = ({
187187
<DetailsList
188188
columns={transactionColumns}
189189
items={txs}
190-
groups={groups}
190+
groups={groups.filter(group => group.count !== 0)}
191191
groupProps={{
192192
onRenderHeader,
193193
}}

packages/neuron-ui/src/containers/Footer/index.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,33 @@ const stackItemStyles = {
2222
root: [theme.fonts.small],
2323
}
2424

25-
const SyncStatus = ({
25+
export const SyncStatus = ({
2626
tipBlockNumber = '',
27-
syncBlockNumber = '',
28-
}: React.PropsWithoutRef<{ tipBlockNumber: string; syncBlockNumber: string }>) => {
27+
syncedBlockNumber = '',
28+
bufferBlockNumber = 10,
29+
}: React.PropsWithoutRef<{ tipBlockNumber: string; syncedBlockNumber: string; bufferBlockNumber?: number }>) => {
2930
const [t] = useTranslation()
3031
if (tipBlockNumber === '') {
3132
return <Text variant="small">{t('footer.fail-to-fetch-tip-block-number')}</Text>
3233
}
3334

34-
const percentage = +syncBlockNumber / +tipBlockNumber
35+
const percentage = +syncedBlockNumber / +tipBlockNumber
3536

3637
return (
3738
<div style={{ display: 'flex', alignItems: 'center', fontSize: theme.fonts.small.fontSize }}>
38-
{t('sync.syncing')}
39-
<ProgressIndicator percentComplete={percentage} styles={{ root: { width: '120px', marginLeft: '5px' } }} />
39+
{+syncedBlockNumber + bufferBlockNumber < +tipBlockNumber ? (
40+
<>
41+
{t('sync.syncing')}
42+
<ProgressIndicator percentComplete={percentage} styles={{ root: { width: '120px', marginLeft: '5px' } }} />
43+
</>
44+
) : (
45+
t('sync.synced')
46+
)}
4047
</div>
4148
)
4249
}
4350

44-
const NetworkStatus = ({ name, online }: { name: string; online: boolean }) => {
51+
export const NetworkStatus = ({ name, online }: { name: string; online: boolean }) => {
4552
return (
4653
<Stack horizontal verticalAlign="center" tokens={{ childrenGap: 5 }}>
4754
{online ? <ConnectIcon size="small" color="green" /> : <AlertIcon size="small" color="red" />}
@@ -56,7 +63,7 @@ const Footer = ({
5663
}: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps>) => {
5764
const {
5865
app: { tipBlockNumber },
59-
chain: { networkID, connectStatus },
66+
chain: { networkID, connectStatus, tipBlockNumber: syncedBlockNumber },
6067
settings: { networks },
6168
} = useContext(NeuronWalletContext)
6269
const [t] = useTranslation()
@@ -80,7 +87,7 @@ const Footer = ({
8087
styles={stackStyles}
8188
>
8289
<Stack.Item styles={stackItemStyles}>
83-
<SyncStatus tipBlockNumber={tipBlockNumber} syncBlockNumber="100" />
90+
<SyncStatus tipBlockNumber={tipBlockNumber} syncedBlockNumber={syncedBlockNumber} />
8491
</Stack.Item>
8592

8693
<Stack styles={stackItemStyles} onClick={goToNetworksSetting} horizontal>

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ export const useChannelListeners = ({
5252
(
5353
_e: Event,
5454
_actionType: 'create' | 'update' | 'delete',
55-
dataType: 'address' | 'transaction' | 'wallet' | 'network'
55+
dataType: 'address' | 'transaction' | 'wallet' | 'network',
56+
walletIDOfMessage?: string
5657
) => {
58+
if (walletIDOfMessage && walletIDOfMessage !== walletID) {
59+
return
60+
}
5761
switch (dataType) {
5862
case 'address': {
5963
walletsCall.getAllAddresses(walletID)
@@ -198,7 +202,7 @@ export const useChannelListeners = ({
198202
dispatch({
199203
type: NeuronWalletActions.Chain,
200204
payload: {
201-
tipBlockNumber: args.result,
205+
tipBlockNumber: args.result || '0',
202206
},
203207
})
204208
break
@@ -335,7 +339,7 @@ export const useChannelListeners = ({
335339
})
336340
break
337341
}
338-
case WalletsMethod.AllAddresses: {
342+
case WalletsMethod.GetAllAddresses: {
339343
const addresses = args.result || []
340344
dispatch({
341345
type: NeuronWalletActions.Wallet,

packages/neuron-ui/src/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Navbar from 'containers/Navbar'
1111
import Notification from 'containers/Notification'
1212
import Main from 'containers/Main'
1313
import Footer from 'containers/Footer'
14+
import ErrorBoundary from 'components/ErrorBoundary'
1415
import withProviders from 'states/stateProvider'
1516

1617
loadTheme({
@@ -63,7 +64,11 @@ const App = withProviders(({ dispatch }: any) => (
6364
<Route
6465
{...container}
6566
key={container.name}
66-
render={routeProps => <container.comp {...routeProps} dispatch={dispatch} />}
67+
render={routeProps => (
68+
<ErrorBoundary>
69+
<container.comp {...routeProps} dispatch={dispatch} />
70+
</ErrorBoundary>
71+
)}
6772
/>
6873
)
6974
})}

packages/neuron-ui/src/locales/en.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"balance": "Balance",
1717
"live-cells": "Live Cells",
1818
"cell-types": "Cell Types",
19-
"recent-activities": "Recent Activites",
19+
"recent-activities": "Recent Activities",
2020
"no-recent-activities": "No Recent Activities",
2121
"blockchain-status": "Blockchain Status",
2222
"blockchain-identity": "Chain Identity",
@@ -71,7 +71,7 @@
7171
"receive": {
7272
"click-to-copy": "Click to copy the address",
7373
"address-not-found": "Address not found",
74-
"prompt": "Neuron picks a new receiving address for better privacy. Please go to the Address Book if you want to use a previously used receiving addresses.",
74+
"prompt": "Neuron picks a new receiving address for better privacy. Please go to the Address Book if you want to use a previously used receiving address.",
7575
"address-qrcode": "Address QR Code"
7676
},
7777
"history": {
@@ -94,7 +94,10 @@
9494
"description": "Description",
9595
"status": "Status",
9696
"blockNumber": "Block Number",
97-
"basic-information": "Basic Information"
97+
"basic-information": "Basic Information",
98+
"search": {
99+
"placeholder": "Search tx hash, address or date (yyyy-mm-dd)"
100+
}
98101
},
99102
"transaction": {
100103
"goBack": "Go back"
@@ -207,7 +210,8 @@
207210
"no-transactions": "No transactions"
208211
},
209212
"sync": {
210-
"syncing": "Syncing"
213+
"syncing": "Syncing",
214+
"synced": "Synced"
211215
},
212216
"pagination": {
213217
"previous-page": "Previous page",

0 commit comments

Comments
 (0)