isometrik-plugin-chat-sdk 1.3.18 → 1.3.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.
@@ -1572,8 +1572,19 @@ function createMqttContext(host) {
1572
1572
  function hostAppendInboundMessage(host, parsedMessage) {
1573
1573
  host.allMessages = appendUniqueById(host.allMessages, parsedMessage);
1574
1574
  }
1575
+ /**
1576
+ * Build MQTT dispatch context from the live <web-chat> host.
1577
+ *
1578
+ * Do NOT `{...host}` / `Object.assign({}, host)` — Stencil `@State` (e.g.
1579
+ * `allConversationList`) lives behind prototype getters. A plain snapshot
1580
+ * drops them → `undefined.some` on `chatMessageSent` and realtime dies
1581
+ * even though MQTT is connected.
1582
+ */
1575
1583
  function hostCreateMqttContext(host) {
1576
- return createMqttContext(Object.assign(Object.assign({}, host), { handleForwardMessage: (msg) => hostHandleForwardMessage(host, msg), appendInboundMessage: (msg) => hostAppendInboundMessage(host, msg) }));
1584
+ return createMqttContext(Object.assign(host, {
1585
+ handleForwardMessage: (msg) => hostHandleForwardMessage(host, msg),
1586
+ appendInboundMessage: (msg) => hostAppendInboundMessage(host, msg),
1587
+ }));
1577
1588
  }
1578
1589
  async function hostHandleMqttMessage(host, message) {
1579
1590
  const parsedMessage = parseMqttPayload(message);
@@ -1653,9 +1664,10 @@ async function hostSetupMqttClient(host) {
1653
1664
  });
1654
1665
  }
1655
1666
  async function hostHandleForwardMessage(host, parsedMessage) {
1656
- var _a, _b;
1667
+ var _a, _b, _c;
1657
1668
  try {
1658
- const conversationExists = host.allConversationList.some((conversation) => conversation.conversationId === parsedMessage.conversationId);
1669
+ const list = (_a = host.allConversationList) !== null && _a !== void 0 ? _a : [];
1670
+ const conversationExists = list.some((conversation) => conversation.conversationId === parsedMessage.conversationId);
1659
1671
  if (!conversationExists) {
1660
1672
  const conversationDetails = await host.getUserConversationDetails(parsedMessage.conversationId);
1661
1673
  const newConversation = {
@@ -1663,19 +1675,19 @@ async function hostHandleForwardMessage(host, parsedMessage) {
1663
1675
  lastMessageDetails: {
1664
1676
  body: parsedMessage.body,
1665
1677
  updatedAt: parsedMessage.updatedAt || Date.now(),
1666
- userName: (_a = conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.opponentDetails) === null || _a === void 0 ? void 0 : _a.userName,
1667
- userProfileImageUrl: (_b = conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.opponentDetails) === null || _b === void 0 ? void 0 : _b.userProfileImageUrl,
1678
+ userName: (_b = conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.opponentDetails) === null || _b === void 0 ? void 0 : _b.userName,
1679
+ userProfileImageUrl: (_c = conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.opponentDetails) === null || _c === void 0 ? void 0 : _c.userProfileImageUrl,
1668
1680
  },
1669
1681
  unreadMessagesCount: 0,
1670
1682
  };
1671
1683
  host.allConversationList = host.sortConversationsByLatestMessage([
1672
1684
  newConversation,
1673
- ...host.allConversationList,
1685
+ ...list,
1674
1686
  ]);
1675
1687
  await host.getAllAttachments(newConversation.conversationId);
1676
1688
  }
1677
1689
  else {
1678
- host.allConversationList = host.sortConversationsByLatestMessage(host.allConversationList.map((conversation) => {
1690
+ host.allConversationList = host.sortConversationsByLatestMessage(list.map((conversation) => {
1679
1691
  if (conversation.conversationId === parsedMessage.conversationId) {
1680
1692
  return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: parsedMessage.body, updatedAt: parsedMessage.updatedAt || Date.now() }), isGroup: conversation.isGroup, conversationTitle: conversation.conversationTitle, conversationImageUrl: conversation.conversationImageUrl, opponentDetails: conversation.opponentDetails });
1681
1693
  }