Skip to content

Commit 9b85589

Browse files
committed
feat(neuron-ui): limit the times of guide bubble to 3
1 parent 59f2dd5 commit 9b85589

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next'
55
import { Stack, getTheme, Text, ProgressIndicator, Icon, TooltipHost, TeachingBubble } from 'office-ui-fabric-react'
66

77
import { openExternal } from 'services/remote'
8+
import { guideBubbleTimes } from 'services/localCache'
89
import { StateWithDispatch } from 'states/stateProvider/reducer'
910
import { NeuronWalletContext } from 'states/stateProvider'
1011
import { ConnectionStatus, FULL_SCREENS, RUN_NODE_GUIDE_URL, Routes } from 'utils/const'
@@ -79,8 +80,9 @@ const Footer = ({
7980
const [showGuide, setShowGuide] = useState(false)
8081

8182
useEffect(() => {
82-
if (connectionStatus !== ConnectionStatus.Online) {
83+
if (connectionStatus !== ConnectionStatus.Online && guideBubbleTimes.getRemaining()) {
8384
setShowGuide(true)
85+
guideBubbleTimes.reduce()
8486
} else {
8587
setShowGuide(false)
8688
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export enum LocalCacheKey {
55
CurrentWallet = 'currentWallet',
66
CurrentNetworkID = 'currentNetworkID',
77
SystemScript = 'systemScript',
8+
GuideBubbleTimes = 'guideBubbleTimes',
89
}
910

1011
export const addresses = {
@@ -122,6 +123,18 @@ export const systemScript = {
122123
},
123124
}
124125

126+
export const guideBubbleTimes = {
127+
getRemaining: () => {
128+
const t = window.localStorage.getItem(LocalCacheKey.GuideBubbleTimes)
129+
const remaining = t === null ? 3 : +t
130+
return remaining
131+
},
132+
reduce: () => {
133+
const remaining = guideBubbleTimes.getRemaining()
134+
window.localStorage.setItem(LocalCacheKey.GuideBubbleTimes, `${Math.max(remaining - 1, 0)}`)
135+
},
136+
}
137+
125138
export default {
126139
LocalCacheKey,
127140
addresses,
@@ -130,4 +143,5 @@ export default {
130143
currentWallet,
131144
currentNetworkID,
132145
systemScript,
146+
guideBubbleTimes,
133147
}

0 commit comments

Comments
 (0)