@ethora/chat-component 26.2.11 → 26.2.12
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/README.md +28 -0
- package/dist/firebase-messaging-sw.js +37 -1
- package/dist/main.js +6372 -6354
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
- package/public/firebase-messaging-sw.js +37 -1
package/package.json
CHANGED
|
@@ -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,
|