Skip to content

Commit

Permalink
fix: coherent off for popup
Browse files Browse the repository at this point in the history
  • Loading branch information
2hwk committed May 10, 2022
1 parent f67e264 commit f79df8d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/shared/src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export type NotiticationParams = {
* import { PopUp } from '@shared/popup';
* ...
* const popup = new PopUp();
* popup.showPopUp({ title: "CRITICAL SETTING CHANGED", message: "Your message here", style: "small"}, yesFunc, noFunc);
* popup.showPopUp("CRITICAL SETTING CHANGED", "Your message here", "small", yesFunc, noFunc);
* popup.showInformation("CRITICAL MESSAGE", "Your message here", "small", yesFunc);
*/
export class PopUp {
params: NotiticationParams;
Expand Down Expand Up @@ -80,11 +81,17 @@ export class PopUp {
}
if (callbackYes) {
const yes = (typeof callbackYes === 'function') ? callbackYes : () => callbackYes;
Coherent.on(`A32NX_POP_${this.params.id}_YES`, yes);
Coherent.on(`A32NX_POP_${this.params.id}_YES`, () => {
Coherent.off(`A32NX_POP_${this.params.id}_YES`, null);
yes();
});
}
if (callbackNo) {
const no = (typeof callbackNo === 'function') ? callbackNo : () => callbackNo;
Coherent.on(`A32NX_POP_${this.params.id}_NO`, no);
Coherent.on(`A32NX_POP_${this.params.id}_NO`, () => {
Coherent.off(`A32NX_POP_${this.params.id}_NO`, null);
no();
});
}

if (!this.popupListener) {
Expand Down Expand Up @@ -113,7 +120,10 @@ export class PopUp {
}
if (callback) {
const yes = (typeof callback === 'function') ? callback : () => callback;
Coherent.on(`A32NX_POP_${this.params.id}_YES`, yes);
Coherent.on(`A32NX_POP_${this.params.id}_YES`, () => {
Coherent.off(`A32NX_POP_${this.params.id}_YES`, null);
yes();
});
}
this.params.buttons = [new NotificationButton('TT:MENU.OK', `A32NX_POP_${this.params.id}_YES`)];

Expand Down

0 comments on commit f79df8d

Please sign in to comment.