Skip to content

Commit 8871552

Browse files
committed
Update PR based on feedback
1 parent 82ad71e commit 8871552

2 files changed

Lines changed: 34 additions & 33 deletions

File tree

lib/js/src/manager/screen/_TextAndGraphicManagerBase.js

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
6666
this._textField4Type = null;
6767
this._isDirty = false;
6868
this._updateOperation = null;
69-
this._currentOperationListener = null;
7069
this._templateConfiguration = null;
7170

7271
this._handleDisplayCapabilityUpdates();
@@ -107,7 +106,6 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
107106
this._textField4Type = null;
108107
this._isDirty = false;
109108
this._updateOperation = null;
110-
this._currentOperationListener = null;
111109

112110
this._handleDisplayCapabilityUpdates();
113111
this._handleTaskQueue();
@@ -124,7 +122,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
124122
resolve(false);
125123
}
126124
if (this._isDirty) {
127-
this._sdlUpdate(true, resolve);
125+
this._sdlUpdate(resolve);
128126
} else {
129127
resolve(true);
130128
}
@@ -134,25 +132,23 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
134132
/**
135133
* Determines what needs to be done to send a valid Show method
136134
* @private
137-
* @param {Boolean} supersedePreviousOperations - Whether this update should have priority over previous updates
138135
* @param {function} listener - A function to invoke when the update task is complete once it runs
139136
*/
140-
_sdlUpdate (supersedePreviousOperations, listener) {
141-
this._currentOperationListener = listener;
142-
137+
_sdlUpdate (listener) {
143138
const currentScreenDataUpdateListener = (asyncListener) => {
144139
asyncListener().then((newScreenData) => {
145140
if (newScreenData !== null) {
146141
this._currentScreenData = newScreenData;
147142
this._updatePendingOperationsWithNewScreenData();
148143
}
149144
}).catch((errorState) => {
145+
this._resetFieldsToCurrentScreenData();
150146
this._updatePendingOperationsWithFailedScreenState(errorState);
151147
});
152148
};
153149

154150
this._updateOperation = new _TextAndGraphicUpdateOperation(this._lifecycleManager, this._fileManager, this._defaultMainWindowCapability,
155-
this._currentScreenData, this._currentState(), this._currentOperationListener, currentScreenDataUpdateListener.bind(this));
151+
this._currentScreenData, this._currentState(), listener, currentScreenDataUpdateListener.bind(this));
156152
this._addTask(this._updateOperation);
157153
}
158154

@@ -187,9 +183,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
187183
if (!(task instanceof _TextAndGraphicUpdateOperation)) {
188184
continue;
189185
}
190-
if (errorState instanceof _TextAndGraphicState) { // check if a _TextAndGraphicState was passed in instead of an error object
191-
task._updateTargetStateWithErrorState(errorState);
192-
}
186+
task._updateTargetStateWithErrorState(errorState);
193187
}
194188
}
195189

