@ledvance/ui-biz-bundle 1.1.50 → 1.1.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.1.50",
7
+ "version": "1.1.51",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -23,17 +23,22 @@ import dayjs from 'dayjs'
23
23
 
24
24
  type UseBiorhythmType = (dpKey: string) => [BiorhythmBean, SetBiorhythmType];
25
25
  type SetBiorhythmType = (deviceId: string, biorhythmObj: BiorhythmBean) => Promise<Result<any>>;
26
-
26
+ let rhythmTimer: undefined | number = undefined
27
27
  export const useBiorhythm: UseBiorhythmType = (dpKey: string) => {
28
28
  const [dp] = useDp<string, any>(dpKey)
29
29
  const deviceId = useDeviceId()
30
30
  const [biorhythmState, setBiorhythmState] = useState(dp2Obj(dp))
31
31
  useEffect(() => {
32
- getRemoteBiorhythm(deviceId, biorhythmState).then(res => {
33
- if (res.success && res.data) {
34
- setBiorhythmState(dto2Vo(res.data))
35
- }
36
- })
32
+ rhythmTimer = setTimeout(() =>{
33
+ getRemoteBiorhythm(deviceId, biorhythmState).then(res => {
34
+ if (res.success && res.data) {
35
+ setBiorhythmState(dto2Vo(res.data))
36
+ }
37
+ })
38
+ }, 400)
39
+ return () =>{
40
+ if(rhythmTimer) clearTimeout(rhythmTimer)
41
+ }
37
42
  }, [dp])
38
43
  return [biorhythmState, setBiorhythm(useDispatch(), dpKey)]
39
44
  }