isometrik-plugin-chat-sdk 2.0.17 → 2.0.19

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.
Files changed (67) hide show
  1. package/dist/cjs/attachment-preview_22.cjs.entry.js +7 -32
  2. package/dist/cjs/attachment-preview_22.cjs.entry.js.map +1 -1
  3. package/dist/cjs/{client-80851676.js → client-fef5fd3d.js} +29 -1
  4. package/dist/cjs/client-fef5fd3d.js.map +1 -0
  5. package/dist/cjs/{group-members-5a82ec8a.js → group-members-cef1198e.js} +29 -1
  6. package/dist/cjs/group-members-cef1198e.js.map +1 -0
  7. package/dist/cjs/index.cjs.js +1 -1
  8. package/dist/cjs/login-page_3.cjs.entry.js +56 -17
  9. package/dist/cjs/login-page_3.cjs.entry.js.map +1 -1
  10. package/dist/collection/components/ChatUIComponent/shared/contact-info/contact-info.js +4 -4
  11. package/dist/collection/components/ChatUIComponent/shared/contact-info/contact-info.js.map +1 -1
  12. package/dist/collection/components/my-component/web-chat/data-fetch.js +9 -3
  13. package/dist/collection/components/my-component/web-chat/data-fetch.js.map +1 -1
  14. package/dist/collection/components/my-component/web-chat/event-handlers.js +16 -3
  15. package/dist/collection/components/my-component/web-chat/event-handlers.js.map +1 -1
  16. package/dist/collection/components/my-component/web-chat/mutations.js +7 -2
  17. package/dist/collection/components/my-component/web-chat/mutations.js.map +1 -1
  18. package/dist/collection/components/my-component/web-chat/offline-host.js +21 -5
  19. package/dist/collection/components/my-component/web-chat/offline-host.js.map +1 -1
  20. package/dist/collection/lib/mqtt/dispatch.js +3 -3
  21. package/dist/collection/lib/mqtt/dispatch.js.map +1 -1
  22. package/dist/collection/lib/offline/client.js +11 -0
  23. package/dist/collection/lib/offline/client.js.map +1 -1
  24. package/dist/collection/lib/offline/idb.js +11 -0
  25. package/dist/collection/lib/offline/idb.js.map +1 -1
  26. package/dist/collection/lib/offline/memory-db.js +6 -0
  27. package/dist/collection/lib/offline/memory-db.js.map +1 -1
  28. package/dist/components/WebChat.js +55 -16
  29. package/dist/components/WebChat.js.map +1 -1
  30. package/dist/components/client.js +28 -0
  31. package/dist/components/client.js.map +1 -1
  32. package/dist/components/contact-info2.js +5 -5
  33. package/dist/components/contact-info2.js.map +1 -1
  34. package/dist/esm/attachment-preview_22.entry.js +5 -30
  35. package/dist/esm/attachment-preview_22.entry.js.map +1 -1
  36. package/dist/esm/{client-4a3e00da.js → client-de7fbead.js} +29 -1
  37. package/dist/esm/client-de7fbead.js.map +1 -0
  38. package/dist/esm/{group-members-05414da2.js → group-members-7909941c.js} +28 -2
  39. package/dist/esm/group-members-7909941c.js.map +1 -0
  40. package/dist/esm/index.js +1 -1
  41. package/dist/esm/login-page_3.entry.js +56 -17
  42. package/dist/esm/login-page_3.entry.js.map +1 -1
  43. package/dist/isometrik-webchat/index.esm.js +1 -1
  44. package/dist/isometrik-webchat/isometrik-webchat.esm.js +1 -1
  45. package/dist/isometrik-webchat/p-5cfb953d.js +2 -0
  46. package/dist/isometrik-webchat/p-5cfb953d.js.map +1 -0
  47. package/dist/isometrik-webchat/p-a9380fb3.entry.js +2 -0
  48. package/dist/isometrik-webchat/{p-e5ffe038.entry.js.map → p-a9380fb3.entry.js.map} +1 -1
  49. package/dist/isometrik-webchat/p-f0d4687f.js +2 -0
  50. package/dist/isometrik-webchat/p-f0d4687f.js.map +1 -0
  51. package/dist/isometrik-webchat/{p-bf71ce5e.entry.js → p-fc3fd090.entry.js} +2 -2
  52. package/dist/isometrik-webchat/p-fc3fd090.entry.js.map +1 -0
  53. package/dist/types/components/my-component/web-chat/offline-host.d.ts +2 -0
  54. package/dist/types/lib/offline/client.d.ts +2 -0
  55. package/dist/types/lib/offline/idb.d.ts +2 -0
  56. package/dist/types/lib/offline/memory-db.d.ts +1 -0
  57. package/package.json +1 -1
  58. package/dist/cjs/client-80851676.js.map +0 -1
  59. package/dist/cjs/group-members-5a82ec8a.js.map +0 -1
  60. package/dist/esm/client-4a3e00da.js.map +0 -1
  61. package/dist/esm/group-members-05414da2.js.map +0 -1
  62. package/dist/isometrik-webchat/p-ae168135.js +0 -2
  63. package/dist/isometrik-webchat/p-ae168135.js.map +0 -1
  64. package/dist/isometrik-webchat/p-b667a9fc.js +0 -2
  65. package/dist/isometrik-webchat/p-b667a9fc.js.map +0 -1
  66. package/dist/isometrik-webchat/p-bf71ce5e.entry.js.map +0 -1
  67. package/dist/isometrik-webchat/p-e5ffe038.entry.js +0 -2
