@@ -4,7 +4,7 @@ import LimitStore from 'src/shared/services/LimitStore';
44import OneSignalEvent from 'src/shared/services/OneSignalEvent' ;
55import AnimatedElement from './AnimatedElement' ;
66import Bell from './Bell' ;
7- import { MESSAGE_TIMEOUT , MessageType } from './constants' ;
7+ import { Events , MESSAGE_TIMEOUT , MessageType } from './constants' ;
88
99export default class Button extends AnimatedElement {
1010 public _events : Record < string , string > ;
@@ -69,14 +69,14 @@ export default class Button extends AnimatedElement {
6969 LimitStore . isEmpty ( this . _events . mouse ) ||
7070 LimitStore . getLast ( this . _events . mouse ) === 'out'
7171 ) {
72- OneSignalEvent . trigger ( 'notifyButtonHovering' ) ;
72+ OneSignalEvent . trigger ( Events . Hovering ) ;
7373 }
7474 LimitStore . put ( this . _events . mouse , 'over' ) ;
7575 }
7676
7777 _onHovered ( ) {
7878 LimitStore . put ( this . _events . mouse , 'out' ) ;
79- OneSignalEvent . trigger ( 'notifyButtonHover' ) ;
79+ OneSignalEvent . trigger ( Events . Hovered ) ;
8080 }
8181
8282 _onTap ( ) {
@@ -98,8 +98,8 @@ export default class Button extends AnimatedElement {
9898 this . _isHandlingClick = true ;
9999
100100 try {
101- OneSignalEvent . trigger ( 'notifyButtonButtonClick' ) ;
102- OneSignalEvent . trigger ( 'notifyButtonLauncherClick' ) ;
101+ OneSignalEvent . trigger ( Events . BellClick ) ;
102+ OneSignalEvent . trigger ( Events . LauncherClick ) ;
103103
104104 if (
105105 this . _bell . _message . _shown &&
@@ -115,20 +115,23 @@ export default class Button extends AnimatedElement {
115115 if ( this . _bell . _unsubscribed && ! optedOut ) {
116116 registerForPushNotifications ( ) ;
117117 this . _bell . _ignoreSubscriptionState = true ;
118- OneSignal . emitter . once ( 'change' , async ( ) => {
119- try {
120- await this . _bell . _message . _display (
121- MessageType . _Message ,
122- this . _bell . _options . text [ 'message.action.subscribed' ] ,
123- MESSAGE_TIMEOUT ,
124- ) ;
125- this . _bell . _ignoreSubscriptionState = false ;
126- await this . _bell . _launcher . _inactivate ( ) ;
127- } catch ( error ) {
128- this . _bell . _ignoreSubscriptionState = false ;
129- throw error ;
130- }
131- } ) ;
118+ OneSignal . emitter . once (
119+ OneSignal . EVENTS . SUBSCRIPTION_CHANGED ,
120+ async ( ) => {
121+ try {
122+ await this . _bell . _message . _display (
123+ MessageType . _Message ,
124+ this . _bell . _options . text [ 'message.action.subscribed' ] ,
125+ MESSAGE_TIMEOUT ,
126+ ) ;
127+ this . _bell . _ignoreSubscriptionState = false ;
128+ await this . _bell . _launcher . _inactivate ( ) ;
129+ } catch ( error ) {
130+ this . _bell . _ignoreSubscriptionState = false ;
131+ throw error ;
132+ }
133+ } ,
134+ ) ;
132135 return ;
133136 }
134137
0 commit comments