@@ -239,7 +233,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
239233
setTextAlignment (textAlignment) {
240234
this._textAlignment = textAlignment;
241235
if (!this._batchingUpdates) {
242-
this._sdlUpdate(true, null);
236+
this._sdlUpdate(null);
243237
} else {
244238
this._isDirty = true;
245239
}
@@ -262,7 +256,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
262256
setMediaTrackTextField (mediaTrackTextField) {
263257
this._mediaTrackTextField = mediaTrackTextField;
264258
if (!this._batchingUpdates) {
265-
this._sdlUpdate(true, null);
259+
this._sdlUpdate(null);
266260
} else {
267261
this._isDirty = true;
268262
}
@@ -285,7 +279,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
285279
setTextField1 (textField1) {
286280
this._textField1 = textField1;
287281
if (!this._batchingUpdates) {
288-
this._sdlUpdate(true, null);
282+
this._sdlUpdate(null);
289283
} else {
290284
this._isDirty = true;
291285
}
@@ -308,7 +302,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
308302
setTextField2 (textField2) {
309303
this._textField2 = textField2;
310304
if (!this._batchingUpdates) {
311-
this._sdlUpdate(true, null);
305+
this._sdlUpdate(null);
312306
} else {
313307
this._isDirty = true;
314308
}
@@ -331,7 +325,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
331325
setTextField3 (textField3) {
332326
this._textField3 = textField3;
333327
if (!this._batchingUpdates) {
334-
this._sdlUpdate(true, null);
328+
this._sdlUpdate(null);
335329
} else {
336330
this._isDirty = true;
337331
}
@@ -354,7 +348,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
354348
setTextField4 (textField4) {
355349
this._textField4 = textField4;
356350
if (!this._batchingUpdates) {
357-
this._sdlUpdate(true, null);
351+
this._sdlUpdate(null);
358352
} else {
359353
this._isDirty = true;
360354
}
@@ -377,7 +371,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
377371
setTextField1Type (textField1Type) {
378372
this._textField1Type = textField1Type;
379373
if (!this._batchingUpdates) {
380-
this._sdlUpdate(true, null);
374+
this._sdlUpdate(null);
381375
} else {
382376
this._isDirty = true;
383377
}
@@ -400,7 +394,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
400394
setTextField2Type (textField2Type) {
401395
this._textField2Type = textField2Type;
402396
if (!this._batchingUpdates) {
403-
this._sdlUpdate(true, null);
397+
this._sdlUpdate(null);
404398
} else {
405399
this._isDirty = true;
406400
}
@@ -423,7 +417,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
423417
setTextField3Type (textField3Type) {
424418
this._textField3Type = textField3Type;
425419
if (!this._batchingUpdates) {
426-
this._sdlUpdate(true, null);
420+
this._sdlUpdate(null);
427421
} else {
428422
this._isDirty = true;
429423
}
@@ -446,7 +440,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
446440
setTextField4Type (textField4Type) {
447441
this._textField4Type = textField4Type;
448442
if (!this._batchingUpdates) {
449-
this._sdlUpdate(true, null);
443+
this._sdlUpdate(null);
450444
} else {
451445
this._isDirty = true;
452446
}
@@ -469,7 +463,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
469463
setTitle (title) {
470464
this._title = title;
471465
if (!this._batchingUpdates) {
472-
this._sdlUpdate(true, null);
466+
this._sdlUpdate(null);
473467
} else {
474468
this._isDirty = true;
475469
}
@@ -492,7 +486,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
492486
setPrimaryGraphic (primaryGraphic) {
493487
this._primaryGraphic = primaryGraphic;
494488
if (!this._batchingUpdates) {
495-
this._sdlUpdate(true, null);
489+
this._sdlUpdate(null);
496490
} else {
497491
this._isDirty = true;
498492
}
@@ -515,7 +509,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
515509
setSecondaryGraphic (secondaryGraphic) {
516510
this._secondaryGraphic = secondaryGraphic;
517511
if (!this._batchingUpdates) {
518-
this._sdlUpdate(true, null);
512+
this._sdlUpdate(null);
519513
} else {
520514
this._isDirty = true;
521515
}
@@ -538,7 +532,7 @@ class _TextAndGraphicManagerBase extends _SubManagerBase {
538532
changeLayout (templateConfiguration, listener) {
539533
this.setTemplateConfiguration(templateConfiguration);
540534
if (!this._batchingUpdates) {
541-
this._sdlUpdate(true, listener);
535+
this._sdlUpdate(listener);
542536
} else {
543537
this._isDirty = true;
544538
}

lib/js/src/manager/screen/_TextAndGraphicUpdateOperation.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class _TextAndGraphicUpdateOperation extends _Task {
153153
} else {
154154
console.info('LifecycleManager is null, Text and Graphic update failed');
155155
this._currentScreenDataUpdateListener(async () => {
156-
throw new Error('LifecycleManager is null, Text and Graphic update failed');
156+
throw this._updatedState; // send the errored state back to the manager
157157
});
158158
this._finishOperation(false);
159159
return;
@@ -176,14 +176,14 @@ class _TextAndGraphicUpdateOperation extends _Task {
176176
} else {
177177
console.info('Text and Graphic SetDisplayLayout failed');
178178
this._currentScreenDataUpdateListener(async () => {
179-
throw new Error('Text and Graphic SetDisplayLayout failed');
179+
throw this._updatedState; // send the errored state back to the manager
180180
});
181181
}
182182
return response.getSuccess();
183183
} else {
184184
console.info('LifecycleManager is null, Text and Graphic update failed');
185185
this._currentScreenDataUpdateListener(async () => {
186-
throw new Error('LifecycleManager is null, Text and Graphic update failed');
186+
throw this._updatedState; // send the errored state back to the manager
187187
});
188188
this._finishOperation(false);
189189
return;
@@ -885,14 +885,21 @@ class _TextAndGraphicUpdateOperation extends _Task {
885885
if (errorState.getTitle() === this._updatedState.getTitle()) {
886886
this._updatedState.setTitle(this._currentScreenData.getTitle());
887887
}
888-
if ((errorState.getPrimaryGraphic() === null && this._updatedState.getPrimaryGraphic() === null)
889-
|| (errorState.getPrimaryGraphic() !== null && errorState.getPrimaryGraphic().equals(this._updatedState.getPrimaryGraphic()))) { // for safe null check
888+
889+
const errorPrimary = errorState.getPrimaryGraphic();
890+
const updatedPrimary = this._updatedState.getPrimaryGraphic();
891+
if ((errorPrimary === null && updatedPrimary === null)
892+
|| (errorPrimary !== null && errorPrimary.equals(updatedPrimary) && errorPrimary.isTemplateImage() === updatedPrimary.isTemplateImage())) { // for safe null check
890893
this._updatedState.setPrimaryGraphic(this._currentScreenData.getPrimaryGraphic());
891894
}
892-
if ((errorState.getSecondaryGraphic() === null && this._updatedState.getSecondaryGraphic() === null)
893-
|| (errorState.getSecondaryGraphic() !== null && errorState.getSecondaryGraphic().equals(this._updatedState.getSecondaryGraphic()))) { // for safe null check
894-
this._updatedState.setSecondaryGraphic(this._currentScreenData.getSecondaryGraphic());
895+
896+
const errorSecondary = errorState.getSecondaryGraphic();
897+
const updatedSecondary = this._updatedState.getSecondaryGraphic();
898+
if ((errorSecondary === null && updatedSecondary === null)
899+
|| (errorSecondary !== null && errorSecondary.equals(updatedSecondary) && errorSecondary.isTemplateImage() === updatedSecondary.isTemplateImage())) { // for safe null check
900+
this._updatedState.setPrimaryGraphic(this._currentScreenData.getPrimaryGraphic());
895901
}
902+
896903
if (errorState.getTextAlignment() === this._updatedState.getTextAlignment()) {
897904
this._updatedState.setTextAlignment(this._currentScreenData.getTextAlignment());
898905
}

0 commit comments

Comments
 (0)