Line data Source code
1 : import 'package:fast_immutable_collections/fast_immutable_collections.dart';
2 : import 'package:redux/redux.dart';
3 :
4 : import '../../adventures/models/adventure_model.dart';
5 : import '../../app_state.dart';
6 : import '../../challenges/models/challenge_model.dart';
7 : import '../../steps/models/step_model.dart';
8 : import '../../tasks/models/task_model.dart';
9 : import '../actions/set_adventure_nodes_action.dart';
10 :
11 : class SetAdventureNodesReducer
12 : extends TypedReducer<AppState, SetAdventureNodesAction> {
13 1 : SetAdventureNodesReducer()
14 2 : : super((state, action) {
15 2 : if (state.adventures.selected == null) {
16 1 : return state.copyWith
17 3 : .adventures(all: action.list as ISet<AdventureModel>);
18 : }
19 :
20 2 : if (state.challenges.selected == null) {
21 1 : return state.copyWith
22 3 : .challenges(all: action.list as ISet<ChallengeModel>);
23 : }
24 :
25 2 : if (state.tasks.selected == null) {
26 4 : return state.copyWith.tasks(all: action.list as ISet<TaskModel>);
27 : }
28 :
29 2 : if (state.steps.selected == null) {
30 4 : return state.copyWith.steps(all: action.list as ISet<StepModel>);
31 : }
32 :
33 : return state;
34 : });
35 : }
|