@natoe/colab 0.1.11 → 0.1.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/dist/index.mjs CHANGED
@@ -569,7 +569,11 @@ function buildChannelName(patientData) {
569
569
  const patientPart = patientData.patientName?.trim() || "Unknown";
570
570
  const labPart = patientData.labName?.trim()?.slice(0, 24) || "";
571
571
  const last4 = (patientData.displayOrderId ?? "").trim().slice(-4) || "0000";
572
- return `${patientPart} - ${labPart} - ${last4}`;
572
+ return labPart ? `${patientPart} - ${labPart} - ${last4}` : `${patientPart} - ${last4}`;
573
+ }
574
+ function cleanChannelName(name) {
575
+ if (!name) return "";
576
+ return name.replace(/\s+-\s+-\s+/g, " - ").trim();
573
577
  }
574
578
 
575
579
  // src/hooks/useConversation.ts
@@ -604,8 +608,11 @@ function useConversation({
604
608
  const ensureConversationInFlight = useRef(null);
605
609
  const markedReadIdsRef = useRef(/* @__PURE__ */ new Set());
606
610
  const buildName = useCallback(
607
- () => buildChannelName(patientData),
608
- [patientData]
611
+ () => {
612
+ const labName = patientData.labName ?? (config.userRole === "lab" ? config.userName : void 0);
613
+ return buildChannelName({ ...patientData, labName });
614
+ },
615
+ [patientData, config.userRole, config.userName]
609
616
  );
610
617
  const joinChannel = useCallback(
611
618
  (conv) => {
@@ -1295,7 +1302,7 @@ var Z_INDEX = {
1295
1302
  function resolveDisplayName(patientData, displayName) {
1296
1303
  const localComplete = !!patientData.labName && !!patientData.displayOrderId;
1297
1304
  if (localComplete) return buildChannelName(patientData);
1298
- return displayName ?? buildChannelName(patientData);
1305
+ return cleanChannelName(displayName) || buildChannelName(patientData);
1299
1306
  }
1300
1307
  function PatientHeader({
1301
1308
  patientData,
@@ -3760,6 +3767,7 @@ function CollabPanel({
3760
3767
  showSeenBy = true,
3761
3768
  onBack,
3762
3769
  hidePatientName = false,
3770
+ onConversationChange,
3763
3771
  className,
3764
3772
  style
3765
3773
  }) {
@@ -3788,6 +3796,9 @@ function CollabPanel({
3788
3796
  pinMessage,
3789
3797
  unpinMessage
3790
3798
  } = useConversation({ orderId, patientData, participantIds });
3799
+ useEffect(() => {
3800
+ onConversationChange?.(conversation);
3801
+ }, [conversation, onConversationChange]);
3791
3802
  const channelSettings = useChannelSettings({
3792
3803
  conversationId: conversation?.id ?? null
3793
3804
  });
@@ -4009,10 +4020,12 @@ function CollabPopup({
4009
4020
  );
4010
4021
  const [isDragging, setIsDragging] = useState(false);
4011
4022
  const [isMinimized, setIsMinimized] = useState(false);
4023
+ const [loadedConversation, setLoadedConversation] = useState(null);
4012
4024
  const dragOffset = useRef({ x: 0, y: 0 });
4013
4025
  const containerRef = useRef(null);
4014
4026
  const previouslyFocused = useRef(null);
4015
4027
  const titleId = useId();
4028
+ const titleText = cleanChannelName(loadedConversation?.name) || buildChannelName(patientData);
4016
4029
  const handleMouseDown = useCallback(
4017
4030
  (e) => {
4018
4031
  if (!e.target.closest("[data-drag-handle]")) return;
@@ -4116,7 +4129,7 @@ function CollabPopup({
4116
4129
  children: "\u2190"
4117
4130
  }
4118
4131
  ),
4119
- /* @__PURE__ */ jsx("span", { id: titleId, style: { ...styles13.titleText, flex: 1 }, children: buildChannelName(patientData) }),
4132
+ /* @__PURE__ */ jsx("span", { id: titleId, style: { ...styles13.titleText, flex: 1 }, children: titleText }),
4120
4133
  /* @__PURE__ */ jsxs("div", { style: styles13.titleActions, children: [
4121
4134
  /* @__PURE__ */ jsx(
4122
4135
  "button",
@@ -4142,7 +4155,16 @@ function CollabPopup({
4142
4155
  )
4143
4156
  ] })
4144
4157
  ] }),
4145
- !isMinimized && /* @__PURE__ */ jsx("div", { style: styles13.panelWrapper, children: /* @__PURE__ */ jsx(CollabPanel, { orderId, patientData, participantIds, hidePatientName: true }) })
4158
+ !isMinimized && /* @__PURE__ */ jsx("div", { style: styles13.panelWrapper, children: /* @__PURE__ */ jsx(
4159
+ CollabPanel,
4160
+ {
4161
+ orderId,
4162
+ patientData,
4163
+ participantIds,
4164
+ hidePatientName: true,
4165
+ onConversationChange: setLoadedConversation
4166
+ }
4167
+ ) })
4146
4168
  ]
4147
4169
  }
4148
4170
  );