isometrik-plugin-chat-sdk 2.0.14 → 2.0.15

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.
@@ -700,6 +700,7 @@ async function dispatchMqttMessage(parsedMessage, ctx) {
700
700
  if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === MQTT_ACTIONS.memberLeave || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'memberLeave') {
701
701
  const leaveId = String(mqttActorId(parsedMessage) || '');
702
702
  const leaveName = (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName) || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName) || 'Someone';
703
+ const leaveAt = (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now();
703
704
  const conversationExists = ctx.allConversationList.some(conversation => conversation.conversationId === (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationId));
704
705
  if (parsedMessage.conversationId === ctx.selectedConversationId && leaveId) {
705
706
  ctx.conversationMetaData = Object.assign(Object.assign({}, ctx.conversationMetaData), { members: (_p = (_o = ctx.conversationMetaData) === null || _o === void 0 ? void 0 : _o.members) === null || _p === void 0 ? void 0 : _p.filter((user) => String((user === null || user === void 0 ? void 0 : user.userId) || (user === null || user === void 0 ? void 0 : user.memberId) || '') !== leaveId) });
@@ -711,9 +712,15 @@ async function dispatchMqttMessage(parsedMessage, ctx) {
711
712
  const nextMembers = leaveId
712
713
  ? (conversation.members || []).filter((m) => String((m === null || m === void 0 ? void 0 : m.userId) || (m === null || m === void 0 ? void 0 : m.memberId) || '') !== leaveId)
713
714
  : conversation.members;
714
- return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${leaveName} left the conversation`, sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(), action: 'memberLeave', userId: leaveId || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userId), userName: leaveName, userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl }), members: nextMembers });
715
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${leaveName} left the conversation`, sentAt: leaveAt, action: 'memberLeave', userId: leaveId || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userId), userName: leaveName, userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl }), members: nextMembers });
715
716
  }));
716
717
  }
718
+ // Self-leave is skipped by the generic append guard (actor === self) — inject here
719
+ // so the open thread shows the same "X left" pill the sidebar preview shows.
720
+ if (parsedMessage.conversationId === ctx.selectedConversationId) {
721
+ ctx.appendInboundMessage(Object.assign(Object.assign({}, parsedMessage), { action: 'memberLeave', userId: leaveId || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userId), userName: leaveName, sentAt: leaveAt, messageId: parsedMessage.messageId ||
722
+ `memberLeave-${leaveId || 'unknown'}-${leaveAt}` }));
723
+ }
717
724
  }
718
725
  if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'addAdmin') {
719
726
  const conversationExists = ctx.allConversationList.some(conversation => conversation.conversationId === parsedMessage.conversationId);
@@ -849,8 +856,12 @@ async function dispatchMqttMessage(parsedMessage, ctx) {
849
856
  }
850
857
  }
851
858
  // Append inbound pills/bubbles. Use mqttActorId — leave events often set userId, not senderId.
859
+ // memberLeave is appended in its dedicated block (incl. self-leave) — skip here to avoid dupes.
852
860
  const actorId = mqttActorId(parsedMessage);
853
- if (actorId != ((_5 = ctx.userMetaData) === null || _5 === void 0 ? void 0 : _5.userId) && !isStatusOnlyAction(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action)) {
861
+ if (actorId != ((_5 = ctx.userMetaData) === null || _5 === void 0 ? void 0 : _5.userId) &&
862
+ !isStatusOnlyAction(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) &&
863
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) !== MQTT_ACTIONS.memberLeave &&
864
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) !== 'memberLeave') {
854
865
  if (parsedMessage.conversationId === ctx.selectedConversationId) {
855
866
  ctx.appendInboundMessage(parsedMessage);
856
867
  }
@@ -2391,11 +2402,38 @@ async function hostDeleteGroupcast(host, e) {
2391
2402
  }
2392
2403
  }
