@droppii-org/chat-sdk 0.6.23 → 0.6.24

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ConversationDetailInput.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-detail/ConversationDetailInput.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAmB/D,MAAM,WAAW,4BAA4B;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,QAAA,MAAM,uBAAuB,GAAI,4EAM9B,4BAA4B,4CAorB9B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"ConversationDetailInput.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-detail/ConversationDetailInput.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAmB/D,MAAM,WAAW,4BAA4B;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,QAAA,MAAM,uBAAuB,GAAI,4EAM9B,4BAA4B,4CAurB9B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -97,11 +97,15 @@ const ConversationDetailInput = ({ placeholder, onSendMessage, onInputChange, mo
97
97
  const [dismissedTriggerStart, setDismissedTriggerStart] = useState(null);
98
98
  // 1v1 threads have no groupID — mentions are a group-only concept
99
99
  // (matches CRM's MentionMenu, which already guards on the same field).
100
+ // Bot threads don't support tagging at all — not just CS staff filtering
101
+ // (DROPPII-30799 follow-up): the whole trigger is suppressed, same as
102
+ // groupless 1v1 threads.
100
103
  const mentionTrigger = !(conversationData === null || conversationData === void 0 ? void 0 : conversationData.groupID) ||
104
+ isBotPeer(conversationData) ||
101
105
  (rawMentionTrigger === null || rawMentionTrigger === void 0 ? void 0 : rawMentionTrigger.triggerStart) === dismissedTriggerStart
102
106
  ? null
103
107
  : rawMentionTrigger;
104
- const rawMentionOptions = useMentionOptions(conversationData === null || conversationData === void 0 ? void 0 : conversationData.groupID, (_a = mentionTrigger === null || mentionTrigger === void 0 ? void 0 : mentionTrigger.query) !== null && _a !== void 0 ? _a : "", conversationData ? isBotPeer(conversationData) : false);
108
+ const rawMentionOptions = useMentionOptions(conversationData === null || conversationData === void 0 ? void 0 : conversationData.groupID, (_a = mentionTrigger === null || mentionTrigger === void 0 ? void 0 : mentionTrigger.query) !== null && _a !== void 0 ? _a : "");
105
109
  const isMentionMenuOpen = mentionTrigger !== null;
106
110
  const [selectedMentionIndex, setSelectedMentionIndex] = useState(0);
107
111
  const { tokens: mentionTokens, addToken, onValueChange, resetTokens } = useMentionTokens();
@@ -1 +1 @@
1
- {"version":3,"file":"MentionMenu.d.ts","sourceRoot":"","sources":["../../../../../src/components/message/footer/mention/MentionMenu.tsx"],"names":[],"mappings":"AA8BA,eAAO,MAAM,qBAAqB,8BAA8B,CAAC;AAWjE,UAAU,gBAAgB;IACxB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAG5B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,QAAA,MAAM,WAAW,GAAI,0BAA0B,gBAAgB,mDAyI9D,CAAC;AA+CF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"MentionMenu.d.ts","sourceRoot":"","sources":["../../../../../src/components/message/footer/mention/MentionMenu.tsx"],"names":[],"mappings":"AA8BA,eAAO,MAAM,qBAAqB,8BAA8B,CAAC;AAWjE,UAAU,gBAAgB;IACxB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,QAAA,MAAM,WAAW,GAAI,0BAA0B,gBAAgB,mDA4I9D,CAAC;AA+CF,eAAe,WAAW,CAAC"}
@@ -41,7 +41,7 @@ const MentionMenu = ({ groupID, isBotThread }) => {
41
41
  const checkForMentionMatch = useBasicTypeaheadTriggerMatch("@", {
42
42
  minLength: 0,
43
43
  });
44
- const options = useMentionOptions(groupID, query !== null && query !== void 0 ? query : "", isBotThread);
44
+ const options = useMentionOptions(groupID, query !== null && query !== void 0 ? query : "");
45
45
  // Re-evaluated per query change (menu re-opens/re-queries on every "@"),
46
46
  // so this stays in sync with mentions added/removed since the last count.
47
47
  const mentionedUserIDs = useMemo(() => editor.getEditorState().read(() => $getMentionedUserIDs($getRoot())), [editor, query]);
@@ -71,7 +71,10 @@ const MentionMenu = ({ groupID, isBotThread }) => {
71
71
  });
72
72
  closeMenu();
73
73
  }, [editor]);
74
- if (!groupID)
74
+ // Bot threads don't support tagging at all, not just CS-staff filtering
75
+ // (DROPPII-30799 follow-up) — the whole trigger is suppressed, same as
76
+ // groupless 1v1 threads.
77
+ if (!groupID || isBotThread)
75
78
  return null;