@@ -6,7 +6,7 @@ import { d as defineCustomElement$2 } from './WebChatHeader.js';
6
6
  import { d as defineCustomElement$u } from './ChatFooter.js';
7
7
  import { d as defineCustomElement$a } from './Profile.js';
8
8
  import { d as defineCustomElement$9 } from './profile-sidebar2.js';
9
- import { d as defineCustomElement$q } from './contact-info2.js';
9
+ import { w as withConversationPushFlag, d as defineCustomElement$q } from './contact-info2.js';
10
10
  import { d as defineCustomElement$1 } from './WebchatRightSide.js';
11
11
  import { d as defineCustomElement$t } from './chat-loading-placeholder2.js';
12
12
  import { d as drawerDialogService } from './drawer.js';
@@ -881,8 +881,8 @@ async function dispatchMqttMessage(parsedMessage, ctx) {
881
881
  }
882
882
  // Local inbound alert (host can disable / customize via init props).
883
883
  const conversation = findConversationForPush(parsedMessage.conversationId, ctx.allConversationList, ctx.conversationMetaData);
884
- const pushMuted = ((_10 = conversation === null || conversation === void 0 ? void 0 : conversation.config) === null || _10 === void 0 ? void 0 : _10.pushNotifications) === false;
885
- if (!pushMuted && ((_11 = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.events) === null || _11 === void 0 ? void 0 : _11.sendPushNotification) !== false) {
884
+ const conversationPushEnabled = ((_10 = conversation === null || conversation === void 0 ? void 0 : conversation.config) === null || _10 === void 0 ? void 0 : _10.pushNotifications) !== false;
885
+ if (conversationPushEnabled && ((_11 = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.events) === null || _11 === void 0 ? void 0 : _11.sendPushNotification) !== false) {
886
886
  showLocalMessageNotification(parsedMessage, {
887
887
  pushCtx: messagePushContextFrom({
888
888
  userMetaData: {
@@ -890,7 +890,7 @@ async function dispatchMqttMessage(parsedMessage, ctx) {
890
890
  },
891
891
  conversation,
892
892
  }),
893
- conversationPushEnabled: true,
893
+ conversationPushEnabled,
894
894
  });
895
895
  }
896
896
  }
@@ -932,8 +932,9 @@ function hostInitOffline(host) {
932
932
  client.setUser(uid);
933
933
  client.startTabSync(event => {
934
934
  var _a;
935
+ // Snapshot from peer tab (incl. clear → []) — do not merge or wiped msgs return.
935
936
  if (event.type === 'messages' && event.conversationId === host.selectedConversationId) {
936
- host.allMessages = mergeMessagesById(host.allMessages || [], event.messages || []);
937
+ host.allMessages = Array.isArray(event.messages) ? event.messages : [];
937
938
  }
938
939
  if (event.type === 'conversations') {
939
940
  // Prefer newer network list; only fill gaps from peer tab
@@ -1000,14 +1001,16 @@ async function hostPersistConversations(host) {
1000
1001
  }
1001
1002
  }
1002
1003
  async function hostPersistMessages(host, conversationId) {
1003
- var _a;
1004
1004
  const uid = userIdOf(host);
1005
1005
  const id = conversationId || host.selectedConversationId;
1006
- if (!uid || !id || !((_a = host.allMessages) === null || _a === void 0 ? void 0 : _a.length))
1006
+ if (!uid || !id)
1007
1007
  return;
1008
1008
  try {
1009
- await getOfflineClient().persistMessages(uid, id, host.allMessages);
1010
- const last = host.allMessages[host.allMessages.length - 1];
1009
+ const list = Array.isArray(host.allMessages) ? host.allMessages : [];
1010
+ await getOfflineClient().persistMessages(uid, id, list);
1011
+ if (!list.length)
1012
+ return;
1013
+ const last = list[list.length - 1];
1011
1014
  const cursor = (last === null || last === void 0 ? void 0 : last.sentAt) || (last === null || last === void 0 ? void 0 : last.updatedAt) || Date.now();
1012
1015
  await getOfflineClient().setCursor(uid, id, cursor);
1013
1016
  }
@@ -1015,6 +1018,19 @@ async function hostPersistMessages(host, conversationId) {
1015
1018
  console.error('offline persist messages failed', e);
1016
1019
  }
1017
1020
  }
1021
+ /** Wipe IndexedDB thread cache after clear-chat so hydrate cannot resurrect msgs. */
1022
+ async function hostClearCachedMessages(host, conversationId) {
1023
+ const uid = userIdOf(host);
1024
+ const id = conversationId || host.selectedConversationId;
1025
+ if (!uid || !id)
1026
+ return;
1027
+ try {
1028
+ await getOfflineClient().clearMessages(uid, id);
1029
+ }
1030
+ catch (e) {
1031
+ console.error('offline clear messages failed', e);
1032
+ }
1033
+ }
1018
1034
  async function hostEnqueueFailedText(host, opts) {
1019
1035
  var _a, _b, _c;
1020
1036
  const uid = userIdOf(host);
@@ -1377,12 +1393,18 @@ async function hostGetMessages(host, skip, conversationId) {
1377
1393
  });
1378
1394
  const targetId = conversationId || host.selectedConversationId;
1379
1395
  if (skip == 0) {
1396
+ // Network page is authority. Keep only local/outbox rows so cleared
1397
+ // IndexedDB hydrate cannot resurrect server-deleted messages.
1398
+ const keepLocal = (list) => (list || []).filter((m) => (m === null || m === void 0 ? void 0 : m.localId) ||
1399
+ (m === null || m === void 0 ? void 0 : m.pendingOffline) ||
1400
+ (m === null || m === void 0 ? void 0 : m.status) === 'queued' ||
1401
+ (m === null || m === void 0 ? void 0 : m.status) === 'pending' ||
1402
+ (m === null || m === void 0 ? void 0 : m.status) === 'failed');
1380
1403
  if (conversationId) {
1381
- host.selectConversationMessages = mergeMessagesById(host.selectConversationMessages || [], messages);
1404
+ host.selectConversationMessages = mergeMessagesById(keepLocal(host.selectConversationMessages), messages);
1382
1405
  }
1383
1406
  else {
1384
- // Merge with any optimistic/outbox rows already on screen
1385
- host.allMessages = mergeMessagesById(host.allMessages || [], messages);
1407
+ host.allMessages = mergeMessagesById(keepLocal(host.allMessages), messages);
1386
1408
  }
1387
1409
  }
1388
1410
  else {
@@ -2324,18 +2346,31 @@ function hostContactAction(host, event) {
2324
2346
  }
2325
2347
  async function hostConversationUpdate(host, event) {
2326
2348
  const { conversationId, type, value } = event.detail || {};
2349
+ const settingsPush = type === 'settings' && typeof (value === null || value === void 0 ? void 0 : value.pushNotifications) === 'boolean'
2350
+ ? value.pushNotifications === true
2351
+ : null;
2327
2352
  if (type === 'title' && value) {
2328
2353
  host.allConversationList = host.allConversationList.map((conv) => conv.conversationId === conversationId ? Object.assign(Object.assign({}, conv), { conversationTitle: value }) : conv);
2329
2354
  }
2330
2355
  else if (type === 'image' && value) {
2331
2356
  host.allConversationList = host.allConversationList.map((conv) => conv.conversationId === conversationId ? Object.assign(Object.assign({}, conv), { conversationImageUrl: value }) : conv);
2332
2357
  }
2358
+ else if (settingsPush !== null) {
2359
+ // Optimistic — MQTT local alerts read list/meta config, not contact-info state alone.
2360
+ host.allConversationList = (host.allConversationList || []).map((conv) => conv.conversationId === conversationId
2361
+ ? withConversationPushFlag(conv, settingsPush)
2362
+ : conv);
2363
+ if (host.selectedConversationId === conversationId && host.conversationMetaData) {
2364
+ host.conversationMetaData = withConversationPushFlag(host.conversationMetaData, settingsPush);
2365
+ }
2366
+ }
2333
2367
  try {
2334
2368
  const response = await M.getInstance().Conversation.getConversationDetails(conversationId, 'true');
2335
2369
  if (response) {
2336
- host.allConversationList = host.allConversationList.map((conv) => conv.conversationId === conversationId ? Object.assign(Object.assign({}, conv), response) : conv);
2370
+ const merged = settingsPush !== null ? withConversationPushFlag(response, settingsPush) : response;
2371
+ host.allConversationList = host.allConversationList.map((conv) => conv.conversationId === conversationId ? Object.assign(Object.assign({}, conv), merged) : conv);
2337
2372
  if (host.selectedConversationId === conversationId) {
2338
- host.conversationMetaData = response;
2373
+ host.conversationMetaData = merged;
2339
2374
  }
2340
2375
  }
2341
2376
  }
@@ -2441,8 +2476,12 @@ async function hostClearConversation(host, conversationId) {
2441
2476
  const id = conversationId || host.selectedConversationId;
2442
2477
  try {
2443
2478
  await apiClearConversationLocal(id);
2444
- host.allMessages = [];
2445
- host.allConversationList = patchListAfterClear(host.allConversationList, host.selectedConversationId);
2479
+ if (host.selectedConversationId === id) {
2480
+ host.allMessages = [];
2481
+ }
2482
+ host.allConversationList = patchListAfterClear(host.allConversationList, id);
2483
+ // IndexedDB was keeping old msgs; hydrate/merge brought them back after clear.
2484
+ await hostClearCachedMessages(host, id);
2446
2485
  }
2447
2486
  catch (error) {
2448
2487
  console.error('Error while clearing conversation:', error);