Skip to content

Commit 7dfe670

Browse files
committed
feat: Show popup message when clearing cache finishes
1 parent 7419d37 commit 7dfe670

4 files changed

Lines changed: 10 additions & 17 deletions

File tree

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
11
import React, { useCallback, useState } from 'react'
22
import { useTranslation } from 'react-i18next'
33
import { Stack, PrimaryButton, Spinner } from 'office-ui-fabric-react'
4-
import { StateWithDispatch, AppActions } from 'states/stateProvider/reducer'
4+
import { StateWithDispatch } from 'states/stateProvider/reducer'
5+
import { addPopup } from 'states/stateProvider/actionCreators'
56
import { clearCellCache } from 'services/remote'
67

78
const GeneralSetting = ({ dispatch }: React.PropsWithoutRef<StateWithDispatch>) => {
89
const [t] = useTranslation()
910
const [clearing, setClearing] = useState(false)
1011

1112
const clearCache = useCallback(() => {
12-
// TODO: real clear action
1313
setClearing(true)
1414
setTimeout(() => {
15-
clearCellCache()
16-
.catch(err => {
17-
dispatch({
18-
type: AppActions.AddNotification,
19-
payload: {
20-
type: 'alert',
21-
timestamp: +new Date(),
22-
content: err.message,
23-
},
24-
})
25-
})
26-
.finally(() => {
27-
setClearing(false)
28-
})
29-
}, 1000)
15+
clearCellCache().finally(() => {
16+
addPopup('clear-cache-successfully')(dispatch)
17+
setClearing(false)
18+
})
19+
}, 100)
3020
}, [dispatch])
3121

3222
return (

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@
257257
"delete-wallet-successfully": "The wallet was deleted",
258258
"create-network-successfully": "The network was created",
259259
"update-network-successfully": "The network was updated",
260+
"clear-cache-successfully": "The cache was cleared",
260261
"addr-copied": "Address has been copied to the clipboard",
261262
"qrcode-copied": "QR Code has been copied to the clipboard",
262263
"view-the-run-node-doc": "View the guide in browser",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@
257257
"delete-wallet-successfully": "已删除钱包",
258258
"create-network-successfully": "已添加新节点",
259259
"update-network-successfully": "已更新节点信息",
260+
"clear-cache-successfully": "已清空数据缓存",
260261
"addr-copied": "已复制地址到剪贴板",
261262
"qrcode-copied": "已复制二维码到剪贴板",
262263
"view-the-run-node-doc": "打开浏览器查看文档",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const initAppState = () => (dispatch: StateDispatch, history: any) => {
6060
})
6161
}
6262

63+
// text: an i18n key under `messages`
6364
export const addPopup = (text: string) => (dispatch: StateDispatch) => {
6465
dispatch({
6566
type: AppActions.PopIn,

0 commit comments

Comments
 (0)