3131*/
3232
3333import { _SubManagerBase } from '../_SubManagerBase.js' ;
34- import { _Task } from '../_Task.js' ;
3534import { _TextAndGraphicUpdateOperation } from './_TextAndGraphicUpdateOperation.js' ;
3635import { _TextAndGraphicState } from './_TextAndGraphicState.js' ;
3736
@@ -67,7 +66,6 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
6766 this . _textField4Type = null ;
6867 this . _isDirty = false ;
6968 this . _updateOperation = null ;
70- this . _currentOperationListener = null ;
7169 this . _templateConfiguration = null ;
7270
7371 this . _handleDisplayCapabilityUpdates ( ) ;
@@ -108,7 +106,6 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
108106 this . _textField4Type = null ;
109107 this . _isDirty = false ;
110108 this . _updateOperation = null ;
111- this . _currentOperationListener = null ;
112109
113110 this . _handleDisplayCapabilityUpdates ( ) ;
114111 this . _handleTaskQueue ( ) ;
@@ -125,7 +122,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
125122 resolve ( false ) ;
126123 }
127124 if ( this . _isDirty ) {
128- this . _sdlUpdate ( true , resolve ) ;
125+ this . _sdlUpdate ( resolve ) ;
129126 } else {
130127 resolve ( true ) ;
131128 }
@@ -135,36 +132,23 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
135132 /**
136133 * Determines what needs to be done to send a valid Show method
137134 * @private
138- * @param {Boolean } supersedePreviousOperations - Whether this update should have priority over previous updates
139135 * @param {function } listener - A function to invoke when the update task is complete once it runs
140136 */
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 ) {
155138 const currentScreenDataUpdateListener = ( asyncListener ) => {
156139 asyncListener ( ) . then ( ( newScreenData ) => {
157140 if ( newScreenData !== null ) {
158141 this . _currentScreenData = newScreenData ;
159142 this . _updatePendingOperationsWithNewScreenData ( ) ;
160143 }
161- } ) . catch ( ( err ) => {
144+ } ) . catch ( ( errorState ) => {
162145 this . _resetFieldsToCurrentScreenData ( ) ;
146+ this . _updatePendingOperationsWithFailedScreenState ( errorState ) ;
163147 } ) ;
164148 } ;
165149
166150 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 ) ) ;
168152 this . _addTask ( this . _updateOperation ) ;
169153 }
170154
@@ -189,11 +173,25 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
189173 this . _templateConfiguration = this . _currentScreenData . getTemplateConfiguration ( ) ;
190174 }
191175
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+
192190 /**
193191 * Updates all pending tasks in the queue with the current screen data
194192 */
195193 _updatePendingOperationsWithNewScreenData ( ) {
196- for ( const task in this . _getTasks ( ) ) {
194+ for ( const task of this . _getTasks ( ) ) {
197195 if ( ! ( task instanceof _TextAndGraphicUpdateOperation ) ) {
198196 continue ;
199197 }
@@ -235,7 +233,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
235233 setTextAlignment ( textAlignment ) {
236234 this . _textAlignment = textAlignment ;
237235 if ( ! this . _batchingUpdates ) {
238- this . _sdlUpdate ( true , null ) ;
236+ this . _sdlUpdate ( null ) ;
239237 } else {
240238 this . _isDirty = true ;
241239 }
@@ -258,7 +256,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
258256 setMediaTrackTextField ( mediaTrackTextField ) {
259257 this . _mediaTrackTextField = mediaTrackTextField ;
260258 if ( ! this . _batchingUpdates ) {
261- this . _sdlUpdate ( true , null ) ;
259+ this . _sdlUpdate ( null ) ;
262260 } else {
263261 this . _isDirty = true ;
264262 }
@@ -281,7 +279,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
281279 setTextField1 ( textField1 ) {
282280 this . _textField1 = textField1 ;
283281 if ( ! this . _batchingUpdates ) {
284- this . _sdlUpdate ( true , null ) ;
282+ this . _sdlUpdate ( null ) ;
285283 } else {
286284 this . _isDirty = true ;
287285 }
@@ -304,7 +302,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
304302 setTextField2 ( textField2 ) {
305303 this . _textField2 = textField2 ;
306304 if ( ! this . _batchingUpdates ) {
307- this . _sdlUpdate ( true , null ) ;
305+ this . _sdlUpdate ( null ) ;
308306 } else {
309307 this . _isDirty = true ;
310308 }
@@ -327,7 +325,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
327325 setTextField3 ( textField3 ) {
328326 this . _textField3 = textField3 ;
329327 if ( ! this . _batchingUpdates ) {
330- this . _sdlUpdate ( true , null ) ;
328+ this . _sdlUpdate ( null ) ;
331329 } else {
332330 this . _isDirty = true ;
333331 }
@@ -350,7 +348,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
350348 setTextField4 ( textField4 ) {
351349 this . _textField4 = textField4 ;
352350 if ( ! this . _batchingUpdates ) {
353- this . _sdlUpdate ( true , null ) ;
351+ this . _sdlUpdate ( null ) ;
354352 } else {
355353 this . _isDirty = true ;
356354 }
@@ -373,7 +371,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
373371 setTextField1Type ( textField1Type ) {
374372 this . _textField1Type = textField1Type ;
375373 if ( ! this . _batchingUpdates ) {
376- this . _sdlUpdate ( true , null ) ;
374+ this . _sdlUpdate ( null ) ;
377375 } else {
378376 this . _isDirty = true ;
379377 }
@@ -396,7 +394,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
396394 setTextField2Type ( textField2Type ) {
397395 this . _textField2Type = textField2Type ;
398396 if ( ! this . _batchingUpdates ) {
399- this . _sdlUpdate ( true , null ) ;
397+ this . _sdlUpdate ( null ) ;
400398 } else {
401399 this . _isDirty = true ;
402400 }
@@ -419,7 +417,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
419417 setTextField3Type ( textField3Type ) {
420418 this . _textField3Type = textField3Type ;
421419 if ( ! this . _batchingUpdates ) {
422- this . _sdlUpdate ( true , null ) ;
420+ this . _sdlUpdate ( null ) ;
423421 } else {
424422 this . _isDirty = true ;
425423 }
@@ -442,7 +440,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
442440 setTextField4Type ( textField4Type ) {
443441 this . _textField4Type = textField4Type ;
444442 if ( ! this . _batchingUpdates ) {
445- this . _sdlUpdate ( true , null ) ;
443+ this . _sdlUpdate ( null ) ;
446444 } else {
447445 this . _isDirty = true ;
448446 }
@@ -465,7 +463,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
465463 setTitle ( title ) {
466464 this . _title = title ;
467465 if ( ! this . _batchingUpdates ) {
468- this . _sdlUpdate ( true , null ) ;
466+ this . _sdlUpdate ( null ) ;
469467 } else {
470468 this . _isDirty = true ;
471469 }
@@ -488,7 +486,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
488486 setPrimaryGraphic ( primaryGraphic ) {
489487 this . _primaryGraphic = primaryGraphic ;
490488 if ( ! this . _batchingUpdates ) {
491- this . _sdlUpdate ( true , null ) ;
489+ this . _sdlUpdate ( null ) ;
492490 } else {
493491 this . _isDirty = true ;
494492 }
@@ -511,7 +509,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
511509 setSecondaryGraphic ( secondaryGraphic ) {
512510 this . _secondaryGraphic = secondaryGraphic ;
513511 if ( ! this . _batchingUpdates ) {
514- this . _sdlUpdate ( true , null ) ;
512+ this . _sdlUpdate ( null ) ;
515513 } else {
516514 this . _isDirty = true ;
517515 }
@@ -534,7 +532,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
534532 changeLayout ( templateConfiguration , listener ) {
535533 this . setTemplateConfiguration ( templateConfiguration ) ;
536534 if ( ! this . _batchingUpdates ) {
537- this . _sdlUpdate ( true , listener ) ;
535+ this . _sdlUpdate ( listener ) ;
538536 } else {
539537 this . _isDirty = true ;
540538 }
0 commit comments