@ethora/chat-component 26.2.11 → 26.2.13

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.
@@ -59,10 +59,13 @@ export declare class XmppClient implements XmppClientInterface {
59
59
  private reconnectBaseDelayMs;
60
60
  private pausedDueToOfflineCap;
61
61
  private authFailureDetected;
62
+ private reconnectSuppressed;
62
63
  private isTerminalAuthFailure;
63
64
  constructor(username: string, password: string, xmppSettings?: xmppSettingsInterface);
64
65
  initializeClient(): Promise<void>;
65
- disconnect(): Promise<void>;
66
+ disconnect(options?: {
67
+ suppressReconnect?: boolean;
68
+ }): Promise<void>;
66
69
  attachEventListeners(): void;
67
70
  private scheduleAdaptivePing;
68
71
  private startAdaptivePing;
@@ -77,5 +77,7 @@ export interface XmppClientInterface {
77
77
  createPrivateRoomStanza(title: string, description: string, to: string): Promise<string>;
78
78
  sendMessageReactionStanza(messageId: string, roomJid: string, reactionsList: string[], reactionSymbol?: string): void;
79
79
  sendTextMessageWithTranslateTagStanza(roomJID: string, firstName: string, lastName: string, photo: string, walletAddress: string, userMessage: string, notDisplayedValue?: string, isReply?: boolean, showInChannel?: boolean, mainMessage?: string, langSource?: Iso639_1Codes): void;
80
- disconnect?(): Promise<void>;
80
+ disconnect?(options?: {
81
+ suppressReconnect?: boolean;
82
+ }): Promise<void>;
81
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethora/chat-component",
3
- "version": "26.02.11",
3
+ "version": "26.02.13",
4
4
  "type": "module",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",
@@ -55,6 +55,24 @@ function wasHandledByFcm(id) {
55
55
  return id ? _handledByFcm.has(id) : false;
56
56
  }
57
57
 
58
+ function buildDedupeKey(payload = {}) {
59
+ const data = payload.data || {};
60
+ const notification = payload.notification || {};
61
+ const explicitMessageId =
62
+ payload.messageId ||
63
+ data.msgID ||
64
+ data.messageId ||
65
+ data.message_id ||
66
+ '';
67
+
68
+ const roomJid = data.jid || payload.roomJid || '';
69
+ const senderId = data.userJid || payload.senderId || '';
70
+ const title = notification.title || payload.title || '';
71
+ const body = notification.body || payload.body || payload.message || '';
72
+
73
+ return explicitMessageId || `${roomJid}|${senderId}|${title}|${body}`;
74
+ }
75
+
58
76
  // ── Helpers ───────────────────────────────────────────────────
59
77
  function isSystemPayload(data) {
60
78
  return !data?.msgID && !data?.jid && !!data?.userJid;
@@ -157,8 +175,14 @@ if (messaging) {
157
175
  const data = payload.data || {};
158
176
  const notification = payload.notification || {};
159
177
  const messageId = payload.messageId || data.msgID || null;
178
+ const dedupeKey = buildDedupeKey({
179
+ messageId,
180
+ data,
181
+ notification,
182
+ });
160
183
 
161
184
  markHandledByFcm(messageId);
185
+ markHandledByFcm(dedupeKey);
162
186
 
163
187
  const isSystem = isSystemPayload(data);
164
188
  const title =
@@ -244,12 +268,24 @@ self.addEventListener('push', (event) => {
244
268
  payloadData.messageId ||
245
269
  payloadData.message_id ||
246
270
  null;
271
+ const dedupeKey = buildDedupeKey({
272
+ messageId,
273
+ data: payloadData,
274
+ notification,
275
+ title: raw.title,
276
+ body: raw.body || raw.message,
277
+ roomJid: raw.roomJid,
278
+ senderId: raw.senderId,
279
+ });
247
280
 
248
- if (wasHandledByFcm(messageId)) {
281
+ if (wasHandledByFcm(messageId) || wasHandledByFcm(dedupeKey)) {
249
282
  // console.log(`[SW] push skipped – already handled by FCM (msgId=${messageId})`);
250
283
  return;
251
284
  }
252
285
 
286
+ markHandledByFcm(messageId);
287
+ markHandledByFcm(dedupeKey);
288
+
253
289
  if (sourceType !== 'json') {
254
290
  /* console.log('[SW][NON_JSON_PUSH_PROCESSED]', {
255
291
  sourceType,