@@ -140,36 +140,49 @@ export class RunsWithQcModel extends RunsOverviewModel {
140140 }
141141
142142 /**
143- * Register not-bad fraction detectors filtering model
143+ * Register not-bad fraction detectors filtering model and update it when detectors are loaded
144+ * Also, trigger an immediate update if detectors are already loaded at the moment of registration
144145 *
145146 * @param {ObservableData<RemoteData<Detector>> } detectors$ detectors remote data observable
146147 */
147148 registerDetectorsNotBadFractionFilterModels ( detectors$ ) {
148- detectors$ . observe ( ( observableData ) => observableData . getCurrent ( ) . apply ( {
149- Success : ( detectors ) => detectors . forEach ( ( { id } ) => {
150- this . _filteringModel . put ( `detectorsQc[_${ id } ][notBadFraction]` , new NumericalComparisonFilterModel ( {
151- scale : 0.01 ,
152- integer : false ,
153- } ) ) ;
154- } ) ,
155- } ) ) ;
149+ const callback = ( observableData ) => {
150+ const current = observableData . getCurrent ( ) ;
151+ current ?. apply ( {
152+ Success : ( detectors ) => detectors . forEach ( ( { id } ) => {
153+ this . _filteringModel . put ( `detectorsQc[_${ id } ][notBadFraction]` , new NumericalComparisonFilterModel ( {
154+ scale : 0.01 ,
155+ integer : false ,
156+ } ) ) ;
157+ } ) ,
158+ } ) ;
159+ } ;
160+ detectors$ . observe ( callback ) ;
161+ callback ( detectors$ ) ;
156162 }
157163
158164 /**
159- * Register detectors for QC flags data export
165+ * Register detectors for QC flags data export and update export configuration when detectors are loaded
166+ * Also, trigger an immediate update if detectors are already loaded at the moment of registration
160167 *
161168 * @param {ObservableData<RemoteData<Detector>> } detectors$ detectors remote data observable
162169 */
163170 registerDetectorsForQcFlagsDataExport ( detectors$ ) {
164- detectors$ . observe ( ( observableData ) => observableData . getCurrent ( ) . apply ( {
165- Success : ( detectors ) => {
166- this . _exportModel . setDataExportConfiguration ( {
167- ...baseDataExportConfiguration ,
168- ...qcFlagsExportConfigurationFactory ( detectors ) ,
169- } ) ;
170- } ,
171- Other : ( ) => null ,
172- } ) ) ;
171+ const callback = ( observableData ) => {
172+ const current = observableData . getCurrent ( ) ;
173+ current ?. apply ( {
174+ Success : ( detectors ) => {
175+ this . _exportModel . setDataExportConfiguration ( {
176+ ...baseDataExportConfiguration ,
177+ ...qcFlagsExportConfigurationFactory ( detectors ) ,
178+ } ) ;
179+ } ,
180+ Other : ( ) => null ,
181+ } ) ;
182+ } ;
183+ detectors$ . observe ( callback ) ;
184+ // Also trigger immediately if detectors are already loaded
185+ callback ( detectors$ ) ;
173186 }
174187
175188 /**
@@ -179,9 +192,13 @@ export class RunsWithQcModel extends RunsOverviewModel {
179192 */
180193 registerObservablesQcSummaryDependsOn ( detectors$ ) {
181194 this . _observablesQcFlagsSummaryDependsOn$ = detectors$ ;
182-
183- this . _observablesQcFlagsSummaryDependsOn$
184- . observe ( ( observableData ) => observableData . getCurrent ( ) . apply ( { Success : ( ) => this . _fetchQcSummary ( ) } ) ) ;
195+ const callback = ( observableData ) => {
196+ const current = observableData . getCurrent ( ) ;
197+ current ?. apply ( { Success : ( ) => this . _fetchQcSummary ( ) } ) ;
198+ } ;
199+ this . _observablesQcFlagsSummaryDependsOn$ . observe ( callback ) ;
200+ // Also trigger immediately if detectors are already loaded
201+ callback ( this . _observablesQcFlagsSummaryDependsOn$ ) ;
185202 }
186203
187204 /**
@@ -208,7 +225,7 @@ export class RunsWithQcModel extends RunsOverviewModel {
208225 async _fetchQcSummary ( ) {
209226 const qcSummaryScopeValid = Object . entries ( this . qcSummaryScope ) . filter ( ( [ , id ] ) => id ) . length == 1 ;
210227
211- if ( qcSummaryScopeValid && this . detectors && this . _observablesQcFlagsSummaryDependsOn$ . getCurrent ( ) ) {
228+ if ( qcSummaryScopeValid && this . detectors && this . _observablesQcFlagsSummaryDependsOn$ ? .getCurrent ( ) ) {
212229 mergeRemoteData ( [ this . detectors , this . _observablesQcFlagsSummaryDependsOn$ . getCurrent ( ) ] ) . match ( {
213230 Success : async ( [ detectors ] ) => {
214231 this . _qcSummary$ . setCurrent ( RemoteData . loading ( ) ) ;
0 commit comments