@ledvance/ui-biz-bundle 1.1.82 → 1.1.83

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.82",
7
+ "version": "1.1.83",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -92,6 +92,7 @@ export interface DefMoodOption extends LightCategory{
92
92
  isSupportColor: boolean;
93
93
  isSupportTemperature: boolean;
94
94
  isSupportBrightness: boolean;
95
+ isSupportSceneStatus?: boolean;// putFeature中的SceneStatus,包含Flag和Mood选中的ID
95
96
  }
96
97
 
97
98
  export interface MoodDps {
@@ -19,10 +19,10 @@ import {
19
19
  stripDp2Obj,
20
20
  stripObj2Dp,
21
21
  } from './MoodParse';
22
- import { useDp, useDps } from '@ledvance/base/src/models/modules/NativePropsSlice';
23
- import { useState } from 'react';
22
+ import {useDeviceId, useDp, useDps} from '@ledvance/base/src/models/modules/NativePropsSlice';
23
+ import {useCallback, useEffect, useState} from 'react';
24
24
  import { useUpdateEffect } from 'ahooks';
25
- import { WorkMode } from '@ledvance/base/src/utils/interface';
25
+ import {SceneStatusType, WorkMode } from '@ledvance/base/src/utils/interface';
26
26
  import { Result } from '@ledvance/base/src/models/modules/Result';
27
27
 
28
28
  const SceneFeatureId = 'SimplifyScene';
@@ -241,3 +241,31 @@ export const saveMoodList = (
241
241
  : SceneFeatureId;
242
242
  return setRemoteMoodList(devId, isFeature, remoteMoods, moodFeatureId);
243
243
  };
244
+
245
+ export function useSceneStatusId(params: MoodPageParams): [number, (moodId: number) => Promise<any>] {
246
+ const devId = useDeviceId();
247
+ const [sceneStatusId, setSceneStatusId] = useState(-1);
248
+ if (!params.isSupportSceneStatus) {
249
+ const setEmpty = useCallback(() => {
250
+ return new Promise<any>(() => {});
251
+ }, [])
252
+ return [sceneStatusId, setEmpty]
253
+ }
254
+ useEffect(() => {
255
+ getFeature(devId, "SceneStatus").then((res) => {
256
+ if (res.data && res.data.type === SceneStatusType.Mood) {
257
+ setSceneStatusId(res.data.id)
258
+ }
259
+ })
260
+ }, [])
261
+ const setSceneStatusIdRemote = useCallback((moodId: number) => {
262
+ return new Promise<any>((resolve, _reject) => {
263
+ putFeature(devId, "SceneStatus", {type: SceneStatusType.Mood, id: moodId}).then((res) => {
264
+ setSceneStatusId(moodId);
265
+ resolve(res);
266
+ })
267
+ });
268
+ }, [])
269
+
270
+ return [sceneStatusId, setSceneStatusIdRemote]
271
+ }
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useEffect, useMemo } from 'react';
2
2
  import Page from '@ledvance/base/src/components/Page';
3
3
  import { Utils } from 'tuya-panel-kit';
4
- import { saveMoodList, useSwitchLed, useWorkMode } from './MoodActions';
4
+ import {saveMoodList, useSceneStatusId, useSwitchLed, useWorkMode} from './MoodActions';
5
5
  import {
6
6
  useDeviceId,
7
7
  useDeviceInfo,
@@ -41,6 +41,7 @@ const MoodPage = () => {
41
41
  const [secondaryWork, setSecondaryWork] = useWorkMode(params.secondaryWorkMode!);
42
42
  const [switchLed] = useSwitchLed(params.switchLedDp)
43
43
  const [flagMode, setFlagMode] = useFlagMode();
44
+ const [sceneStatusId, setSceneStatusId] = useSceneStatusId(params);
44
45
 
45
46
  const state = useReactive<MoodPageState>({
46
47
  currentMood: undefined,
@@ -160,7 +161,9 @@ const MoodPage = () => {
160
161
  },
161
162
  };
162
163
  if (mode === 'set') {
163
- return setMoodInfo(checkedMood);
164
+ await setMoodInfo(checkedMood);
165
+ await setSceneStatusId(checkedMood.id);
166
+ return;
164
167
  }
165
168
  let newScene: MoodUIInfo[] = [];
166
169
  if (mode === 'add') {
@@ -197,18 +200,20 @@ const MoodPage = () => {
197
200
  if (mood) {
198
201
  if (mode === 'del') {
199
202
  if (
200
- (mainWork !== WorkMode.Scene && secondaryWork !== WorkMode.Scene) ||
201
- (params.isCeilingLight
202
- ? currentMood.mainLamp.id !== moodInfo.mainLamp.id &&
203
- currentMood.secondaryLamp.id !== moodInfo.secondaryLamp.id
204
- : currentMood.id !== moodInfo.id) || !switchLed
203
+ (mainWork !== WorkMode.Scene && secondaryWork !== WorkMode.Scene) ||
204
+ (params.isCeilingLight
205
+ ? currentMood.mainLamp.id !== moodInfo.mainLamp.id &&
206
+ currentMood.secondaryLamp.id !== moodInfo.secondaryLamp.id
207
+ : (params.isSupportSceneStatus ? currentMood.id !== sceneStatusId : currentMood.id !== moodInfo.id)) || !switchLed
205
208
  ) {
206
209
  return {
207
210
  success: true,
208
211
  };
209
212
  }
210
213
  }
211
- setMoodInfo(mood).then();
214
+ setMoodInfo(mood).then(() => {
215
+ setSceneStatusId(mood.id).then();
216
+ });
212
217
  } else {
213
218
  if (mainWork === WorkMode.Scene) {
214
219
  if (params.isCeilingLight) {
@@ -266,18 +271,20 @@ const MoodPage = () => {
266
271
  );
267
272
 
268
273
  const getItemEnable = useCallback(
269
- (moodItem: MoodUIInfo) => {
270
- if (params.isCeilingLight) {
271
- return (
272
- moodInfo.mainLamp.id === moodItem.mainLamp.id &&
273
- moodInfo.secondaryLamp.id === moodItem.secondaryLamp.id &&
274
- (mainWork === WorkMode.Scene || secondaryWork === WorkMode.Scene) && !flagMode.flagMode && switchLed
275
- );
276
- } else {
277
- return moodInfo.id === moodItem.id && mainWork === WorkMode.Scene && !flagMode.flagMode && switchLed
278
- }
279
- },
280
- [moodInfo, mainWork, secondaryWork, flagMode?.flagMode, switchLed]
274
+ (moodItem: MoodUIInfo) => {
275
+ if (params.isCeilingLight) {
276
+ return (
277
+ moodInfo.mainLamp.id === moodItem.mainLamp.id &&
278
+ moodInfo.secondaryLamp.id === moodItem.secondaryLamp.id &&
279
+ (mainWork === WorkMode.Scene || secondaryWork === WorkMode.Scene) && !flagMode.flagMode && switchLed
280
+ );
281
+ } else if (params.isSupportSceneStatus) {
282
+ return sceneStatusId === moodItem.id && mainWork === WorkMode.Scene && !flagMode.flagMode && switchLed
283
+ } else {
284
+ return moodInfo.id === moodItem.id && mainWork === WorkMode.Scene && !flagMode.flagMode && switchLed
285
+ }
286
+ },
287
+ [moodInfo, mainWork, secondaryWork, flagMode?.flagMode, switchLed, sceneStatusId]
281
288
  );
282
289
 
283
290
  const nameRepeat = useCallback((mood: MoodUIInfo) => {