Skip to content

Commit 940e23a

Browse files
committed
feat: Always show address book
1 parent 07dc1b3 commit 940e23a

19 files changed

Lines changed: 26 additions & 162 deletions

File tree

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect, useMemo } from 'react'
1+
import React, { useState, useMemo } from 'react'
22
import { RouteComponentProps } from 'react-router-dom'
33
import { useTranslation } from 'react-i18next'
44
import {
@@ -18,7 +18,6 @@ import { ckbCore } from 'services/chain'
1818
import { StateWithDispatch } from 'states/stateProvider/reducer'
1919

2020
import { useLocalDescription } from 'utils/hooks'
21-
import { Routes } from 'utils/const'
2221
import { localNumberFormatter, shannonToCKBFormatter } from 'utils/formatters'
2322
import { onRenderRow } from 'utils/fabricUIRender'
2423

@@ -28,22 +27,13 @@ const Addresses = ({
2827
},
2928
wallet: { addresses = [], id: walletID },
3029
chain: { networkID },
31-
settings: {
32-
general: { showAddressBook = false },
33-
networks = [],
34-
},
35-
history,
30+
settings: { networks = [] },
3631
dispatch,
3732
}: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps>) => {
3833
const isMainnet =
3934
(networks.find(n => n.id === networkID) || {}).chain === (process.env.REACT_APP_MAINNET_TAG || 'ckb')
4035
const [showMainnetAddress, setShowMainnetAddress] = useState(false)
4136
const [t] = useTranslation()
42-
useEffect(() => {
43-
if (!showAddressBook) {
44-
history.push(Routes.Overview)
45-
}
46-
}, [showAddressBook, history])
4737

4838
const {
4939
localDescription,

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,21 @@ import { Stack, Toggle } from 'office-ui-fabric-react'
33
import { useTranslation } from 'react-i18next'
44

55
import { StateWithDispatch } from 'states/stateProvider/reducer'
6-
import { toggleAddressBook, setSkipDataAndType } from 'states/stateProvider/actionCreators'
6+
import { setSkipDataAndType } from 'states/stateProvider/actionCreators'
77

88
const GeneralSetting = ({
99
settings: {
10-
general: { showAddressBook, skipDataAndType },
10+
general: { skipDataAndType },
1111
},
1212
dispatch,
1313
}: React.PropsWithoutRef<StateWithDispatch>) => {
1414
const [t] = useTranslation()
15-
const [onToggleAddressVisibility, onSetSkipDataAndType] = useMemo(
16-
() => [() => dispatch(toggleAddressBook()), () => setSkipDataAndType(!skipDataAndType)(dispatch)],
17-
[dispatch, skipDataAndType]
18-
)
15+
const [onSetSkipDataAndType] = useMemo(() => [() => setSkipDataAndType(!skipDataAndType)(dispatch)], [
16+
dispatch,
17+
skipDataAndType,
18+
])
1919
return (
2020
<Stack tokens={{ childrenGap: 15 }}>
21-
<Toggle
22-
checked={showAddressBook}
23-
label={t('settings.general.display-address-book-in-the-navbar')}
24-
onText={t('common.toggle.on')}
25-
offText={t('common.toggle.off')}
26-
onChange={onToggleAddressVisibility}
27-
/>
2821
<Toggle
2922
checked={skipDataAndType}
3023
label={t('settings.general.skip-data-and-type')}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useEffect } from 'react'
22

33
import { NeuronWalletActions, StateDispatch, AppActions } from 'states/stateProvider/reducer'
44
import {
5-
toggleAddressBook,
65
updateTransactionList,
76
updateCurrentWallet,
87
updateWalletList,
@@ -214,10 +213,6 @@ export const useSubscription = ({
214213
history.push(payload)
215214
break
216215
}
217-
case 'toggle-address-book': {
218-
dispatch(toggleAddressBook())
219-
break
220-
}
221216
case 'delete-wallet': {
222217
dispatch({
223218
type: AppActions.RequestPassword,

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,11 @@ const Navbar = ({
4242
}: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps>) => {
4343
const neuronWallet = useState()
4444
const {
45-
settings: {
46-
wallets = [],
47-
general: { showAddressBook = false },
48-
},
45+
settings: { wallets = [] },
4946
} = neuronWallet
5047
const [t] = useTranslation()
5148

52-
const pivotItems = useMemo(() => (showAddressBook ? menuItems : menuItems.slice(0, menuItems.length - 1)), [
53-
showAddressBook,
54-
])
49+
const pivotItems = menuItems
5550

5651
const selectedKey = useMemo(() => {
5752
const selectedTab = pivotItems.find(item => item.key === pathname.split('/')[1])

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@
180180
"network": "Network"
181181
},
182182
"general": {
183-
"display-address-book-in-the-navbar": "Show the address book",
184183
"skip-data-and-type": "Skip the Cells which contain Data or Type Script",
185184
"show": "Show",
186185
"hide": "Hide"

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@
180180
"network": "网络"
181181
},
182182
"general": {
183-
"display-address-book-in-the-navbar": "显示地址簿",
184183
"skip-data-and-type": "忽略包含 Data 或 Type Script 的 Cells",
185184
"show": "显示",
186185
"hide": "隐藏"

packages/neuron-ui/src/services/localCache.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
11
export enum LocalCacheKey {
2-
AddressBookVisibility = 'address-book-visibility',
32
Addresses = 'addresses',
43
Networks = 'networks',
54
Wallets = 'wallets',
65
CurrentWallet = 'currentWallet',
76
CurrentNetworkID = 'currentNetworkID',
87
SystemScript = 'systemScript',
98
}
10-
enum AddressBookVisibility {
11-
Invisible = '0',
12-
Visible = '1',
13-
}
14-
15-
export const addressBook = {
16-
isVisible: () => {
17-
const isVisible = window.localStorage.getItem(LocalCacheKey.AddressBookVisibility)
18-
return AddressBookVisibility.Visible === isVisible
19-
},
20-
21-
toggleVisibility: () => {
22-
window.localStorage.setItem(
23-
LocalCacheKey.AddressBookVisibility,
24-
addressBook.isVisible() ? AddressBookVisibility.Invisible : AddressBookVisibility.Visible
25-
)
26-
},
27-
}
289

2910
export const addresses = {
3011
save: (addressList: State.Address[]) => {
@@ -143,7 +124,6 @@ export const systemScript = {
143124

144125
export default {
145126
LocalCacheKey,
146-
addressBook,
147127
addresses,
148128
networks,
149129
wallets,

packages/neuron-ui/src/states/initStates/settings.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { addressBook, wallets, networks } from 'services/localCache'
1+
import { wallets, networks } from 'services/localCache'
22

33
export const settingsState: State.Settings = {
44
general: {
55
skipDataAndType: false,
6-
showAddressBook: addressBook.isVisible(),
76
},
87
networks: networks.load(),
98
wallets: wallets.load(),

packages/neuron-ui/src/states/stateProvider/actionCreators/settings.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
import { createNetwork as createRemoteNetwork, updateNetwork as updateRemoteNetwork } from 'services/remote'
2-
import { addressBook } from 'services/localCache'
32
import { Routes } from 'utils/const'
43
import { failureResToNotification } from 'utils/formatters'
54
import { addNotification, addPopup } from './app'
65

76
import { AppActions, StateDispatch } from '../reducer'
87

9-
export const toggleAddressBook = () => {
10-
addressBook.toggleVisibility()
11-
return {
12-
type: AppActions.ToggleAddressBookVisibility,
13-
payload: null,
14-
}
15-
}
16-
178
export const createNetwork = (params: Controller.CreateNetworkParams) => (dispatch: StateDispatch, history: any) => {
189
dispatch({
1910
type: AppActions.UpdateLoadings,
@@ -67,7 +58,6 @@ export const updateNetwork = (params: Controller.UpdateNetworkParams) => (dispat
6758
}
6859

6960
export default {
70-
toggleAddressBook,
7161
createNetwork,
7262
updateNetwork,
7363
}

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export enum NeuronWalletActions {
2222
UpdateSkipDataAndType = 'updateSkipDataAndType',
2323
}
2424
export enum AppActions {
25-
ToggleAddressBookVisibility = 'toggleAddressBookVisibility',
2625
UpdateTransactionID = 'updateTransactionID',
2726
AddSendOutput = 'addSendOutput',
2827
RemoveSendOutput = 'removeSendOutput',
@@ -103,18 +102,6 @@ export const reducer = (
103102
},
104103
}
105104
}
106-
case AppActions.ToggleAddressBookVisibility: {
107-
return {
108-
...state,
109-
settings: {
110-
...settings,
111-
general: {
112-
...settings.general,
113-
showAddressBook: !settings.general.showAddressBook,
114-
},
115-
},
116-
}
117-
}
118105
case NeuronWalletActions.UpdateSkipDataAndType: {
119106
return {
120107
...state,

0 commit comments

Comments
 (0)