Skip to content

Commit

Permalink
Fix duplicate click actions
Browse files Browse the repository at this point in the history
  • Loading branch information
hufman committed Oct 12, 2023
1 parent b06d337 commit 4ede74a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions app/lib/rhmi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class RHMIAction {
final action = switch (type) {
"combinedAction" => RHMICombinedAction(id, type, attributes),
"hmiAction" => RHMIHmiAction(id, type, attributes),
"raAction" => RHMIRaAction(id, type, attributes),
_ => RHMIAction(id, type, attributes),
};
if (action is RHMICombinedAction) {
Expand All @@ -184,13 +185,13 @@ class RHMIAction {
class RHMICombinedAction extends RHMIAction {
RHMICombinedAction(super.id, super.type, super.attributes);

RHMIAction? raAction;
RHMIRaAction? raAction;
RHMIHmiAction? hmiAction;

void loadChildren(XmlNode combinedActionNode) {
combinedActionNode.getElement("actions")?.childElements.forEach((element) {
final action = RHMIAction.loadXml(element);
if (action.type == "raAction") {
if (action is RHMIRaAction && action.type == "raAction") {
raAction = action;
}
if (action is RHMIHmiAction && action.type == "hmiAction") {
Expand All @@ -204,6 +205,10 @@ class RHMICombinedAction extends RHMIAction {
}
}

class RHMIRaAction extends RHMIAction {
RHMIRaAction(super.id, super.type, super.attributes);
}

class RHMIHmiAction extends RHMIAction {
RHMIHmiAction(super.id, super.type, super.attributes):
target = int.tryParse(attributes['target'] ?? '', radix: 10),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/rhmi_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class RHMICallbacks {
void action(RHMIComponent component, {Map<int, Object?>? args}) async {
final action = component.actions['action'];

if (action is RHMIAction) {
if (action is RHMIRaAction) {
dispatchAction(action.id, args: args);
}
if (action is RHMIHmiAction) {
Expand Down

0 comments on commit 4ede74a

Please sign in to comment.