Skip to content

Commit 3f68111

Browse files
committed
more triggers filtering changes for legacy ears
1 parent c69d23f commit 3f68111

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

lib/Backend/sensors.dart

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ abstract class TriggerDefinition extends ChangeNotifier implements Comparable<Tr
212212
return;
213213
}
214214
// we need to handle legacy ears for now
215+
// assuming only legacy or tailcontrol ears are connected. no mixing
215216
bool hasLegacyEars = ref
216217
.read(getAvailableIdleGearForTypeProvider([DeviceType.ears].toBuiltSet()))
217218
.where(
@@ -248,40 +249,26 @@ abstract class TriggerDefinition extends ChangeNotifier implements Comparable<Tr
248249
actionsToRun.add(baseAction);
249250
}
250251
//only adding a check here
251-
if (baseAction != null && moveActions.length > 1 && ((baseAction is CommandAction && hasLegacyEars) || !baseAction.deviceCategory.toSet().containsAll(flattenedDeviceTypes) || (baseAction is EarsMoveList && !hasLegacyEars))) {
252+
if (baseAction != null && moveActions.length > 1 && ((baseAction is CommandAction && hasLegacyEars) || !baseAction.deviceCategory.toSet().containsAll(flattenedDeviceTypes))) {
252253
// find the missing device type
253254
// The goal here is if a user selects multiple moves, send a move to all gear
254255
final Set<DeviceType> missingGearAction = baseAction.deviceCategory
255-
.where(
256+
.whereNot(
256257
// filtering out the first actions ears entry if its a unified move but legacy gear is connected
257-
(element) {
258-
if (DeviceType.ears == element) {
259-
if (baseAction is CommandAction && hasLegacyEars) {
260-
return false;
261-
} else if (baseAction is EarsMoveList && !hasLegacyEars) {
262-
return false;
263-
}
264-
}
265-
return true;
266-
},
258+
(element) => (DeviceType.ears == element && (baseAction is CommandAction && hasLegacyEars)),
267259
)
268260
.toSet()
269261
.difference(flattenedDeviceTypes);
270262
final List<BaseAction> remainingActions = moveActions.where(
271263
// Check if any actions contain the device type of the gear the first action is missing
272264
(element) {
273-
if (baseAction is CommandAction && missingGearAction.contains(DeviceType.ears)) {
265+
// filters out remaining CommandActions if legacy ears are connected. Assumes Custom Actions send to ears too
266+
if (baseAction is CommandAction && hasLegacyEars) {
274267
if (element is EarsMoveList) {
275268
return true;
276269
} else if (element is CommandAction) {
277270
return false;
278271
}
279-
} else if (baseAction is EarsMoveList && missingGearAction.contains(DeviceType.ears)) {
280-
if (element is CommandAction) {
281-
return true;
282-
} else if (element is EarsMoveList) {
283-
return false;
284-
}
285272
}
286273
return element.deviceCategory.toSet().intersection(missingGearAction).isNotEmpty;
287274
},
@@ -317,7 +304,7 @@ abstract class TriggerDefinition extends ChangeNotifier implements Comparable<Tr
317304
return false;
318305
}
319306
}
320-
// return remaining gear if action is not a glowtip action
307+
// return remaining gear
321308
return true;
322309
},
323310
).toList()

0 commit comments

Comments
 (0)