@natoe/colab 0.1.28 → 0.1.31

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
@@ -885,6 +885,7 @@ function cleanChannelName(name) {
885
885
  // src/hooks/useConversation.ts
886
886
  function useConversation({
887
887
  orderId,
888
+ conversation: providedConversation,
888
889
  patientData,
889
890
  participantIds = [],
890
891
  loadHistory = true,
@@ -917,6 +918,7 @@ function useConversation({
917
918
  const markedReadIdsRef = useRef(/* @__PURE__ */ new Set());
918
919
  const buildName = useCallback(
919
920
  () => {
921
+ if (!patientData) return "";
920
922
  const labName = patientData.labName ?? (config.userRole === "lab" ? config.userName : void 0);
921
923
  return buildChannelName({ ...patientData, labName });
922
924
  },
@@ -1016,6 +1018,28 @@ function useConversation({
1016
1018
  setIsLoading(true);
1017
1019
  setError(null);
1018
1020
  try {
1021
+ if (providedConversation) {
1022
+ setConversation(providedConversation);
1023
+ setParticipants(providedConversation.participants ?? []);
1024
+ joinChannel(providedConversation);
1025
+ if (loadHistory) {
1026
+ const history = await fetchMessages(providedConversation.id);
1027
+ if (cancelled) return;
1028
+ setMessages(history);
1029
+ setHasMore(history.length >= MESSAGES_PAGE_SIZE);
1030
+ setPinnedMessages(history.filter((m) => m.isPinned));
1031
+ }
1032
+ if (!cancelled) setIsLoading(false);
1033
+ return;
1034
+ }
1035
+ if (!orderId) {
1036
+ setConversation(null);
1037
+ setMessages([]);
1038
+ setParticipants([]);
1039
+ setHasMore(false);
1040
+ setIsLoading(false);
1041
+ return;
1042
+ }
1019
1043
  const preview = await requestPreview(orderId, kind);
1020
1044
  if (cancelled) return;
1021
1045
  if (!preview) {
@@ -1077,6 +1101,12 @@ function useConversation({
1077
1101
  const ensureConversation = useCallback(
1078
1102
  async (payload) => {
1079
1103
  if (conversation) return { conv: conversation, persistedByCreate: false };
1104
+ if (!orderId) {
1105
+ throw {
1106
+ code: "NO_CONVERSATION",
1107
+ message: "This conversation is not available yet. Please reopen it and try again."
1108
+ };
1109
+ }
1080
1110
  if (ensureConversationInFlight.current) {
1081
1111
  const conv = await ensureConversationInFlight.current;
1082
1112
  return { conv, persistedByCreate: false };
@@ -1564,15 +1594,19 @@ function PatientHeader({
1564
1594
  onBack,
1565
1595
  hideName = false,
1566
1596
  displayName,
1597
+ isSupportChannel = false,
1567
1598
  className
1568
1599
  }) {
1569
- const hasDicom = !!(patientData.studyId && patientData.storageId);
1570
- const resolvedName = resolveDisplayName(patientData, displayName);
1600
+ const hasDicom = !isSupportChannel && !!(patientData.studyId && patientData.storageId);
1601
+ const resolvedName = isSupportChannel ? displayName || patientData.patientName || "Natoe Support" : resolveDisplayName(patientData, displayName);
1571
1602
  const metaParts = [];
1572
- if (patientData.patientAge) metaParts.push(String(patientData.patientAge));
1573
- if (patientData.patientSex) metaParts.push(String(patientData.patientSex));
1574
- if (patientData.studyType) metaParts.push(patientData.studyType);
1575
- if (patientData.bodyParts && patientData.bodyParts.length > 0) {
1603
+ if (isSupportChannel) {
1604
+ metaParts.push("Help and support");
1605
+ }
1606
+ if (!isSupportChannel && patientData.patientAge) metaParts.push(String(patientData.patientAge));
1607
+ if (!isSupportChannel && patientData.patientSex) metaParts.push(String(patientData.patientSex));
1608
+ if (!isSupportChannel && patientData.studyType) metaParts.push(patientData.studyType);
1609
+ if (!isSupportChannel && patientData.bodyParts && patientData.bodyParts.length > 0) {
1576
1610
  metaParts.push(patientData.bodyParts.join(", "));
1577
1611
  }
1578
1612
  const hasPrimaryActions = hasDicom && onOpenDicom || onOpenCase;
@@ -4529,6 +4563,7 @@ var DARK_THEME_OVERRIDES = {
4529
4563
  };
4530
4564
  function CollabPanel({
4531
4565
  orderId,
4566
+ conversation: providedConversation,
4532
4567
  patientData,
4533
4568
  participantIds,
4534
4569
  kind,
@@ -4570,7 +4605,13 @@ function CollabPanel({
4570
4605
  loadMoreMessages,
4571
4606
  pinMessage,
4572
4607
  unpinMessage
4573
- } = useConversation({ orderId, patientData, participantIds, kind });
4608
+ } = useConversation({
4609
+ orderId,
4610
+ conversation: providedConversation,
4611
+ patientData,
4612
+ participantIds,
4613
+ kind
4614
+ });
4574
4615
  useEffect(() => {
4575
4616
  onConversationChange?.(conversation);
4576
4617
  }, [conversation, onConversationChange]);
@@ -4579,11 +4620,11 @@ function CollabPanel({
4579
4620
  });
4580
4621
  const { handleDeepLink } = useDeepLinks();
4581
4622
  const handleOpenDicom = () => {
4582
- if (patientData.studyId && patientData.storageId && config.onOpenDicom) {
4623
+ if (patientData?.studyId && patientData.storageId && config.onOpenDicom) {
4583
4624
  config.onOpenDicom(patientData.studyId, patientData.storageId);
4584
4625
  }
4585
4626
  };
4586
- const handleOpenCase = !hideOpenCase && config.onOpenCase ? () => config.onOpenCase?.(patientData.orderId, patientData.displayOrderId) : void 0;
4627
+ const handleOpenCase = !hideOpenCase && config.onOpenCase && patientData?.orderId ? () => config.onOpenCase?.(patientData.orderId, patientData.displayOrderId) : void 0;
4587
4628
  const handleJumpToMessage = (messageId) => {
4588
4629
  messageListRef.current?.scrollToMessage(messageId);
4589
4630
  };
@@ -4656,7 +4697,8 @@ function CollabPanel({
4656
4697
  /* @__PURE__ */ jsx(
4657
4698
  PatientHeader,
4658
4699
  {
4659
- patientData,
4700
+ patientData: patientData ?? { orderId: "", patientName: conversation?.name ?? "Natoe Support" },
4701
+ isSupportChannel: !patientData,
4660
4702
  participants,
4661
4703
  onOpenDicom: handleOpenDicom,
4662
4704
  onOpenCase: handleOpenCase,
@@ -4787,6 +4829,7 @@ ensureGlobalStyles();
4787
4829
  var FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';
4788
4830
  function CollabPopup({
4789
4831
  orderId,
4832
+ conversation: providedConversation,
4790
4833
  patientData,
4791
4834
  participantIds,
4792
4835
  kind,
@@ -4813,7 +4856,7 @@ function CollabPopup({
4813
4856
  const containerRef = useRef(null);
4814
4857
  const previouslyFocused = useRef(null);
4815
4858
  const titleId = useId();
4816
- const titleText = cleanChannelName(loadedConversation?.name) || buildChannelName(patientData);
4859
+ const titleText = cleanChannelName(loadedConversation?.name) || (patientData ? buildChannelName(patientData) : "Natoe Support");
4817
4860
  const handleMouseDown = useCallback(
4818
4861
  (e) => {
4819
4862
  if (!e.target.closest("[data-drag-handle]")) return;
@@ -4918,8 +4961,9 @@ function CollabPopup({
4918
4961
  }
4919
4962
  ),
4920
4963
  /* @__PURE__ */ jsxs("div", { style: styles13.titleCenter, children: [
4921
- /* @__PURE__ */ jsx("h2", { id: titleId, style: styles13.patientName, children: patientData.patientName || titleText }),
4964
+ /* @__PURE__ */ jsx("h2", { id: titleId, style: styles13.patientName, children: patientData?.patientName || titleText }),
4922
4965
  (() => {
4966
+ if (!patientData) return /* @__PURE__ */ jsx("div", { style: styles13.subRow, children: /* @__PURE__ */ jsx("span", { style: styles13.metaText, children: "Help and support" }) });
4923
4967
  const parts = [];
4924
4968
  if (patientData.patientAge) parts.push(String(patientData.patientAge));
4925
4969
  if (patientData.patientSex) parts.push(String(patientData.patientSex));
@@ -4976,6 +5020,7 @@ function CollabPopup({
4976
5020
  CollabPanel,
4977
5021
  {
4978
5022
  orderId,
5023
+ conversation: providedConversation,
4979
5024
  patientData,
4980
5025
  participantIds,
4981
5026
  kind,
@@ -5895,7 +5940,10 @@ function useConversationList(options) {
5895
5940
 
5896
5941
  // src/core/types.ts
5897
5942
  function isHelpKind(kind) {
5898
- return kind === "help_lab" || kind === "help_radiologist";
5943
+ return kind === "help_lab";
5944
+ }
5945
+ function isCaseKind(kind) {
5946
+ return kind === void 0 || kind === "case";
5899
5947
  }
5900
5948
  function ConversationListItem({
5901
5949
  item,
@@ -6531,6 +6579,7 @@ function CollabInbox({
6531
6579
  );
6532
6580
  }
6533
6581
  function buildPatientData(item) {
6582
+ if (isHelpKind(item.kind) || !item.orderId) return void 0;
6534
6583
  const parsed = parseChannelName(item.name, item.orderId);
6535
6584
  if (item.patientSnapshot) {
6536
6585
  return {
@@ -6837,6 +6886,6 @@ function usePinnedMessages({
6837
6886
  };
6838
6887
  }
6839
6888
 
6840
- export { AUDIO_MIME_TYPE, ChannelSettings, CollabInbox, CollabInline, CollabPanel, CollabPopup, CollabProvider, CollabSocket, ConversationList, ConversationListItem, DEEP_LINK_PREFIX, EVENTS, MAX_FILE_SIZE, MAX_PINNED_MESSAGES, MESSAGES_PAGE_SIZE, MESSAGE_TYPES, MessageActionsMenu, MessageBubble, MessageInput, MessageList, ParticipantsList, PatientHeader, PinnedMessagesBar, ReplyPreview, ReplyQuoteBlock, SUPPORTED_IMAGE_TYPES, SeenByIndicator, THEME_DEFAULTS, THEME_VAR, TYPING_DEBOUNCE_MS, applyThemeOverrides, isHelpKind, useAudioRecorder, useChannelSettings, useCollab, useConversation, useConversationList, useDeepLinks, useInlineCollab, useMessages, usePinnedMessages, useUnreadCount };
6889
+ export { AUDIO_MIME_TYPE, ChannelSettings, CollabInbox, CollabInline, CollabPanel, CollabPopup, CollabProvider, CollabSocket, ConversationList, ConversationListItem, DEEP_LINK_PREFIX, EVENTS, MAX_FILE_SIZE, MAX_PINNED_MESSAGES, MESSAGES_PAGE_SIZE, MESSAGE_TYPES, MessageActionsMenu, MessageBubble, MessageInput, MessageList, ParticipantsList, PatientHeader, PinnedMessagesBar, ReplyPreview, ReplyQuoteBlock, SUPPORTED_IMAGE_TYPES, SeenByIndicator, THEME_DEFAULTS, THEME_VAR, TYPING_DEBOUNCE_MS, applyThemeOverrides, isCaseKind, isHelpKind, useAudioRecorder, useChannelSettings, useCollab, useConversation, useConversationList, useDeepLinks, useInlineCollab, useMessages, usePinnedMessages, useUnreadCount };
6841
6890
  //# sourceMappingURL=index.mjs.map
6842
6891
  //# sourceMappingURL=index.mjs.map