Skip to content

Commit 08a74a9

Browse files
committed
fix: do not consider disabled inputs
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
1 parent 730c189 commit 08a74a9

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/main/kotlin/ru/octol1ttle/flightassistant/api/util/extensions/CollectionExtensions.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import ru.octol1ttle.flightassistant.api.computer.Computer
99
* If there are no such inputs, the returned list contains all inputs with the highest priority in the list.
1010
*/
1111
fun List<ControlInput>.getActiveHighestPriority(): List<ControlInput> {
12-
// TODO
13-
val activeInput: List<ControlInput> = this.filter { it.status == ControlInput.Status.ACTIVE && it.priority.value == this[0].priority.value }
12+
// TODO: Disabled inputs should not be submitted in the first place
13+
val noDisabled = this.filter { it.status != ControlInput.Status.DISABLED }
14+
val activeInput: List<ControlInput> = noDisabled.filter { it.status == ControlInput.Status.ACTIVE && it.priority.value == noDisabled[0].priority.value }
1415
if (activeInput.any()) {
1516
return activeInput
1617
}
1718

18-
return this.filter { it.priority.value == this[0].priority.value }
19+
return noDisabled.filter { it.priority.value == noDisabled[0].priority.value }
1920
}
2021

2122
/**

0 commit comments

Comments
 (0)