76
79
  return (_jsx(LexicalTypeaheadMenuPlugin, { onQueryChange: setQuery, onSelectOption: onSelectOption, onOpen: () => setIsMentionMenuOpen(true), onClose: () => setIsMentionMenuOpen(false), triggerFn: checkForMentionMatch, options: typeaheadOptions, menuRenderFn: (anchorElementRef, { selectedIndex, setHighlightedIndex, selectOptionAndCleanUp }) => {
77
80
  if (!anchorElementRef.current)
@@ -5,5 +5,5 @@ export interface MentionOption {
5
5
  isAtAll: boolean;
6
6
  }
7
7
  export declare const ALL_MEMBERS_USER_ID = "__all__";
8
- export declare const useMentionOptions: (groupID: string | undefined, query: string, excludeStaff?: boolean) => MentionOption[];
8
+ export declare const useMentionOptions: (groupID: string | undefined, query: string) => MentionOption[];
9
9
  //# sourceMappingURL=useMentionOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMentionOptions.d.ts","sourceRoot":"","sources":["../../../../../src/components/message/footer/mention/useMentionOptions.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,mBAAmB,YAAY,CAAC;AA0B7C,eAAO,MAAM,iBAAiB,GAC5B,SAAS,MAAM,GAAG,SAAS,EAC3B,OAAO,MAAM,EAIb,sBAAoB,KACnB,aAAa,EA+Df,CAAC"}
1
+ {"version":3,"file":"useMentionOptions.d.ts","sourceRoot":"","sources":["../../../../../src/components/message/footer/mention/useMentionOptions.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAe7C,eAAO,MAAM,iBAAiB,GAC5B,SAAS,MAAM,GAAG,SAAS,EAC3B,OAAO,MAAM,KACZ,aAAa,EAyCf,CAAC"}
@@ -1,10 +1,7 @@
1
- import { useEffect, useMemo } from "react";
1
+ import { useMemo } from "react";
2
2
  import { useTranslation } from "react-i18next";
3
3
  import { useGroupMembers } from "../../../../hooks/group/useGroupMembers";
4
4
  import useAuthStore from "../../../../store/auth";
5
- import useUsersInfoStore from "../../../../store/usersInfo";
6
- import { DChatSDK } from "../../../../constants/sdk";
7
- import { AccountType } from "../../../../types/chat";
8
5
  export const ALL_MEMBERS_USER_ID = "__all__";
9
6
  // Prefix matches rank above mid-string matches, then alphabetical — matches
10
7
  // the "closest match first" ranking spec'd for this feature (not just a
@@ -15,52 +12,20 @@ const matchRank = (displayName, keyword) => {
15
12
  return 0;
16
13
  return 1;
17
14
  };
18
- // Mirrors useCurrentUserAccountType's parsing of the same ex-encoded field.
19
- // Takes the account-level `ex` (PublicUserItem, from getUsersInfo) — NOT
20
- // GroupMemberItem.ex, which is a separate per-membership field that never
21
- // carries accountType.
22
- const isStaffMember = (ex) => {
23
- var _a, _b, _c;
24
- try {
25
- return (((_c = (_b = (_a = JSON.parse(ex || "{}")) === null || _a === void 0 ? void 0 : _a.userInfo) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.accountType) === AccountType.Staff);
26
- }
27
- catch (_d) {
28
- return false;
29
- }
30
- };
31
- export const useMentionOptions = (groupID, query,
32
- // Bot threads shouldn't surface CS/staff accounts as tag targets — they
33
- // aren't part of the customer-facing conversation. Real member-managed
34
- // groups have no such restriction (DROPPII-30799).
35
- excludeStaff = false) => {
15
+ // Bot threads don't reach this hook at all — both mention triggers
16
+ // (ConversationDetailInput, MentionMenu) suppress the trigger entirely for
17
+ // bot peers (DROPPII-30799 follow-up), so there's no staff-filtering concern
18
+ // left to handle here.
19
+ export const useMentionOptions = (groupID, query) => {
36
20
  const { t } = useTranslation();
37
21
  const { members } = useGroupMembers(groupID);
38
22
  const currentUserID = useAuthStore((state) => state.userID);
39
- const usersInfo = useUsersInfoStore((state) => state.usersInfo);
40
- // Only fetch when actually needed: bot threads (excludeStaff) require the
41
- // account-level accountType, which GroupMemberItem.ex doesn't carry.
42
- useEffect(() => {
43
- if (!excludeStaff || members.length === 0)
44
- return;
45
- const { usersInfo: cache, upsertUsers } = useUsersInfoStore.getState();
46
- const missingIds = members
47
- .map((member) => member.userID)
48
- .filter((userID) => !cache[userID]);
49
- if (missingIds.length === 0)
50
- return;
51
- DChatSDK.getUsersInfo(missingIds)
52
- .then(({ data }) => upsertUsers(data))
53
- .catch((error) => {
54
- console.error("Error fetching mention candidates' user info:", error);
55
- });
56
- }, [excludeStaff, members]);
57
23
  return useMemo(() => {
58
24
  const keyword = query.trim().toLowerCase();
59
25
  // Self-tagging isn't a useful mention target — the sender already
60
26
  // knows who they are — so the current user is filtered out entirely.
61
27
  const memberOptions = members
62
28
  .filter((member) => member.userID !== currentUserID)
63
- .filter((member) => { var _a; return !excludeStaff || !isStaffMember((_a = usersInfo[member.userID]) === null || _a === void 0 ? void 0 : _a.ex); })
64
29
  .map((member) => ({
65
30
  userID: member.userID,
66
31
  displayName: member.nickname || member.userID,
@@ -83,5 +48,5 @@ excludeStaff = false) => {
83
48
  };
84
49
  const matchesAll = !keyword || allOption.displayName.toLowerCase().includes(keyword);
85
50
  return matchesAll ? [allOption, ...memberOptions] : memberOptions;
86
- }, [members, query, t, currentUserID, excludeStaff, usersInfo]);
51
+ }, [members, query, t, currentUserID]);
87
52
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@droppii-org/chat-sdk",
3
- "version": "0.6.23",
3
+ "version": "0.6.24",
4
4
  "description": "Droppii React Chat SDK",
5
5
  "repository": {
6
6
  "type": "git",