Skip to content

Commit 172098b

Browse files
committed
fix merge conflicts
1 parent 835aa5e commit 172098b

File tree

5 files changed

+44
-38
lines changed

5 files changed

+44
-38
lines changed

src/page/bell/AnimatedElement.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,40 +26,40 @@ export default class AnimatedElement {
2626
* Show element using CSS classes and wait for animations to complete
2727
*/
2828
async _show(): Promise<void> {
29-
const element = this.element;
30-
if (!element || this.shown) {
29+
const element = this._element;
30+
if (!element || this._shown) {
3131
return;
3232
}
3333

3434
if (this._showClass) {
3535
element.classList.add(this._showClass);
3636
}
3737

38-
await this.waitForAnimations();
38+
await this._waitForAnimations();
3939
}
4040

4141
/**
4242
* Hide element using CSS classes and wait for animations to complete
4343
*/
44-
async hide(): Promise<void> {
45-
const element = this.element;
46-
if (!element || !this.shown) {
44+
async _hide(): Promise<void> {
45+
const element = this._element;
46+
if (!element || !this._shown) {
4747
return;
4848
}
4949

5050
if (this._showClass) {
5151
element.classList.remove(this._showClass);
5252
}
5353

54-
await this.waitForAnimations();
54+
await this._waitForAnimations();
5555
}
5656

5757
/**
5858
* Activate element using CSS classes
5959
*/
6060
async _activate(): Promise<void> {
61-
const element = this.element;
62-
if (!element || this.active) {
61+
const element = this._element;
62+
if (!element || this._active) {
6363
return;
6464
}
6565

@@ -70,15 +70,15 @@ export default class AnimatedElement {
7070
element.classList.add(this._activeClass);
7171
}
7272

73-
await this.waitForAnimations();
73+
await this._waitForAnimations();
7474
}
7575

7676
/**
7777
* Inactivate element using CSS classes
7878
*/
7979
async _inactivate(): Promise<void> {
80-
const element = this.element;
81-
if (!element || !this.active) {
80+
const element = this._element;
81+
if (!element || !this._active) {
8282
return;
8383
}
8484

@@ -89,7 +89,7 @@ export default class AnimatedElement {
8989
element.classList.add(this._inactiveClass);
9090
}
9191

92-
await this.waitForAnimations();
92+
await this._waitForAnimations();
9393
}
9494

9595
/**

src/page/bell/Badge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class Badge extends AnimatedElement {
2525
this._updateCount(-1);
2626
}
2727

28-
_show(): Promise<AnimatedElement> {
28+
_show(): Promise<void> {
2929
const promise = super._show();
3030
OneSignal._notifyButton?._setCustomColorsIfSpecified();
3131
return promise;

src/page/bell/Bell.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const DEFAULT_THEME = 'default';
4141

4242
export default class Bell {
4343
public _options: AppUserConfigNotifyButton;
44-
public _state: BellStateType = BellState._Uninitialized;
44+
public _state: BellStateValue = BellState._Uninitialized;
4545
public _ignoreSubscriptionState = false;
4646
public _hovering = false;
4747
public _initialized = false;
@@ -188,7 +188,7 @@ export default class Bell {
188188
})
189189
.then(() => {
190190
return this._message._display(
191-
MesageType._Message,
191+
MessageType._Message,
192192
this._options.text['message.action.resubscribed'],
193193
MESSAGE_TIMEOUT,
194194
);
@@ -224,7 +224,7 @@ export default class Bell {
224224
})
225225
.then(() => {
226226
return this._message._display(
227-
MesageType._Message,
227+
MessageType._Message,
228228
this._options.text['message.action.unsubscribed'],
229229
MESSAGE_TIMEOUT,
230230
);
@@ -246,7 +246,7 @@ export default class Bell {
246246

247247
// If the message is a message and not a tip, don't show it (only show tips)
248248
// Messages will go away on their own
249-
if (this._message._contentType === MesageType._Message) {
249+
if (this._message._contentType === MessageType._Message) {
250250
this._hovering = false;
251251
return;
252252
}
@@ -256,14 +256,14 @@ export default class Bell {
256256
if (this._message._queued.length > 0) {
257257
return this._message._dequeue().then((msg: any) => {
258258
this._message._content = msg;
259-
this._message._contentType = MesageType._Queued;
259+
this._message._contentType = MessageType._Queued;
260260
resolve();
261261
});
262262
} else {
263263
this._message._content = decodeHtmlEntities(
264264
this._message._getTipForState(),
265265
);
266-
this._message._contentType = MesageType._Tip;
266+
this._message._contentType = MessageType._Tip;
267267
resolve();
268268
}
269269
})
@@ -280,7 +280,7 @@ export default class Bell {
280280

281281
OneSignal._emitter.on(BellEvent._Hovered, () => {
282282
// If a message is displayed (and not a tip), don't control it. Visitors have no control over messages
283-
if (this._message._contentType === MesageType._Message) {
283+
if (this._message._contentType === MessageType._Message) {
284284
return;
285285
}
286286

@@ -351,7 +351,10 @@ export default class Bell {
351351
}
352352
if (state.to === BellState._Subscribed) {
353353
this._launcher._inactivate();
354-
} else if (state.to === BellState._Unsubscribed || state.to === BellState._Blocked) {
354+
} else if (
355+
state.to === BellState._Unsubscribed ||
356+
state.to === BellState._Blocked
357+
) {
355358
this._launcher._activate();
356359
}
357360
});
@@ -579,19 +582,19 @@ export default class Bell {
579582
const pulseRing = buttonElement?.querySelector<HTMLElement>('.pulse-ring');
580583

581584
// Reset added styles first
582-
const background = this.graphic?.querySelector<HTMLElement>('.background');
585+
const background = this._graphic?.querySelector<HTMLElement>('.background');
583586
if (background) {
584587
background.style.cssText = '';
585588
}
586589
const foregroundElements =
587-
this.graphic?.querySelectorAll<HTMLElement>('.foreground') ?? [];
590+
this._graphic?.querySelectorAll<HTMLElement>('.foreground') ?? [];
588591
for (let i = 0; i < foregroundElements.length; i++) {
589592
const element = foregroundElements[i];
590593
if (element) {
591594
element.style.cssText = '';
592595
}
593596
}
594-
const stroke = this.graphic?.querySelector<HTMLElement>('.stroke');
597+
const stroke = this._graphic?.querySelector<HTMLElement>('.stroke');
595598
if (stroke) {
596599
stroke.style.cssText = '';
597600
}
@@ -613,21 +616,21 @@ export default class Bell {
613616
const colors = this._options.colors;
614617
if (colors['circle.background']) {
615618
const background =
616-
this.graphic?.querySelector<HTMLElement>('.background');
619+
this._graphic?.querySelector<HTMLElement>('.background');
617620
if (background) {
618621
background.style.cssText += `fill: ${colors['circle.background']}`;
619622
}
620623
}
621624
if (colors['circle.foreground']) {
622625
const foregroundElements =
623-
this.graphic?.querySelectorAll<HTMLElement>('.foreground') ?? [];
626+
this._graphic?.querySelectorAll<HTMLElement>('.foreground') ?? [];
624627
for (let i = 0; i < foregroundElements.length; i++) {
625628
const element = foregroundElements[i];
626629
if (element) {
627630
element.style.cssText += `fill: ${colors['circle.foreground']}`;
628631
}
629632
}
630-
const stroke = this.graphic?.querySelector<HTMLElement>('.stroke');
633+
const stroke = this._graphic?.querySelector<HTMLElement>('.stroke');
631634
if (stroke) {
632635
stroke.style.cssText += `stroke: ${colors['circle.foreground']}`;
633636
}
@@ -714,7 +717,7 @@ export default class Bell {
714717
* Updates the current state to the specified new state.
715718
* @param newState One of ['subscribed', 'unsubscribed'].
716719
*/
717-
_setState(newState: BellStateType, silent = false) {
720+
_setState(newState: BellStateValue, silent = false) {
718721
const lastState = this._state;
719722
this._state = newState;
720723
if (lastState !== newState && !silent) {
@@ -733,7 +736,7 @@ export default class Bell {
733736
}
734737

735738
get _graphic() {
736-
return this._button._element?.querySelector('svg');
739+
return this._buttonEl?._element?.querySelector('svg');
737740
}
738741

739742
get _launcher() {

src/page/bell/Button.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default class Button extends AnimatedElement {
101101
try {
102102
if (
103103
this._bell._message._shown &&
104-
this._bell._message._contentType == MesageType._Message
104+
this._bell._message._contentType == MessageType._Message
105105
) {
106106
// A message is being shown, it'll disappear soon
107107
return;
@@ -115,7 +115,7 @@ export default class Button extends AnimatedElement {
115115
OneSignal._emitter.once(OneSignal.EVENTS.SUBSCRIPTION_CHANGED, () => {
116116
this._bell._message
117117
._display(
118-
MesageType._Message,
118+
MessageType._Message,
119119
this._bell._options.text['message.action.subscribed'],
120120
MESSAGE_TIMEOUT,
121121
)

src/page/bell/Launcher.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,20 @@ export default class Launcher extends AnimatedElement {
7878
}
7979

8080
async _inactivate() {
81-
await this.bell.message.hide();
82-
const hasContent = this.bell.badge.content.length > 0;
83-
if (hasContent) await this.bell.badge.hide();
84-
await Promise.all([super.inactivate(), this.resize('small')]);
85-
if (hasContent) await this.bell.badge.show();
81+
await this._bell._message._hide();
82+
const hasContent = this._bell._badge._content.length > 0;
83+
if (hasContent) await this._bell._badge._hide();
84+
await Promise.all([super._inactivate(), this._resize('small')]);
85+
if (hasContent) await this._bell._badge._show();
8686
}
8787

8888
async _activate() {
8989
if (this._bell._badge._content.length > 0) {
9090
await this._bell._badge._hide();
9191
}
92-
await Promise.all([super.activate(), this.resize(this.bell.options.size!)]);
92+
await Promise.all([
93+
super._activate(),
94+
this._resize(this._bell._options.size!),
95+
]);
9396
}
9497
}

0 commit comments

Comments
 (0)