@product7/product7-js 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@product7/product7-js",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "JavaScript SDK for integrating Product7 feedback widgets into any website",
5
5
  "main": "dist/product7-js.js",
6
6
  "module": "src/index.js",
@@ -37,7 +37,7 @@ export class NotificationSound {
37
37
  if (this._soundUrl) {
38
38
  await this._playFile();
39
39
  } else {
40
- this._playSynthetic();
40
+ await this._playSynthetic();
41
41
  }
42
42
  } catch {
43
43
  /* autoplay policy or context suspended — silent fail */
@@ -61,12 +61,12 @@ export class NotificationSound {
61
61
  * • Second tone: 1100 Hz, 60–160 ms
62
62
  * Sounds like a gentle message ping.
63
63
  */
64
- _playSynthetic() {
64
+ async _playSynthetic() {
65
65
  const ctx = this._getAudioContext();
66
66
  if (!ctx) return;
67
67
 
68
68
  if (ctx.state === 'suspended') {
69
- ctx.resume().catch(() => {});
69
+ await ctx.resume();
70
70
  }
71
71
 
72
72
  const now = ctx.currentTime;
@@ -100,7 +100,7 @@ export class MessengerWidget extends BaseWidget {
100
100
  : true;
101
101
 
102
102
  this._notificationSound = new NotificationSound({
103
- soundUrl: typeof notificationSoundOption === 'string' ? notificationSoundOption : null,
103
+ soundUrl: typeof notificationSoundOption === 'string' ? notificationSoundOption : undefined,
104
104
  volume: options.notificationVolume ?? 0.4,
105
105
  });
106
106
 
@@ -434,14 +434,8 @@ export class MessengerWidget extends BaseWidget {
434
434
 
435
435
  const isOwnMessage = message.sender_type === 'customer';
436
436
 
437
- if (!isOwnMessage) {
438
- const panelOpenOnThisConversation =
439
- this.messengerState.isOpen &&
440
- this.messengerState.activeConversationId === conversation_id;
441
-
442
- if (!panelOpenOnThisConversation) {
443
- this._notificationSound.play();
444
- }
437
+ if (!isOwnMessage && this.messengerState.isIdentified) {
438
+ this._notificationSound.play();
445
439
  }
446
440
 
447
441
  if (