2393
2404
  function hostGroupExited(host, event) {
2394
- var _a;
2405
+ var _a, _b, _c;
2395
2406
  const conversationId = (_a = event.detail) === null || _a === void 0 ? void 0 : _a.conversationId;
2396
- if (conversationId) {
2397
- host.exitedGroupIds.add(conversationId);
2407
+ if (!conversationId)
2408
+ return;
2409
+ // New Set so Stencil @State re-renders the exited composer banner.
2410
+ const nextExited = new Set(host.exitedGroupIds || []);
2411
+ nextExited.add(conversationId);
2412
+ host.exitedGroupIds = nextExited;
2413
+ const selfId = String(((_b = host.userMetaData) === null || _b === void 0 ? void 0 : _b.userId) || '');
2414
+ const selfName = String(((_c = host.userMetaData) === null || _c === void 0 ? void 0 : _c.userName) || 'You');
2415
+ const sentAt = Date.now();
2416
+ const leaveMsg = {
2417
+ action: 'memberLeave',
2418
+ userId: selfId,
2419
+ userName: selfName,
2420
+ conversationId,
2421
+ sentAt,
2422
+ messageId: `local-leave-${conversationId}-${sentAt}`,
2423
+ };
2424
+ // API leave can finish before MQTT — keep body in sync with sidebar "You left".
2425
+ if (host.selectedConversationId === conversationId) {
2426
+ const list = Array.isArray(host.allMessages) ? host.allMessages : [];
2427
+ const already = list.some((m) => (m === null || m === void 0 ? void 0 : m.action) === 'memberLeave' &&
2428
+ String((m === null || m === void 0 ? void 0 : m.userId) || '') === selfId &&
2429
+ Math.abs(Number((m === null || m === void 0 ? void 0 : m.sentAt) || 0) - sentAt) < 60000);
2430
+ if (!already) {
2431
+ host.allMessages = [...list, leaveMsg];
2432
+ host.isScrollToBottom = true;
2433
+ }
2398
2434
  }
2435
+ host.allConversationList = (host.allConversationList || []).map((c) => (c === null || c === void 0 ? void 0 : c.conversationId) === conversationId
2436
+ ? Object.assign(Object.assign({}, c), { lastMessageDetails: Object.assign(Object.assign({}, c.lastMessageDetails), { action: 'memberLeave', body: 'You left the conversation', userId: selfId, userName: selfName, sentAt }) }) : c);
2399
2437
  }
2400
2438
  function hostTagUserClick(host, event) {
2401
2439
  const { userId, userName } = event.detail || {};
@@ -2626,13 +2664,9 @@ function renderLeftRail(host) {
2626
2664
  function renderDefaultComposer(host) {
2627
2665
  var _a;
2628
2666
  if (host.exitedGroupIds.has(host.selectedConversationId)) {
2629
- return (h("div", { style: {
2630
- padding: '1rem',
2631
- textAlign: 'center',
2632
- backgroundColor: 'var(--bg-secondary)',
2633
- color: 'var(--text-primary)',
2634
- borderTop: '1px solid var(--bg-secondary)',
2635
- } }, "You are no longer a member of this group"));
2667
+ return (h("div", { class: "exited-group-banner", role: "status", "aria-live": "polite" },
2668
+ h("div", { class: "exited-group-banner-pill" }, "You are no longer a member of this group"),
2669
+ h("p", { class: "exited-group-banner-hint" }, "You can still read past messages, but you can\u2019t send new ones.")));
2636
2670
  }
2637
2671
  if (host.isBlocked === 'loading') {
2638
2672
  return h("p", { class: "blockMessageContainer" }, WEB_CONTENT.PLEASE_WAIT);
@@ -2711,7 +2745,7 @@ function renderRightRail(host) {
2711
2745
  return (h("div", { class: "chat-sidebar-right" }, renderRegion(host, 'right-panel', true, () => renderDefaultRightPanel(host))));
2712
2746
  }
2713
2747
 
2714
- const webChatCss = ":host{display:flex;flex:1;width:var(--w-full);min-height:0;height:100%}web-chat{display:flex;flex:1;width:var(--w-full);min-height:0;height:100%}.boot-loader-shell{display:flex;flex:1;width:var(--w-full);min-height:0;height:100%;align-items:stretch;justify-content:stretch}.boot-loader-shell>chat-loading-placeholder,.boot-loader-shell>slot[name='boot-loader']{display:flex;flex:1;width:var(--w-full);min-height:0;height:100%}.isometrik-quickchat{box-shadow:none;display:flex;flex:1 1 auto;height:100%;min-height:0;width:var(--w-full);max-height:100%;overflow:hidden}.chat-sidebar-container{width:30%;min-width:var(--sidebar-width);transition:all 0.3s ease;border-right:1px solid var(--border);display:flex;flex-direction:row;background-color:var(--bg-primary);overflow:hidden;min-height:0}profile-sidebar,profile-sidebar-ui{display:flex;height:var(--h-full);flex-shrink:0}.chat-sidebar-right{width:30%;min-width:var(--sidebar-width);transition:all 0.3s ease;border-left:1px solid var(--border);background-color:var(--bg-primary)}.loaderoverlay{width:var(--w-full);position:absolute;margin:auto;background:var(--overlay);z-index:1400}.sidebar-tab{flex:1;min-width:0;height:var(--h-full);min-height:0;background-color:var(--bg-primary);display:flex;flex-direction:column;overflow:hidden}.sidebar-tab>*{flex:1;min-height:0;min-width:0;width:var(--w-full);max-width:var(--w-full)}.chat-body-container{flex:1;display:flex;flex-direction:column;transition:all 0.3s ease;background-color:var(--bg-secondary);position:relative;min-height:0;min-width:0}.chat-pane-row{flex:1;min-height:0;min-width:0;display:flex;flex-direction:row;align-items:stretch;overflow:hidden}.chat-main-stack{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:hidden}.message-info-dock{flex:0 0 clamp(280px, 36%, 380px);height:var(--h-full);min-height:0;display:flex;flex-direction:column;background:var(--bg-primary);border-left:1px solid var(--border);overflow:hidden}.message-info-dock message-info{flex:1;min-height:0;height:var(--h-full);display:block}.message-info-loading{flex:1;display:flex;align-items:center;justify-content:center}.chat-sidebar-container>slot[name='sidebar'],.chat-sidebar-container slot[name='profile-rail'],.sidebar-tab>slot[name='conversation-list'],.sidebar-tab>slot[name='profile-page'],.sidebar-tab>slot[name='group-cast'],.chat-body-container>slot[name='empty'],.chat-main-stack>slot[name='header'],.chat-main-stack>slot[name='messages'],.chat-main-stack>slot[name='composer'],.chat-sidebar-right>slot[name='right-panel']{display:contents}::slotted([slot='sidebar']),::slotted([slot='profile-rail']),::slotted([slot='conversation-list']),::slotted([slot='profile-page']),::slotted([slot='group-cast']),::slotted([slot='empty']),::slotted([slot='messages']),::slotted([slot='right-panel']),::slotted([slot='contact-info']),::slotted([slot='profile-info']),::slotted([slot='message-search']),::slotted([slot='boot-loader']){display:flex;flex-direction:column;flex:1;min-height:0;width:var(--w-full);height:var(--h-full)}::slotted([slot='header']),::slotted([slot='composer']),::slotted([slot='composer-input']),::slotted([slot='reply-preview']),::slotted([slot='attachment-preview']){display:block;width:var(--w-full);flex-shrink:0}.noChatSelectedPlaceholder{height:var(--h-full);width:var(--w-full);display:flex;align-items:center;justify-content:center;font-size:var(--text-20);flex-direction:column;gap:var(--gap-4);color:var(--text-primary)}.noChatSelectedPlaceholder span:nth-child(2){font-size:var(--text-24);font-weight:var(--fw-700);margin-top:var(--space-16)}.noChatSelectedPlaceholder span:nth-child(3){font-size:var(--text-18);text-align:center;color:var(--text-secondary)}.loadingPlaceholder{height:var(--h-full);width:var(--w-full);z-index:12839283}.back-button{display:none;padding:0;background:none;border:none;cursor:pointer;align-items:center;gap:var(--gap-4)}spinner-loader{display:flex;height:100%}.blockMessageContainer{text-align:center;padding:var(--space-16) 0;margin:0;background-color:var(--bg-secondary);color:var(--text-secondary)}@media (max-width: 768px){.isometrik-quickchat{position:relative;overflow:hidden}.chat-sidebar-right{width:var(--w-full);height:var(--h-full);min-width:100% !important;position:absolute;left:0;top:0;z-index:20;display:flex;flex-direction:column;background-color:var(--bg-primary);transition:all 0.3s ease;border:none}.chat-sidebar-right>*{flex:1;min-height:0;width:var(--w-full);height:var(--h-full)}.chat-sidebar-container{width:var(--w-full);height:var(--h-full);position:absolute;left:0;top:0;transform:translateX(0);transition:transform 0.3s ease;z-index:2;min-width:100% !important}.chat-sidebar-container.hidden{transform:translateX(-100%)}.chat-body-container{width:var(--w-full);height:var(--h-full);position:absolute;left:0;top:0;transform:translateX(100%);transition:transform 0.3s ease;z-index:1}.chat-body-container.hidden{transform:translateX(0)}.chat-body-container.show{transform:translateX(0);z-index:3}.back-button{display:flex;align-items:center;justify-content:center;position:absolute;right:var(--rail-width);z-index:10;top:var(--space-16)}}";
2748
+ const webChatCss = ":host{display:flex;flex:1;width:var(--w-full);min-height:0;height:100%}web-chat{display:flex;flex:1;width:var(--w-full);min-height:0;height:100%}.boot-loader-shell{display:flex;flex:1;width:var(--w-full);min-height:0;height:100%;align-items:stretch;justify-content:stretch}.boot-loader-shell>chat-loading-placeholder,.boot-loader-shell>slot[name='boot-loader']{display:flex;flex:1;width:var(--w-full);min-height:0;height:100%}.isometrik-quickchat{box-shadow:none;display:flex;flex:1 1 auto;height:100%;min-height:0;width:var(--w-full);max-height:100%;overflow:hidden}.chat-sidebar-container{width:30%;min-width:var(--sidebar-width);transition:all 0.3s ease;border-right:1px solid var(--border);display:flex;flex-direction:row;background-color:var(--bg-primary);overflow:hidden;min-height:0}profile-sidebar,profile-sidebar-ui{display:flex;height:var(--h-full);flex-shrink:0}.chat-sidebar-right{width:30%;min-width:var(--sidebar-width);transition:all 0.3s ease;border-left:1px solid var(--border);background-color:var(--bg-primary)}.loaderoverlay{width:var(--w-full);position:absolute;margin:auto;background:var(--overlay);z-index:1400}.sidebar-tab{flex:1;min-width:0;height:var(--h-full);min-height:0;background-color:var(--bg-primary);display:flex;flex-direction:column;overflow:hidden}.sidebar-tab>*{flex:1;min-height:0;min-width:0;width:var(--w-full);max-width:var(--w-full)}.chat-body-container{flex:1;display:flex;flex-direction:column;transition:all 0.3s ease;background-color:var(--bg-secondary);position:relative;min-height:0;min-width:0}.chat-pane-row{flex:1;min-height:0;min-width:0;display:flex;flex-direction:row;align-items:stretch;overflow:hidden}.chat-main-stack{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:hidden}.message-info-dock{flex:0 0 clamp(280px, 36%, 380px);height:var(--h-full);min-height:0;display:flex;flex-direction:column;background:var(--bg-primary);border-left:1px solid var(--border);overflow:hidden}.message-info-dock message-info{flex:1;min-height:0;height:var(--h-full);display:block}.message-info-loading{flex:1;display:flex;align-items:center;justify-content:center}.chat-sidebar-container>slot[name='sidebar'],.chat-sidebar-container slot[name='profile-rail'],.sidebar-tab>slot[name='conversation-list'],.sidebar-tab>slot[name='profile-page'],.sidebar-tab>slot[name='group-cast'],.chat-body-container>slot[name='empty'],.chat-main-stack>slot[name='header'],.chat-main-stack>slot[name='messages'],.chat-main-stack>slot[name='composer'],.chat-sidebar-right>slot[name='right-panel']{display:contents}::slotted([slot='sidebar']),::slotted([slot='profile-rail']),::slotted([slot='conversation-list']),::slotted([slot='profile-page']),::slotted([slot='group-cast']),::slotted([slot='empty']),::slotted([slot='messages']),::slotted([slot='right-panel']),::slotted([slot='contact-info']),::slotted([slot='profile-info']),::slotted([slot='message-search']),::slotted([slot='boot-loader']){display:flex;flex-direction:column;flex:1;min-height:0;width:var(--w-full);height:var(--h-full)}::slotted([slot='header']),::slotted([slot='composer']),::slotted([slot='composer-input']),::slotted([slot='reply-preview']),::slotted([slot='attachment-preview']){display:block;width:var(--w-full);flex-shrink:0}.noChatSelectedPlaceholder{height:var(--h-full);width:var(--w-full);display:flex;align-items:center;justify-content:center;font-size:var(--text-20);flex-direction:column;gap:var(--gap-4);color:var(--text-primary)}.noChatSelectedPlaceholder span:nth-child(2){font-size:var(--text-24);font-weight:var(--fw-700);margin-top:var(--space-16)}.noChatSelectedPlaceholder span:nth-child(3){font-size:var(--text-18);text-align:center;color:var(--text-secondary)}.loadingPlaceholder{height:var(--h-full);width:var(--w-full);z-index:12839283}.back-button{display:none;padding:0;background:none;border:none;cursor:pointer;align-items:center;gap:var(--gap-4)}spinner-loader{display:flex;height:100%}.blockMessageContainer{text-align:center;padding:var(--space-16) 0;margin:0;background-color:var(--bg-secondary);color:var(--text-secondary)}.exited-group-banner{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0.4rem;padding:0.875rem 1rem 1rem;border-top:1px solid var(--border-subtle, var(--bg-secondary));background:var(--bg-surface, var(--bg-primary));text-align:center}.exited-group-banner-pill{display:inline-flex;align-items:center;justify-content:center;max-width:100%;padding:0.4rem 0.85rem;border-radius:999px;background:var(--bg-secondary, #f4f4f5);color:var(--text-secondary, #52525b);font-size:0.8125rem;font-weight:500;letter-spacing:-0.01em;line-height:1.3}.exited-group-banner-hint{margin:0;max-width:18rem;font-size:0.75rem;line-height:1.35;color:var(--text-tertiary, #71717a)}@media (max-width: 768px){.isometrik-quickchat{position:relative;overflow:hidden}.chat-sidebar-right{width:var(--w-full);height:var(--h-full);min-width:100% !important;position:absolute;left:0;top:0;z-index:20;display:flex;flex-direction:column;background-color:var(--bg-primary);transition:all 0.3s ease;border:none}.chat-sidebar-right>*{flex:1;min-height:0;width:var(--w-full);height:var(--h-full)}.chat-sidebar-container{width:var(--w-full);height:var(--h-full);position:absolute;left:0;top:0;transform:translateX(0);transition:transform 0.3s ease;z-index:2;min-width:100% !important}.chat-sidebar-container.hidden{transform:translateX(-100%)}.chat-body-container{width:var(--w-full);height:var(--h-full);position:absolute;left:0;top:0;transform:translateX(100%);transition:transform 0.3s ease;z-index:1}.chat-body-container.hidden{transform:translateX(0)}.chat-body-container.show{transform:translateX(0);z-index:3}.back-button{display:flex;align-items:center;justify-content:center;position:absolute;right:var(--rail-width);z-index:10;top:var(--space-16)}}";
2715
2749
  const WebChatStyle0 = webChatCss;
2716
2750
 
2717
2751
  const WebChat = class {