@ledvance/ui-biz-bundle 1.1.121 → 1.1.123

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.121",
7
+ "version": "1.1.123",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -72,6 +72,27 @@ interface ConflictItem {
72
72
  endTime: number
73
73
  weeks: number[]
74
74
  enable: boolean
75
+ channel?: number
76
+ }
77
+
78
+ const processConflictItems = <T extends ConflictItem>(
79
+ items: T[],
80
+ conflictItem: ConflictItem,
81
+ transformItem?: (item: T) => ConflictItem
82
+ ): { hasConflict: boolean; newItems: T[] } => {
83
+ let hasConflict = false
84
+ const newItems = items.map(item => {
85
+ if (!item.enable || (item.channel !== undefined && item.channel !== conflictItem.channel)) return item
86
+
87
+ const checkItem = transformItem ? transformItem(item) : item
88
+ if (isConflictTask(checkItem, conflictItem)) {
89
+ hasConflict = true
90
+ return { ...item, enable: false }
91
+ }
92
+ return item
93
+ })
94
+
95
+ return { hasConflict, newItems }
75
96
  }
76
97
 
77
98
  export const useConflictTask = (conflictDps: ConflictDps, isPlug?: boolean): [(v: ConflictItem) => boolean, () => void] => {
@@ -101,75 +122,35 @@ export const useConflictTask = (conflictDps: ConflictDps, isPlug?: boolean): [(v
101
122
  }
102
123
  }
103
124
  if (conflictDps.fixedTimeDpCode && fixedTime.length){
104
- let conflict = false
105
- const newFixedTime = fixedTime.map(item => {
106
- if (item.enable && isConflictTask(item, conflictItem)) {
107
- conflict = true
108
- return {
109
- ...item,
110
- enable: false
111
- }
112
- }
113
- return item
114
- })
115
- if (conflict){
116
- newState[conflictDps.fixedTimeDpCode] = newFixedTime
125
+ const { hasConflict, newItems } = processConflictItems(fixedTime, conflictItem)
126
+ if (hasConflict) {
127
+ newState[conflictDps.fixedTimeDpCode] = newItems
117
128
  }
118
129
  }
119
130
  if (conflictDps.randomTimeDpCode && randomTime.length){
120
- let conflict = false
121
- const newRandomTime = randomTime.map(item => {
122
- if (item.enable && isConflictTask(item, conflictItem)) {
123
- conflict = true
124
- return {
125
- ...item,
126
- enable: false
127
- }
128
- }
129
- return item
130
- })
131
- if (conflict){
132
- newState[conflictDps.randomTimeDpCode] = newRandomTime
131
+ const { hasConflict, newItems } = processConflictItems(randomTime, conflictItem)
132
+ if (hasConflict) {
133
+ newState[conflictDps.randomTimeDpCode] = newItems
133
134
  }
134
135
  }
135
136
  if (conflictDps.sleepDpCode && sleepPlan.length){
136
- let conflict = false
137
- const newSleepPlan = sleepPlan.map(item => {
138
- if (item.enable && isConflictTask({
139
- ...item,
140
- startTime: getStartTime(item),
141
- endTime: getEndTime(item)
142
- }, conflictItem)) {
143
- conflict = true
144
- return {
145
- ...item,
146
- enable: false
147
- }
148
- }
149
- return item
150
- })
151
- if (conflict){
152
- newState[conflictDps.sleepDpCode] = newSleepPlan
137
+ const { hasConflict, newItems } = processConflictItems(sleepPlan, conflictItem, (item) => ({
138
+ ...item,
139
+ startTime: getStartTime(item),
140
+ endTime: getEndTime(item)
141
+ }))
142
+ if (hasConflict) {
143
+ newState[conflictDps.sleepDpCode] = newItems
153
144
  }
154
145
  }
155
146
  if (conflictDps.wakeUpDpCode && wakeUpPlan.length){
156
- let conflict = false
157
- const newWakeUpPlan = wakeUpPlan.map(item => {
158
- if (item.enable && isConflictTask({
159
- ...item,
160
- startTime: getStartTime(item),
161
- endTime: getEndTime(item)
162
- }, conflictItem)) {
163
- conflict = true
164
- return {
165
- ...item,
166
- enable: false
167
- }
168
- }
169
- return item
170
- })
171
- if (conflict){
172
- newState[conflictDps.wakeUpDpCode] = newWakeUpPlan
147
+ const { hasConflict, newItems } = processConflictItems(wakeUpPlan, conflictItem, (item) => ({
148
+ ...item,
149
+ startTime: getStartTime(item),
150
+ endTime: getEndTime(item)
151
+ }))
152
+ if (hasConflict) {
153
+ newState[conflictDps.wakeUpDpCode] = newItems
173
154
  }
174
155
  }
175
156
  if (conflictDps.switchIngCode && switchInching.enable){
@@ -139,7 +139,9 @@ const TimerPage = (props: {theme?: ThemeType}) => {
139
139
  alignItems: 'center',
140
140
  backgroundColor: props.theme?.global.background,
141
141
  marginBottom: cx(8)
142
- }}>
142
+ }}
143
+ key={item.dpId}
144
+ >
143
145
  <Text
144
146
  style={{
145
147
  color: props.theme?.global.fontColor,
@@ -12,7 +12,7 @@ import ThemeType from '@ledvance/base/src/config/themeType'
12
12
  import dayjs from "dayjs";
13
13
  import {EnergyHistory} from "../EnergyConsumptionActions";
14
14
 
15
- const { convertX: cx, height } = Utils.RatioUtils
15
+ const { convertX: cx, height, statusBarHeight } = Utils.RatioUtils
16
16
  const { withTheme } = Utils.ThemeUtils
17
17
 
18
18
  export const UnitList = [
@@ -264,7 +264,7 @@ const EnergyModal = (props: EnergyModalProps) => {
264
264
  </View>
265
265
  ),
266
266
  wrapperStyle: {
267
- height: height - cx(40),
267
+ height: height - statusBarHeight - cx(40),
268
268
  backgroundColor: props.theme?.global.background
269
269
  },
270
270
  footer: (<View style={{ backgroundColor: props.theme?.global.background}}></View>),
@@ -326,7 +326,7 @@ const EnergyModal = (props: EnergyModalProps) => {
326
326
  <Text style={{ color: props.theme?.button.primary, fontSize: cx(16) }}>{props.confirmText}</Text>
327
327
  </TouchableOpacity>
328
328
  </View>
329
- <View style={{ height: height - cx(100), paddingHorizontal: cx(16), backgroundColor: props.theme?.global.background }}>
329
+ <View style={{ height: height - statusBarHeight - cx(100), paddingHorizontal: cx(16), backgroundColor: props.theme?.global.background }}>
330
330
  {getContent()}
331
331
  </View>
332
332
  </ScrollView>
@@ -95,7 +95,8 @@ const FixedTimePage = (props: { theme?: ThemeType }) => {
95
95
  let itselfConflict = false
96
96
  cloneList.forEach((item, idx) => {
97
97
  const itself = mode === 'add' ? (idx === cloneList.length - 1) : fixedTime.index === item.index
98
- if (!itself && item.enable && isConflictTask(item, fixedTime)){
98
+ const isSameChannel = item.channel !== undefined ? item.channel === fixedTime.channel : true
99
+ if (!itself && item.enable && isSameChannel && isConflictTask(item, fixedTime)){
99
100
  itselfConflict = true
100
101
  item.enable = false
101
102
  }
@@ -98,8 +98,8 @@ export const getRemoteMoodList = async (
98
98
  ) => {
99
99
  const isFeature = !(option.isCeilingLight || option.isStringLight || option.isStripLight);
100
100
  const moodFeatureId = isFeature ? (option.isMixLight ? MixLightSceneListFeatureId : SceneFeatureId) : (option.isCeilingLight ? SceneFeatureId : featureId)
101
+ const defScene = getDefMoodList(option)
101
102
  if (isRefresh){
102
- const defScene = getDefMoodList(option)
103
103
  const res = await setRemoteMoodList(devId, isFeature, defScene, featureId)
104
104
  if (res.success){
105
105
  return {
@@ -117,7 +117,7 @@ export const getRemoteMoodList = async (
117
117
  const result = await setRemoteMoodList(
118
118
  devId,
119
119
  isFeature,
120
- getDefMoodList(option),
120
+ defScene,
121
121
  moodFeatureId
122
122
  );
123
123
  if (!result.success) {
@@ -125,7 +125,7 @@ export const getRemoteMoodList = async (
125
125
  }
126
126
  return {
127
127
  success: true,
128
- data: result.data.map((item, index) => remoteMoodInfo2MoodUIState(item, index, option)),
128
+ data: defScene.map((item, index) => remoteMoodInfo2MoodUIState(item, index, option)),
129
129
  };
130
130
  }
131
131
  return {
@@ -144,12 +144,11 @@ export const getRemoteMoodList = async (
144
144
  };
145
145
  } else {
146
146
  if (res.msg?.includes('资源未找到') || !isNormalData) {
147
- const defaultScene = getDefMoodList(option);
148
- const res = await setRemoteMoodList(devId, isFeature, defaultScene, moodFeatureId);
147
+ const res = await setRemoteMoodList(devId, isFeature, defScene, moodFeatureId);
149
148
  if (res.success) {
150
149
  return {
151
150
  success: true,
152
- data: defaultScene.map((item, index) =>
151
+ data: defScene.map((item, index) =>
153
152
  remoteMoodInfo2MoodUIState(item, index, option)
154
153
  ),
155
154
  };
@@ -96,7 +96,8 @@ const RandomTimePage = (props: { theme?: ThemeType }) => {
96
96
  let itselfConflict = false
97
97
  cloneList.forEach((item, idx) => {
98
98
  const itself = mode === 'add' ? (idx === cloneList.length - 1) : randomTime.index === item.index
99
- if (!itself && item.enable && isConflictTask(item, randomTime)){
99
+ const isSameChannel = item.channel !== undefined ? item.channel === randomTime.channel : true
100
+ if (!itself && item.enable && isSameChannel && isConflictTask(item, randomTime)){
100
101
  itselfConflict = true
101
102
  item.enable = false
102
103
  }