Skip to content

Commit 27ca179

Browse files
authored
Merge pull request #510 from smartdevicelink/bugfix/alert-view-cancel-listener
Fix AlertManager logic for canceling an in-progress alert
2 parents 9173b0a + ec0e4df commit 27ca179

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

lib/js/src/manager/screen/utils/_PresentAlertOperation.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ class _PresentAlertOperation extends _Task {
6464
this._isAlertPresented = false;
6565
this._alertSoftButtonClearListener = alertSoftButtonClearListener;
6666

67-
this._alertView.canceledListener = function () {
67+
this._alertView.canceledListener = () => {
6868
this.cancelAlert();
6969
};
70+
alertView.canceledListener = this._alertView.canceledListener;
7071
}
7172

7273
/**
@@ -257,7 +258,7 @@ class _PresentAlertOperation extends _Task {
257258
*/
258259
async cancelAlert () {
259260
if (this.getState() === _Task.FINISHED) {
260-
console.logInfo('This operation has already finished so it can not be canceled');
261+
console.log('This operation has already finished so it can not be canceled');
261262
return;
262263
} else if (this.getState() === _Task.CANCELED) {
263264
console.log('This operation has already been canceled. It will be finished at some point during the operation.');
@@ -266,12 +267,17 @@ class _PresentAlertOperation extends _Task {
266267
if (this._lifecycleManager !== null && this._lifecycleManager.getSdlMsgVersion() !== null && this._lifecycleManager.getSdlMsgVersion().getMajorVersion() < 6) {
267268
console.log('Attempting to cancel this operation in-progress; if the alert is already presented on the module, it cannot be dismissed.');
268269
this.switchStates(_Task.CANCELED);
270+
return;
269271
} else if (!this._isAlertPresented) {
270272
console.log('Alert has not yet been sent to the module. Alert will not be shown.');
273+
this.switchStates(_Task.CANCELED);
274+
return;
271275
}
272276
console.log('Canceling the presented alert');
273277

274-
const cancelInteraction = new CancelInteraction(FunctionID.Alert, this._cancelId);
278+
const cancelInteraction = new CancelInteraction()
279+
.setFunctionIDParam(FunctionID.Alert)
280+
.setCancelID(this._cancelId);
275281
const response = await this._lifecycleManager.sendRpcResolve(cancelInteraction);
276282
if (!response.getSuccess()) {
277283
console.log(`Error canceling the presented alert: ${response.getInfo()}`);

0 commit comments

Comments
 (0)