|
| 1 | +import 'package:built_collection/built_collection.dart'; |
| 2 | +import 'package:redux/redux.dart'; |
| 3 | +import 'package:scadnano/src/actions/actions.dart' as actions; |
| 4 | +import 'package:scadnano/src/state/app_state.dart'; |
| 5 | +import 'package:scadnano/src/state/design.dart'; |
| 6 | +import 'package:scadnano/src/state/strand.dart'; |
| 7 | + |
| 8 | +bool are_batch_actions(dynamic action) { |
| 9 | + for (var action in action.actions) { |
| 10 | + if (!(action is actions.StrandNameSet || |
| 11 | + action is actions.StrandOrSubstrandColorSet || |
| 12 | + action is actions.ScaffoldSet || |
| 13 | + action is actions.SubstrandNameSet || |
| 14 | + action is actions.StrandLabelSet || |
| 15 | + action is actions.SubstrandLabelSet || |
| 16 | + action is actions.RemoveDNA)) { |
| 17 | + return false; |
| 18 | + } |
| 19 | + } |
| 20 | + return true; |
| 21 | +} |
| 22 | + |
| 23 | +reselect_after_props(Store<AppState> store, action, NextDispatcher next) { |
| 24 | + List<String> prevIds = store.state.ui_state.selectables_store.selected_strands.map((s) => s.id).toList(); |
| 25 | + if (action is actions.BatchAction && are_batch_actions(action) || |
| 26 | + ((action is actions.AssignDNAComplementFromBoundStrands || |
| 27 | + action is actions.ScalePurificationVendorFieldsAssign || |
| 28 | + action is actions.AssignDomainNameComplementFromBoundDomains || |
| 29 | + action is actions.AssignDNA || |
| 30 | + action is actions.StrandOrSubstrandColorSet || |
| 31 | + action is actions.SubstrandNameSet || |
| 32 | + action is actions.SubstrandLabelSet || |
| 33 | + action is actions.ExtensionAdd || |
| 34 | + action is actions.PlateWellVendorFieldsAssign || |
| 35 | + action is actions.PlateWellVendorFieldsRemove || |
| 36 | + action is actions.VendorFieldsRemove || |
| 37 | + action is actions.StrandsReflect) && |
| 38 | + prevIds.length > 1)) { |
| 39 | + next(action); |
| 40 | + |
| 41 | + List<Strand> new_strands = []; |
| 42 | + Design newDesign = store.state.design; |
| 43 | + for (var strand in newDesign.strands) { |
| 44 | + if (prevIds.contains(strand.id)) { |
| 45 | + new_strands.add(strand); |
| 46 | + } |
| 47 | + } |
| 48 | + store.dispatch(actions.SelectAll(selectables: new_strands.toBuiltList(), only: true)); |
| 49 | + } else { |
| 50 | + next(action); |
| 51 | + } |
| 52 | +} |
0 commit comments