31
31
*/
32
32
33
33
import { _SubManagerBase } from '../_SubManagerBase.js' ;
34
- import { _Task } from '../_Task.js' ;
35
34
import { _TextAndGraphicUpdateOperation } from './_TextAndGraphicUpdateOperation.js' ;
36
35
import { _TextAndGraphicState } from './_TextAndGraphicState.js' ;
37
36
@@ -67,7 +66,6 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
67
66
this . _textField4Type = null ;
68
67
this . _isDirty = false ;
69
68
this . _updateOperation = null ;
70
- this . _currentOperationListener = null ;
71
69
this . _templateConfiguration = null ;
72
70
73
71
this . _handleDisplayCapabilityUpdates ( ) ;
@@ -108,7 +106,6 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
108
106
this . _textField4Type = null ;
109
107
this . _isDirty = false ;
110
108
this . _updateOperation = null ;
111
- this . _currentOperationListener = null ;
112
109
113
110
this . _handleDisplayCapabilityUpdates ( ) ;
114
111
this . _handleTaskQueue ( ) ;
@@ -125,7 +122,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
125
122
resolve ( false ) ;
126
123
}
127
124
if ( this . _isDirty ) {
128
- this . _sdlUpdate ( true , resolve ) ;
125
+ this . _sdlUpdate ( resolve ) ;
129
126
} else {
130
127
resolve ( true ) ;
131
128
}
@@ -135,36 +132,23 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
135
132
/**
136
133
* Determines what needs to be done to send a valid Show method
137
134
* @private
138
- * @param {Boolean } supersedePreviousOperations - Whether this update should have priority over previous updates
139
135
* @param {function } listener - A function to invoke when the update task is complete once it runs
140
136
*/
141
- _sdlUpdate ( supersedePreviousOperations , listener ) {
142
- if ( this . _updateOperation !== null && this . _updateOperation . getState ( ) === _Task . READY && supersedePreviousOperations ) {
143
- this . _updateOperation . switchStates ( _Task . CANCELED ) ;
144
- if ( typeof this . _currentOperationListener === 'function' ) {
145
- this . _currentOperationListener ( false ) ;
146
- }
147
- }
148
-
149
- if ( this . _updateOperation !== null && this . _updateOperation . getState ( ) === _Task . IN_PROGRESS && supersedePreviousOperations ) {
150
- this . _updateOperation . switchStates ( _Task . CANCELED ) ;
151
- }
152
-
153
- this . _currentOperationListener = listener ;
154
-
137
+ _sdlUpdate ( listener ) {
155
138
const currentScreenDataUpdateListener = ( asyncListener ) => {
156
139
asyncListener ( ) . then ( ( newScreenData ) => {
157
140
if ( newScreenData !== null ) {
158
141
this . _currentScreenData = newScreenData ;
159
142
this . _updatePendingOperationsWithNewScreenData ( ) ;
160
143
}
161
- } ) . catch ( ( err ) => {
144
+ } ) . catch ( ( errorState ) => {
162
145
this . _resetFieldsToCurrentScreenData ( ) ;
146
+ this . _updatePendingOperationsWithFailedScreenState ( errorState ) ;
163
147
} ) ;
164
148
} ;
165
149
166
150
this . _updateOperation = new _TextAndGraphicUpdateOperation ( this . _lifecycleManager , this . _fileManager , this . _defaultMainWindowCapability ,
167
- this . _currentScreenData , this . _currentState ( ) , this . _currentOperationListener , currentScreenDataUpdateListener . bind ( this ) ) ;
151
+ this . _currentScreenData , this . _currentState ( ) , listener , currentScreenDataUpdateListener . bind ( this ) ) ;
168
152
this . _addTask ( this . _updateOperation ) ;
169
153
}
170
154
@@ -189,11 +173,25 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
189
173
this . _templateConfiguration = this . _currentScreenData . getTemplateConfiguration ( ) ;
190
174
}
191
175
176
+ /**
177
+ * Updates all pending tasks in the queue with the failed screen state
178
+ * @param {_TextAndGraphicState } errorState - The _TextAndGraphicState when the error occured
179
+ * @private
180
+ */
181
+ _updatePendingOperationsWithFailedScreenState ( errorState ) {
182
+ for ( const task of this . _getTasks ( ) ) {
183
+ if ( ! ( task instanceof _TextAndGraphicUpdateOperation ) ) {
184
+ continue ;
185
+ }
186
+ task . _updateTargetStateWithErrorState ( errorState ) ;
187
+ }
188
+ }
189
+
192
190
/**
193
191
* Updates all pending tasks in the queue with the current screen data
194
192
*/
195
193
_updatePendingOperationsWithNewScreenData ( ) {
196
- for ( const task in this . _getTasks ( ) ) {
194
+ for ( const task of this . _getTasks ( ) ) {
197
195
if ( ! ( task instanceof _TextAndGraphicUpdateOperation ) ) {
198
196
continue ;
199
197
}
@@ -235,7 +233,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
235
233
setTextAlignment ( textAlignment ) {
236
234
this . _textAlignment = textAlignment ;
237
235
if ( ! this . _batchingUpdates ) {
238
- this . _sdlUpdate ( true , null ) ;
236
+ this . _sdlUpdate ( null ) ;
239
237
} else {
240
238
this . _isDirty = true ;
241
239
}
@@ -258,7 +256,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
258
256
setMediaTrackTextField ( mediaTrackTextField ) {
259
257
this . _mediaTrackTextField = mediaTrackTextField ;
260
258
if ( ! this . _batchingUpdates ) {
261
- this . _sdlUpdate ( true , null ) ;
259
+ this . _sdlUpdate ( null ) ;
262
260
} else {
263
261
this . _isDirty = true ;
264
262
}
@@ -281,7 +279,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
281
279
setTextField1 ( textField1 ) {
282
280
this . _textField1 = textField1 ;
283
281
if ( ! this . _batchingUpdates ) {
284
- this . _sdlUpdate ( true , null ) ;
282
+ this . _sdlUpdate ( null ) ;
285
283
} else {
286
284
this . _isDirty = true ;
287
285
}
@@ -304,7 +302,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
304
302
setTextField2 ( textField2 ) {
305
303
this . _textField2 = textField2 ;
306
304
if ( ! this . _batchingUpdates ) {
307
- this . _sdlUpdate ( true , null ) ;
305
+ this . _sdlUpdate ( null ) ;
308
306
} else {
309
307
this . _isDirty = true ;
310
308
}
@@ -327,7 +325,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
327
325
setTextField3 ( textField3 ) {
328
326
this . _textField3 = textField3 ;
329
327
if ( ! this . _batchingUpdates ) {
330
- this . _sdlUpdate ( true , null ) ;
328
+ this . _sdlUpdate ( null ) ;
331
329
} else {
332
330
this . _isDirty = true ;
333
331
}
@@ -350,7 +348,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
350
348
setTextField4 ( textField4 ) {
351
349
this . _textField4 = textField4 ;
352
350
if ( ! this . _batchingUpdates ) {
353
- this . _sdlUpdate ( true , null ) ;
351
+ this . _sdlUpdate ( null ) ;
354
352
} else {
355
353
this . _isDirty = true ;
356
354
}
@@ -373,7 +371,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
373
371
setTextField1Type ( textField1Type ) {
374
372
this . _textField1Type = textField1Type ;
375
373
if ( ! this . _batchingUpdates ) {
376
- this . _sdlUpdate ( true , null ) ;
374
+ this . _sdlUpdate ( null ) ;
377
375
} else {
378
376
this . _isDirty = true ;
379
377
}
@@ -396,7 +394,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
396
394
setTextField2Type ( textField2Type ) {
397
395
this . _textField2Type = textField2Type ;
398
396
if ( ! this . _batchingUpdates ) {
399
- this . _sdlUpdate ( true , null ) ;
397
+ this . _sdlUpdate ( null ) ;
400
398
} else {
401
399
this . _isDirty = true ;
402
400
}
@@ -419,7 +417,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
419
417
setTextField3Type ( textField3Type ) {
420
418
this . _textField3Type = textField3Type ;
421
419
if ( ! this . _batchingUpdates ) {
422
- this . _sdlUpdate ( true , null ) ;
420
+ this . _sdlUpdate ( null ) ;
423
421
} else {
424
422
this . _isDirty = true ;
425
423
}
@@ -442,7 +440,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
442
440
setTextField4Type ( textField4Type ) {
443
441
this . _textField4Type = textField4Type ;
444
442
if ( ! this . _batchingUpdates ) {
445
- this . _sdlUpdate ( true , null ) ;
443
+ this . _sdlUpdate ( null ) ;
446
444
} else {
447
445
this . _isDirty = true ;
448
446
}
@@ -465,7 +463,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
465
463
setTitle ( title ) {
466
464
this . _title = title ;
467
465
if ( ! this . _batchingUpdates ) {
468
- this . _sdlUpdate ( true , null ) ;
466
+ this . _sdlUpdate ( null ) ;
469
467
} else {
470
468
this . _isDirty = true ;
471
469
}
@@ -488,7 +486,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
488
486
setPrimaryGraphic ( primaryGraphic ) {
489
487
this . _primaryGraphic = primaryGraphic ;
490
488
if ( ! this . _batchingUpdates ) {
491
- this . _sdlUpdate ( true , null ) ;
489
+ this . _sdlUpdate ( null ) ;
492
490
} else {
493
491
this . _isDirty = true ;
494
492
}
@@ -511,7 +509,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
511
509
setSecondaryGraphic ( secondaryGraphic ) {
512
510
this . _secondaryGraphic = secondaryGraphic ;
513
511
if ( ! this . _batchingUpdates ) {
514
- this . _sdlUpdate ( true , null ) ;
512
+ this . _sdlUpdate ( null ) ;
515
513
} else {
516
514
this . _isDirty = true ;
517
515
}
@@ -534,7 +532,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
534
532
changeLayout ( templateConfiguration , listener ) {
535
533
this . setTemplateConfiguration ( templateConfiguration ) ;
536
534
if ( ! this . _batchingUpdates ) {
537
- this . _sdlUpdate ( true , listener ) ;
535
+ this . _sdlUpdate ( listener ) ;
538
536
} else {
539
537
this . _isDirty = true ;
540
538
}
0 commit comments