Skip to content

Commit 8b89b1e

Browse files
committed
feat(neuron-ui): add loading on creating networks
1 parent b7f1b5a commit 8b89b1e

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

  • packages/neuron-ui/src/states/stateProvider/actionCreators

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,29 @@ export const toggleAddressBook = () => {
1515
}
1616

1717
export const createNetwork = (params: Controller.CreateNetworkParams) => (dispatch: StateDispatch, history: any) => {
18-
createRemoteNetwork(params).then(res => {
19-
if (res.status === 1) {
20-
addPopup('create-network-successfully')(dispatch)
21-
history.push(Routes.SettingsNetworks)
22-
} else {
23-
addNotification(failureResToNotification(res))(dispatch)
24-
}
18+
dispatch({
19+
type: AppActions.UpdateLoadings,
20+
payload: {
21+
network: true,
22+
},
2523
})
24+
createRemoteNetwork(params)
25+
.then(res => {
26+
if (res.status === 1) {
27+
addPopup('create-network-successfully')(dispatch)
28+
history.push(Routes.SettingsNetworks)
29+
} else {
30+
addNotification(failureResToNotification(res))(dispatch)
31+
}
32+
})
33+
.finally(() => {
34+
dispatch({
35+
type: AppActions.UpdateLoadings,
36+
payload: {
37+
network: false,
38+
},
39+
})
40+
})
2641
}
2742

2843
export const updateNetwork = (params: Controller.UpdateNetworkParams) => (dispatch: StateDispatch, history: any) => {

0 commit comments

Comments
 (0)