1
1
import { is_defined } from "../../shared/utils/is_defined"
2
2
import { SortDirection , sort_list } from "../../shared/utils/sort"
3
3
import { update_substate } from "../../utils/update_state"
4
- import type { WComponentHasObjectives , WComponentJudgement } from "../../wcomponent/interfaces/judgement"
5
- import { wcomponent_is_goal , wcomponent_is_judgement_or_objective } from "../../wcomponent/interfaces/SpecialisedObjects"
4
+ import type { WComponentJudgement } from "../../wcomponent/interfaces/judgement"
5
+ import { wcomponent_is_judgement_or_objective } from "../../wcomponent/interfaces/SpecialisedObjects"
6
6
import { default_wcomponent_validity_value , get_wcomponent_validity_value } from "../../wcomponent_derived/get_wcomponent_validity_value"
7
7
import { get_wcomponents_from_state } from "../specialised_objects/accessors"
8
8
import type { RootState } from "../State"
@@ -26,13 +26,6 @@ export function derived_state_reducer (prev_state: RootState, state: RootState)
26
26
27
27
const judgement_or_objective_ids_by_target_id = update_judgement_or_objective_ids_by_target_id ( judgement_or_objectives )
28
28
state = update_substate ( state , "derived" , "judgement_or_objective_ids_by_target_id" , judgement_or_objective_ids_by_target_id )
29
-
30
- const goals = get_wcomponents_from_state ( state , state . derived . wcomponent_ids_by_type . goal )
31
- . filter ( is_defined )
32
- . filter ( wcomponent_is_goal )
33
-
34
- const judgement_or_objective_ids_by_goal_or_action_id = update_judgement_or_objective_ids_by_goal_or_action_id ( goals )
35
- state = update_substate ( state , "derived" , "judgement_or_objective_ids_by_goal_or_action_id" , judgement_or_objective_ids_by_goal_or_action_id )
36
29
}
37
30
38
31
@@ -79,23 +72,6 @@ function update_judgement_or_objective_ids_by_target_id (judgement_or_objectives
79
72
}
80
73
81
74
82
-
83
- function update_judgement_or_objective_ids_by_goal_or_action_id ( goals_and_actions : WComponentHasObjectives [ ] )
84
- {
85
- const judgement_or_objective_ids_by_goal_or_action_id : { [ goal_or_action_id : string ] : string [ ] } = { }
86
-
87
- goals_and_actions
88
- // .sort () // some kind of sort so that front end display is stable and predictable
89
- . forEach ( ( { id : goal_or_action_id , objective_ids } ) =>
90
- {
91
- judgement_or_objective_ids_by_goal_or_action_id [ goal_or_action_id ] = objective_ids || [ ]
92
- } )
93
-
94
- return judgement_or_objective_ids_by_goal_or_action_id
95
- }
96
-
97
-
98
-
99
75
function conditionally_update_active_judgement_or_objective_ids ( prev_state : RootState , state : RootState ) : RootState
100
76
{
101
77
let { current_composed_knowledge_view } = state . derived
@@ -111,12 +87,10 @@ function conditionally_update_active_judgement_or_objective_ids (prev_state: Roo
111
87
112
88
// todo: we should update when the order of elements in current_composed_knowledge_view
113
89
// changes so that ... <todo insert reason. Perhaps it's so that the list of judgements / objectives
114
- // are in the correct order when they are rendered on/for their targets and for their goals or actions?>
90
+ // are in the correct order when they are rendered on/for their targets and for their actions?>
115
91
if ( current_composed_knowledge_view && ( kv_id_changed || judgement_or_objective_ids_by_target_id_changed || created_at_ms_changed || sim_ms_changed ) )
116
92
{
117
93
const active_judgement_or_objective_ids_by_target_id : { [ id : string ] : string [ ] } = { }
118
- const active_judgement_or_objective_ids_by_goal_or_action_id : { [ id : string ] : string [ ] } = { }
119
-
120
94
121
95
const { wc_ids_by_type, composed_visible_wc_id_map } = current_composed_knowledge_view
122
96
const judgement_or_objectives = get_judgement_or_objectives ( state , wc_ids_by_type . judgement_or_objective )
@@ -153,15 +127,12 @@ function conditionally_update_active_judgement_or_objective_ids (prev_state: Roo
153
127
154
128
const {
155
129
judgement_or_objective_ids_by_target_id,
156
- judgement_or_objective_ids_by_goal_or_action_id,
157
130
} = state . derived
158
131
159
132
Object . keys ( composed_visible_wc_id_map )
160
133
. forEach ( id =>
161
134
{
162
135
const target_ids = judgement_or_objective_ids_by_target_id [ id ]
163
- const ids_from_goal_or_action = judgement_or_objective_ids_by_goal_or_action_id [ id ]
164
-
165
136
if ( target_ids )
166
137
{
167
138
const active_judgement_or_objective_ids = target_ids . filter ( judgement_or_objective_id_is_active )
@@ -172,24 +143,12 @@ function conditionally_update_active_judgement_or_objective_ids (prev_state: Roo
172
143
active_judgement_or_objective_ids_by_target_id [ id ] = sorted
173
144
}
174
145
}
175
-
176
- if ( ids_from_goal_or_action )
177
- {
178
- const active_judgement_or_objective_ids = ids_from_goal_or_action . filter ( judgement_or_objective_id_is_active )
179
- if ( active_judgement_or_objective_ids . length )
180
- {
181
- const sorted = sort_list ( active_judgement_or_objective_ids , get_wcomponent_ids_sort_key , SortDirection . descending )
182
-
183
- active_judgement_or_objective_ids_by_goal_or_action_id [ id ] = sorted
184
- }
185
- }
186
146
} )
187
147
188
148
189
149
current_composed_knowledge_view = {
190
150
...current_composed_knowledge_view ,
191
151
active_judgement_or_objective_ids_by_target_id,
192
- active_judgement_or_objective_ids_by_goal_or_action_id,
193
152
}
194
153
state = update_substate ( state , "derived" , "current_composed_knowledge_view" , current_composed_knowledge_view )
195
154
}
0 commit comments