@cometchat/chat-uikit-react-native 5.4.1 → 5.5.0

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.
Files changed (80) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/7.4/gc.properties +0 -0
  5. package/android/.gradle/vcs-1/gc.properties +0 -0
  6. package/android/src/main/java/com/reactnativecometchatuikit/CometChatClipboardModule.kt +34 -0
  7. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +542 -5
  8. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +20 -1
  9. package/ios/CometChatClipboardModule.m +5 -0
  10. package/ios/CometChatClipboardModule.swift +22 -0
  11. package/ios/RichTextEditorView.swift +593 -31
  12. package/ios/RichTextEditorViewManager.m +2 -0
  13. package/ios/RichTextEditorViewManager.swift +16 -0
  14. package/package.json +1 -1
  15. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +245 -55
  16. package/src/CometChatCompactMessageComposer/index.ts +2 -0
  17. package/src/CometChatConversations/CometChatConversations.tsx +291 -14
  18. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +181 -12
  19. package/src/CometChatMessageList/CometChatMessageList.tsx +568 -15
  20. package/src/CometChatMessageList/MANUAL_TEST_CASES.md +154 -0
  21. package/src/CometChatMessageList/components/MessageModals.tsx +30 -0
  22. package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +14 -1
  23. package/src/CometChatMessageList/components/MessageQuickActions.tsx +162 -0
  24. package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +940 -0
  25. package/src/CometChatPinnedMessages/index.ts +5 -0
  26. package/src/CometChatPinnedMessages/style.ts +216 -0
  27. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +5 -0
  28. package/src/CometChatRichTextEditor/index.tsx +27 -1
  29. package/src/CometChatRichTextEditor/types.ts +19 -1
  30. package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +634 -0
  31. package/src/CometChatSavedMessages/index.ts +5 -0
  32. package/src/CometChatSavedMessages/style.ts +159 -0
  33. package/src/CometChatSearch/CometChatSearch.tsx +47 -340
  34. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +22 -2
  35. package/src/index.ts +60 -0
  36. package/src/shared/CometChatUiKit/CometChatUIKit.ts +16 -0
  37. package/src/shared/base/Types.ts +5 -0
  38. package/src/shared/constants/UIKitConstants.ts +13 -0
  39. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +34 -0
  40. package/src/shared/events/CometChatUIEventHandler/Listener.ts +37 -0
  41. package/src/shared/events/ListenerInitializer.ts +20 -1
  42. package/src/shared/events/messages.ts +18 -0
  43. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +92 -6
  44. package/src/shared/formatters/index.ts +14 -0
  45. package/src/shared/formatters/richTextWireFormat.ts +165 -0
  46. package/src/shared/framework/MessageDataSource.tsx +296 -3
  47. package/src/shared/icons/components/thread-follow.tsx +13 -0
  48. package/src/shared/icons/components/thread-unfollow.tsx +13 -0
  49. package/src/shared/icons/components/unsave.tsx +13 -0
  50. package/src/shared/icons/icon-mapping.tsx +6 -0
  51. package/src/shared/index.ts +37 -0
  52. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +54 -0
  53. package/src/shared/utils/MarkdownUtils.ts +25 -4
  54. package/src/shared/utils/MessageUtils.tsx +80 -5
  55. package/src/shared/utils/PinConversationHelper.ts +245 -0
  56. package/src/shared/utils/PinSaveFeatureGates.ts +178 -0
  57. package/src/shared/utils/PinSaveHelper.ts +549 -0
  58. package/src/shared/utils/SavedMessagesHelper.ts +231 -0
  59. package/src/shared/utils/ThreadSubscriptionHelper.ts +427 -0
  60. package/src/shared/utils/conversationUtils.ts +8 -1
  61. package/src/shared/utils/stripRichText.ts +7 -0
  62. package/src/shared/views/ClipboardPasteHandler/ClipboardPasteHandler.ts +21 -0
  63. package/src/shared/views/ClipboardPasteHandler/NativeCometChatClipboardModule.ts +6 -0
  64. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +4 -0
  65. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +17 -5
  66. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +1 -0
  67. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +2 -0
  68. package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +91 -20
  69. package/src/shared/views/CometChatList/CometChatList.tsx +6 -1
  70. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +4 -0
  71. package/src/shared/views/CometChatRetryButton/CometChatRetryButton.tsx +1 -0
  72. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +4 -0
  73. package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +4 -1
  74. package/src/theme/default/default.ts +6 -0
  75. package/src/theme/type.ts +4 -0
  76. package/src/CometChatMessageList/PERFORMANCE_ARCHITECTURE.md +0 -478
  77. package/src/CometChatMessageList/SEARCH_NAV_PERF_PLAN.md +0 -613
  78. package/src/CometChatMessageList/SEARCH_NAV_SLOWNESS_FINDINGS_AND_FIX.md +0 -313
  79. package/src/shared/CometChatUiKit/CometChatUIKit.changes.md +0 -76
  80. package/src/shared/CometChatUiKit/checkAuthSettings-review.md +0 -211
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Rich-text wire grammar — the on-the-wire representation of inline styles that
3
+ * both the composer (which *produces* it while editing) and the rich-text
4
+ * formatter (which *renders* it in the bubble) must agree on.
5
+ *
6
+ * This module is deliberately neutral: it belongs to neither side. The formatter
7
+ * is swappable/developer-supplied, so the composer must not import from it (or
8
+ * vice-versa) — both import the grammar from here instead, so the token spec
9
+ * lives in exactly one place and the two sides can never drift.
10
+ *
11
+ * Currently the only value-carrying inline style: text colour `<color=#rrggbb>…</color>`.
12
+ */
13
+
14
+ /** Opening tag prefix, e.g. `<color=#ff0000>`. */
15
+ export const COLOR_OPEN_TAG = '<color=';
16
+ /** Closing tag. */
17
+ export const COLOR_CLOSE_TAG = '</color>';
18
+
19
+ /**
20
+ * Valid colour attribute: `#rgb` or `#rrggbb` (case-insensitive).
21
+ * Anchored and non-global on purpose — a /g regex keeps lastIndex between
22
+ * .test() calls, which would silently let every other value through.
23
+ * 8-digit `#rrggbbaa` is rejected deliberately: a transparent run is an
24
+ * invisible-message vector.
25
+ */
26
+ export const HEX_COLOR_REGEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
27
+
28
+ /**
29
+ * Expands `#rgb` to `#rrggbb` and lowercases. Native always reports the active
30
+ * colour as 6-digit, so a 3-digit swatch would never compare equal to it.
31
+ */
32
+ export const normalizeHex = (hex: string): string => {
33
+ const lower = hex.toLowerCase();
34
+ if (lower.length !== 4) return lower;
35
+ return `#${lower[1]}${lower[1]}${lower[2]}${lower[2]}${lower[3]}${lower[3]}`;
36
+ };
37
+
38
+ /** Builds the opening tag for a hex colour, e.g. `openColorTag('#f00')` → `<color=#f00>`. */
39
+ export const openColorTag = (hex: string): string => `${COLOR_OPEN_TAG}${hex}>`;
40
+
41
+ /** Boundaries of a well-formed `<color=…>…</color>` run. */
42
+ export interface ColorTagMatch {
43
+ /** Validated, lowercased hex attribute. */
44
+ hex: string;
45
+ /** Index of the run's first content character (just after `>`). */
46
+ contentStart: number;
47
+ /** Index of the matching close tag (exclusive end of content). */
48
+ contentEnd: number;
49
+ /** Index just past the whole run (after `</color>`). */
50
+ endIndex: number;
51
+ }
52
+
53
+ /**
54
+ * Given `openIdx` pointing at a `<color=` open tag, return the run's boundaries,
55
+ * or `null` if the tag is malformed (no `>`), carries an invalid hex, or is
56
+ * unterminated. Depth-aware: `<color=#a>x<color=#b>y</color>z</color>` captures
57
+ * the whole outer run instead of stopping at the inner close tag.
58
+ */
59
+ export function matchColorTagAt(text: string, openIdx: number): ColorTagMatch | null {
60
+ const lower = text.toLowerCase();
61
+ if (!lower.startsWith(COLOR_OPEN_TAG, openIdx)) return null;
62
+
63
+ const attrStart = openIdx + COLOR_OPEN_TAG.length;
64
+ const attrEnd = text.indexOf('>', attrStart);
65
+ if (attrEnd < 0) return null;
66
+
67
+ const hex = text.substring(attrStart, attrEnd).trim().toLowerCase();
68
+ if (!HEX_COLOR_REGEX.test(hex)) return null;
69
+
70
+ const contentStart = attrEnd + 1;
71
+ let depth = 1;
72
+ let cursor = contentStart;
73
+ let contentEnd = -1;
74
+
75
+ while (cursor < lower.length) {
76
+ const nextClose = lower.indexOf(COLOR_CLOSE_TAG, cursor);
77
+ if (nextClose < 0) break;
78
+ const nextOpen = lower.indexOf(COLOR_OPEN_TAG, cursor);
79
+ if (nextOpen >= 0 && nextOpen < nextClose) {
80
+ depth++;
81
+ cursor = nextOpen + COLOR_OPEN_TAG.length;
82
+ continue;
83
+ }
84
+ depth--;
85
+ if (depth === 0) {
86
+ contentEnd = nextClose;
87
+ break;
88
+ }
89
+ cursor = nextClose + COLOR_CLOSE_TAG.length;
90
+ }
91
+
92
+ if (contentEnd < 0) return null;
93
+ return { hex, contentStart, contentEnd, endIndex: contentEnd + COLOR_CLOSE_TAG.length };
94
+ }
95
+
96
+ /**
97
+ * Find the first well-formed `<color=…>…</color>` run at or after `from`.
98
+ * Malformed, unterminated, or empty runs are skipped so one bad token can't
99
+ * disable colour for the rest of the text. Returns `null` if none.
100
+ */
101
+ export function findColorTag(
102
+ text: string,
103
+ from = 0
104
+ ): (ColorTagMatch & { startIndex: number }) | null {
105
+ const lower = text.toLowerCase();
106
+ let searchFrom = from;
107
+
108
+ while (searchFrom < lower.length) {
109
+ const openIdx = lower.indexOf(COLOR_OPEN_TAG, searchFrom);
110
+ if (openIdx < 0) return null;
111
+
112
+ const match = matchColorTagAt(text, openIdx);
113
+ if (!match) {
114
+ // Malformed / invalid hex / unterminated — skip past this open tag.
115
+ searchFrom = openIdx + COLOR_OPEN_TAG.length;
116
+ continue;
117
+ }
118
+ if (match.contentEnd === match.contentStart) {
119
+ // Empty run — skip the whole thing and keep scanning.
120
+ searchFrom = match.endIndex;
121
+ continue;
122
+ }
123
+ return { ...match, startIndex: openIdx };
124
+ }
125
+ return null;
126
+ }
127
+
128
+ /**
129
+ * Strips every `<color=…>` / `</color>` token, leaving the content. Used by the
130
+ * plain-text surfaces (search subtitles, AI history) that render raw strings and
131
+ * would otherwise show the markup to users.
132
+ *
133
+ * Deliberately removes tags even when unbalanced — a half-written token must never
134
+ * be shown to a user, and this is a display-only path.
135
+ */
136
+ export function stripColorTags(text: string): string {
137
+ if (!text) return text;
138
+ if (text.toLowerCase().indexOf(COLOR_OPEN_TAG) < 0 &&
139
+ text.toLowerCase().indexOf(COLOR_CLOSE_TAG) < 0) {
140
+ return text;
141
+ }
142
+ let out = '';
143
+ let cursor = 0;
144
+ const lower = text.toLowerCase();
145
+
146
+ while (cursor < text.length) {
147
+ const openIdx = lower.indexOf(COLOR_OPEN_TAG, cursor);
148
+ const closeIdx = lower.indexOf(COLOR_CLOSE_TAG, cursor);
149
+
150
+ // Whichever token comes first (either may be absent).
151
+ const next = openIdx < 0 ? closeIdx : closeIdx < 0 ? openIdx : Math.min(openIdx, closeIdx);
152
+ if (next < 0) break;
153
+
154
+ out += text.substring(cursor, next);
155
+ if (next === closeIdx && (openIdx < 0 || closeIdx < openIdx)) {
156
+ cursor = next + COLOR_CLOSE_TAG.length;
157
+ } else {
158
+ // Drop through to the tag's `>`; if there is none the rest is malformed markup.
159
+ const attrEnd = text.indexOf('>', next + COLOR_OPEN_TAG.length);
160
+ if (attrEnd < 0) return out;
161
+ cursor = attrEnd + 1;
162
+ }
163
+ }
164
+ return out + text.substring(cursor);
165
+ }
@@ -28,6 +28,11 @@ import { CometChatUiKitConstants } from "../index";
28
28
  import { CometChatMessageComposerAction } from "../helper/types";
29
29
  import { Icon, IconName } from "../icons/Icon";
30
30
  import { getMessagePreviewInternal } from "../utils/MessageUtils";
31
+ import { canPin, isPinned, isPinSaveEligible, isSaved, PinSaveConfig } from "../utils/PinSaveHelper";
32
+ import {
33
+ isThreadSubscribed,
34
+ ThreadSubscriptionConfig,
35
+ } from "../utils/ThreadSubscriptionHelper";
31
36
  import { CometChatMessageOption } from "../modals/CometChatMessageOption";
32
37
  import { CometChatMessageTemplate } from "../modals/CometChatMessageTemplate";
33
38
  import { CometChatConversationUtils, attachmentCountLabel } from "../utils/conversationUtils";
@@ -53,7 +58,8 @@ import { CometChatVideosBubble } from "../views/CometChatVideosBubble";
53
58
  import { CometChatFilesBubble } from "../views/CometChatFilesBubble";
54
59
  import { CometChatAudiosBubble } from "../views/CometChatAudiosBubble";
55
60
  import { CometChatVoiceNoteBubble } from "../views/CometChatVoiceNoteBubble";
56
- import Clipboard from "@react-native-clipboard/clipboard";
61
+ import { ClipboardPasteHandler } from "../views/ClipboardPasteHandler/ClipboardPasteHandler";
62
+ import { stripMarkdown } from "../utils/MarkdownUtils";
57
63
  import { getCometChatTranslation } from "../resources/CometChatLocalizeNew/LocalizationManager";
58
64
 
59
65
  const t = getCometChatTranslation();
@@ -197,8 +203,10 @@ export class MessageDataSource implements DataSource {
197
203
  messageData.content || "";
198
204
  }
199
205
 
206
+ // Clean plain text for every other app; colour preserved in a private representation
207
+ // that only our own composer reads back on paste.
200
208
  if (textToCopy?.trim()) {
201
- Clipboard.setString(textToCopy);
209
+ ClipboardPasteHandler.copyMessageText(textToCopy);
202
210
  }
203
211
  } catch (err) {
204
212
  console.error(err);
@@ -285,6 +293,137 @@ export class MessageDataSource implements DataSource {
285
293
  },
286
294
  };
287
295
  }
296
+ /**
297
+ * Pin / Unpin (§6.1). Two option ids rather than one that flips its title,
298
+ * because a consumer can legitimately hide one and not the other, and because
299
+ * the press handler needs to know which direction it is going without
300
+ * re-deriving state that may have changed since the sheet opened.
301
+ */
302
+ getPinOption(theme: CometChatTheme): CometChatMessageOption {
303
+ return {
304
+ id: MessageOptionConstants.pinMessage,
305
+ title: t("PIN_MESSAGE"),
306
+ icon: (
307
+ <Icon
308
+ name='keep'
309
+ color={
310
+ theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.tintColor
311
+ }
312
+ height={theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.height}
313
+ width={theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.width}
314
+ containerStyle={
315
+ theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconContainerStyle
316
+ }
317
+ ></Icon>
318
+ ),
319
+ };
320
+ }
321
+
322
+ getUnpinOption(theme: CometChatTheme): CometChatMessageOption {
323
+ return {
324
+ id: MessageOptionConstants.unpinMessage,
325
+ title: t("UNPIN_MESSAGE"),
326
+ icon: (
327
+ <Icon
328
+ name='keep-off'
329
+ color={
330
+ theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.tintColor
331
+ }
332
+ height={theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.height}
333
+ width={theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.width}
334
+ containerStyle={
335
+ theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconContainerStyle
336
+ }
337
+ ></Icon>
338
+ ),
339
+ };
340
+ }
341
+
342
+ /** Save / Unsave (§6.1). No role gate — a save is private to the acting user. */
343
+ getSaveOption(theme: CometChatTheme): CometChatMessageOption {
344
+ return {
345
+ id: MessageOptionConstants.saveMessage,
346
+ title: t("SAVE_MESSAGE"),
347
+ icon: (
348
+ <Icon
349
+ name='bookmark'
350
+ color={
351
+ theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.tintColor
352
+ }
353
+ height={theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.height}
354
+ width={theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.width}
355
+ containerStyle={
356
+ theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconContainerStyle
357
+ }
358
+ ></Icon>
359
+ ),
360
+ };
361
+ }
362
+
363
+ getUnsaveOption(theme: CometChatTheme): CometChatMessageOption {
364
+ return {
365
+ id: MessageOptionConstants.unsaveMessage,
366
+ title: t("UNSAVE_MESSAGE"),
367
+ icon: (
368
+ // Bookmark-with-a-cross, the design's own glyph for the unsave ACTION. Distinct from
369
+ // 'bookmark-fill', which stays the saved-STATE indicator beside the timestamp.
370
+ <Icon
371
+ name='unsave'
372
+ color={
373
+ theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.tintColor
374
+ }
375
+ height={theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.height}
376
+ width={theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.width}
377
+ containerStyle={
378
+ theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconContainerStyle
379
+ }
380
+ ></Icon>
381
+ ),
382
+ };
383
+ }
384
+
385
+ /**
386
+ * Pushes whichever of the pin/save pair applies to the message's CURRENT state.
387
+ * Shared by getTextMessageOptions and getCommonOptions so every eligible
388
+ * category gets the same four options in the same position — right after the
389
+ * message's own actions and before the destructive ones.
390
+ */
391
+ pushPinSaveOptions(
392
+ optionsList: CometChatMessageOption[],
393
+ loggedInUser: CometChat.User,
394
+ messageObject: CometChat.BaseMessage,
395
+ theme: CometChatTheme,
396
+ group?: CometChat.Group,
397
+ additionalParams?: AdditionalParams
398
+ ): void {
399
+ const pinned = isPinned(messageObject);
400
+ const saved = isSaved(messageObject);
401
+
402
+ if (
403
+ this.validateOption(
404
+ loggedInUser,
405
+ messageObject,
406
+ pinned ? MessageOptionConstants.unpinMessage : MessageOptionConstants.pinMessage,
407
+ group,
408
+ additionalParams
409
+ )
410
+ ) {
411
+ optionsList.push(pinned ? this.getUnpinOption(theme) : this.getPinOption(theme));
412
+ }
413
+
414
+ if (
415
+ this.validateOption(
416
+ loggedInUser,
417
+ messageObject,
418
+ saved ? MessageOptionConstants.unsaveMessage : MessageOptionConstants.saveMessage,
419
+ group,
420
+ additionalParams
421
+ )
422
+ ) {
423
+ optionsList.push(saved ? this.getUnsaveOption(theme) : this.getSaveOption(theme));
424
+ }
425
+ }
426
+
288
427
  getReplyOption(theme: CometChatTheme): CometChatMessageOption {
289
428
  return {
290
429
  id: MessageOptionConstants.replyMessage,
@@ -324,6 +463,41 @@ export class MessageDataSource implements DataSource {
324
463
  };
325
464
  }
326
465
 
466
+ /**
467
+ * Follow / unfollow the thread rooted at this message — "tell me when replies
468
+ * arrive here in future". One option id; the title flips on the current state.
469
+ *
470
+ * Deliberately NOT gated on replyCount: following a message before anyone has
471
+ * answered it is the whole point. Offered on a reply too — inside a thread the
472
+ * user reaches for the same control — and there it targets the PARENT thread,
473
+ * via getThreadIdFor, so no subscription is ever rooted at a reply id.
474
+ */
475
+ getThreadSubscriptionOption(
476
+ theme: CometChatTheme,
477
+ messageObject?: CometChat.BaseMessage
478
+ ): CometChatMessageOption {
479
+ const subscribed = messageObject ? isThreadSubscribed(messageObject) : false;
480
+ return {
481
+ id: MessageOptionConstants.threadSubscription,
482
+ title: subscribed
483
+ ? t("THREAD_SUBSCRIPTION_UNSUBSCRIBE")
484
+ : t("THREAD_SUBSCRIPTION_SUBSCRIBE"),
485
+ icon: (
486
+ <Icon
487
+ name={subscribed ? "notifications-off" : "notifications"}
488
+ color={
489
+ theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.tintColor
490
+ }
491
+ height={theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.height}
492
+ width={theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconStyle?.width}
493
+ containerStyle={
494
+ theme.messageListStyles.messageOptionsStyles?.optionsItemStyle?.iconContainerStyle
495
+ }
496
+ ></Icon>
497
+ ),
498
+ };
499
+ }
500
+
327
501
  getReportOption(theme: CometChatTheme): CometChatMessageOption {
328
502
  return {
329
503
  id: MessageOptionConstants.reportMessage,
@@ -474,6 +648,20 @@ export class MessageDataSource implements DataSource {
474
648
  messageOptionList.push(this.getReplyInThreadOption(theme));
475
649
  }
476
650
 
651
+ // follow / unfollow thread — placed straight after "Reply in thread" so the
652
+ // two thread actions sit together (§6.3, locked so five kits don't diverge)
653
+ if (
654
+ this.validateOption(
655
+ loggedInUser,
656
+ messageObject,
657
+ MessageOptionConstants.threadSubscription,
658
+ group,
659
+ additionalParams
660
+ )
661
+ ) {
662
+ messageOptionList.push(this.getThreadSubscriptionOption(theme, messageObject));
663
+ }
664
+
477
665
  // reply
478
666
  if (
479
667
  this.validateOption(
@@ -576,6 +764,17 @@ export class MessageDataSource implements DataSource {
576
764
  messageOptionList.push(this.getInformationOption(theme));
577
765
  }
578
766
 
767
+ // Before delete: pin/save are non-destructive, so they should not sit below
768
+ // the one option the user must not hit by accident.
769
+ this.pushPinSaveOptions(
770
+ messageOptionList,
771
+ loggedInUser,
772
+ messageObject,
773
+ theme,
774
+ group,
775
+ additionalParams
776
+ );
777
+
579
778
  if (
580
779
  this.validateOption(
581
780
  loggedInUser,
@@ -861,6 +1060,21 @@ export class MessageDataSource implements DataSource {
861
1060
  return true;
862
1061
  }
863
1062
 
1063
+ // Shown on a root message AND on a reply — inside a thread the user reaches for the
1064
+ // same control, so hiding it there is a dead end. On a reply it acts on the PARENT
1065
+ // thread (getThreadIdFor), which is what kept the old gate necessary: the server will
1066
+ // accept a subscription rooted at a reply id and write a /threads row nobody can open,
1067
+ // so the fix is to never send that id, not to hide the option.
1068
+ // NOT gated on replyCount either: following a message before anyone answers is the
1069
+ // entire point. Only the feature gate applies, and it is off until the integrator opts in.
1070
+ if (
1071
+ MessageOptionConstants.threadSubscription === optionId &&
1072
+ ThreadSubscriptionConfig.isEnabled() &&
1073
+ !additionalParams?.hideThreadSubscriptionOption
1074
+ ) {
1075
+ return true;
1076
+ }
1077
+
864
1078
  if (
865
1079
  MessageOptionConstants.shareMessage === optionId &&
866
1080
  (messageObject instanceof CometChat.TextMessage ||
@@ -936,6 +1150,58 @@ export class MessageDataSource implements DataSource {
936
1150
  return true;
937
1151
  }
938
1152
 
1153
+ // Pin / Unpin (§6.1, §6.5). Role-gated via canPin, which is NOT the delete
1154
+ // gate: delete also allows isSentByMe, but a participant may not pin their
1155
+ // own message — pinning is a conversation-wide act on shared state.
1156
+ //
1157
+ // Offered on a thread REPLY too (Q9). Unlike thread subscription there is no
1158
+ // parent-redirect here: a reply is pinned as itself, and the pinned list
1159
+ // returns the parent for context.
1160
+ // isPinSaveEligible gates all four: no server id yet, deleted, or any
1161
+ // moderation verdict. The backend refuses those outright, so offering the
1162
+ // option means walking the user through a confirm modal to earn an error
1163
+ // toast. Applies to save as well as pin — an unsent message has no id to
1164
+ // save against either.
1165
+ if (
1166
+ MessageOptionConstants.pinMessage === optionId &&
1167
+ PinSaveConfig.isPinEnabled() &&
1168
+ isPinSaveEligible(messageObject) &&
1169
+ canPin(loggedInUser, group) &&
1170
+ !additionalParams?.hidePinMessageOption
1171
+ ) {
1172
+ return true;
1173
+ }
1174
+
1175
+ if (
1176
+ MessageOptionConstants.unpinMessage === optionId &&
1177
+ PinSaveConfig.isPinEnabled() &&
1178
+ isPinSaveEligible(messageObject) &&
1179
+ canPin(loggedInUser, group) &&
1180
+ !additionalParams?.hideUnpinMessageOption
1181
+ ) {
1182
+ return true;
1183
+ }
1184
+
1185
+ // Save / Unsave (§6.1). No role gate at all — the save is private to this
1186
+ // user, so there is no shared state for a scope to protect.
1187
+ if (
1188
+ MessageOptionConstants.saveMessage === optionId &&
1189
+ PinSaveConfig.isSaveEnabled() &&
1190
+ isPinSaveEligible(messageObject) &&
1191
+ !additionalParams?.hideSaveMessageOption
1192
+ ) {
1193
+ return true;
1194
+ }
1195
+
1196
+ if (
1197
+ MessageOptionConstants.unsaveMessage === optionId &&
1198
+ PinSaveConfig.isSaveEnabled() &&
1199
+ isPinSaveEligible(messageObject) &&
1200
+ !additionalParams?.hideUnsaveMessageOption
1201
+ ) {
1202
+ return true;
1203
+ }
1204
+
939
1205
  return false;
940
1206
  }
941
1207
 
@@ -973,6 +1239,19 @@ export class MessageDataSource implements DataSource {
973
1239
  messageOptionList.push(this.getReplyInThreadOption(theme));
974
1240
  }
975
1241
 
1242
+ // follow / unfollow thread — same placement as the other assembler (§6.3)
1243
+ if (
1244
+ this.validateOption(
1245
+ loggedInUser,
1246
+ messageObject,
1247
+ MessageOptionConstants.threadSubscription,
1248
+ group,
1249
+ additionalParams
1250
+ )
1251
+ ) {
1252
+ messageOptionList.push(this.getThreadSubscriptionOption(theme, messageObject));
1253
+ }
1254
+
976
1255
  if (
977
1256
  this.validateOption(
978
1257
  loggedInUser,
@@ -997,6 +1276,16 @@ export class MessageDataSource implements DataSource {
997
1276
  messageOptionList.push(this.getInformationOption(theme));
998
1277
  }
999
1278
 
1279
+ // Same position as in getTextMessageOptions — above the destructive actions.
1280
+ this.pushPinSaveOptions(
1281
+ messageOptionList,
1282
+ loggedInUser,
1283
+ messageObject,
1284
+ theme,
1285
+ group,
1286
+ additionalParams
1287
+ );
1288
+
1000
1289
  if (
1001
1290
  this.validateOption(
1002
1291
  loggedInUser,
@@ -2451,7 +2740,11 @@ export class MessageDataSource implements DataSource {
2451
2740
  const count = isBatch ? batchTotalCount : (lastMessage.getAttachments?.() ?? []).length;
2452
2741
  if (count > 1) {
2453
2742
  const { icon, label } = kindPreview(lastMessage.getType(), count);
2454
- const caption = (lastMessage.getCaption?.() ?? '').trim();
2743
+ // Captions carry the same wire markup a text message does, and this branch returns a
2744
+ // JSX element — so the conversation list's own stripMarkdown pass, which only runs for
2745
+ // string subtitles, never sees it. Strip here or `<color=…>`/`**bold**` render verbatim
2746
+ // in the row (ENG-38258).
2747
+ const caption = stripMarkdown((lastMessage.getCaption?.() ?? '').trim()).trim();
2455
2748
  return getMessagePreviewInternal(icon, caption ? `${label} · ${caption}` : label, { theme });
2456
2749
  }
2457
2750
  }
@@ -0,0 +1,13 @@
1
+ import Svg, { Path } from "react-native-svg";
2
+ import type { SvgProps } from "react-native-svg";
3
+ // Followed state for the thread subscription control. Design's own 19x23 artboard, kept as the
4
+ // viewBox so the glyph is not re-scaled; `color` replaces the exported fill.
5
+ const SvgComponent = ({ height, width, color }: SvgProps) => (
6
+ <Svg width={width} height={height} fill='none' viewBox='0 0 19 23'>
7
+ <Path
8
+ fill={color}
9
+ d='M0.91875 19.4833C0.659556 19.4833 0.441583 19.3948 0.264833 19.2176C0.0882778 19.0403 0 18.8215 0 18.5614C0 18.301 0.0882778 18.0818 0.264833 17.9037C0.441583 17.7254 0.659556 17.6362 0.91875 17.6362H2.23621V9.17788C2.23621 7.55757 2.72057 6.10731 3.68929 4.82708C4.65801 3.54706 5.92521 2.72718 7.49088 2.36746V1.71033C7.49088 1.2353 7.65703 0.831541 7.98933 0.499041C8.32164 0.166347 8.72511 0 9.19975 0C9.67439 0 10.0786 0.166347 10.4125 0.499041C10.7464 0.831541 10.9133 1.2353 10.9133 1.71033V2.36746C12.4817 2.72718 13.7512 3.54706 14.7219 4.82708C15.6925 6.10731 16.1779 7.55757 16.1779 9.17788V17.6362H17.4904C17.7435 17.6362 17.9607 17.7264 18.142 17.9069C18.3232 18.0875 18.4138 18.3079 18.4138 18.5681C18.4138 18.8283 18.3239 19.0458 18.144 19.2208C17.9641 19.3958 17.7446 19.4833 17.4854 19.4833H0.91875ZM9.20208 22.9008C8.57014 22.9008 8.02978 22.6764 7.581 22.2276C7.13203 21.7787 6.90754 21.2382 6.90754 20.6063H11.4966C11.4966 21.2382 11.2721 21.7787 10.8232 22.2276C10.3744 22.6764 9.83403 22.9008 9.20208 22.9008ZM4.08333 17.6362H14.3305V9.17788C14.3305 7.76057 13.8294 6.55307 12.8272 5.55537C11.825 4.55787 10.6155 4.05912 9.19858 4.05912C7.78147 4.05912 6.57465 4.55787 5.57813 5.55537C4.5816 6.55307 4.08333 7.76057 4.08333 9.17788V17.6362Z'
10
+ />
11
+ </Svg>
12
+ );
13
+ export default SvgComponent;
@@ -0,0 +1,13 @@
1
+ import Svg, { Path } from "react-native-svg";
2
+ import type { SvgProps } from "react-native-svg";
3
+ // Un-followed state for the thread subscription control — the slash reads as "no reply
4
+ // notifications". 22x23 artboard (wider than thread-follow, the slash overhangs).
5
+ const SvgComponent = ({ height, width, color }: SvgProps) => (
6
+ <Svg width={width} height={height} fill='none' viewBox='0 0 22 23'>
7
+ <Path
8
+ fill={color}
9
+ d='M16.8487 19.4833H3.12083C2.85833 19.4833 2.63958 19.3958 2.46458 19.2208C2.28958 19.0458 2.20208 18.8271 2.20208 18.5646C2.20208 18.3021 2.28958 18.0818 2.46458 17.9037C2.63958 17.7254 2.85833 17.6362 3.12083 17.6362H4.43829V9.17788C4.43829 8.52979 4.5185 7.89221 4.67892 7.26512C4.83933 6.63804 5.09124 6.04255 5.43463 5.47867L6.81538 6.85912C6.64038 7.22215 6.50825 7.59908 6.419 7.98992C6.32994 8.38075 6.28542 8.77674 6.28542 9.17788V17.6362H15.0596L0.277083 2.89246C0.0923611 2.71415 0 2.50269 0 2.25808C0 2.01347 0.0907084 1.79715 0.272125 1.60912C0.453736 1.4211 0.667625 1.32631 0.913792 1.32475C1.16015 1.32319 1.37735 1.41312 1.56538 1.59454L21.2558 21.3045C21.4353 21.484 21.5242 21.6976 21.5227 21.9453C21.5209 22.193 21.4325 22.4078 21.2575 22.5896C21.073 22.7679 20.8576 22.857 20.6112 22.857C20.3648 22.857 20.1525 22.7679 19.9742 22.5896L16.8487 19.4833ZM13.1154 2.36746C14.6935 2.71415 15.9654 3.53043 16.9313 4.81629C17.8971 6.10215 18.38 7.55601 18.38 9.17788V13.5529C18.38 13.8624 18.2846 14.0946 18.0938 14.2494C17.9033 14.404 17.6918 14.4813 17.4595 14.4813C17.2273 14.4813 17.0148 14.4045 16.8219 14.2511C16.629 14.0975 16.5325 13.8664 16.5325 13.5578V9.17788C16.5325 7.76057 16.0317 6.55307 15.0299 5.55537C14.0279 4.55787 12.8193 4.05912 11.4042 4.05912C10.9245 4.05912 10.4586 4.12475 10.0065 4.256C9.55442 4.38725 9.13238 4.57605 8.74038 4.82242C8.49071 4.97797 8.22335 5.04437 7.93829 5.02162C7.65304 4.99887 7.42292 4.87482 7.24792 4.64946C7.08595 4.45365 7.00817 4.24151 7.01458 4.01304C7.021 3.78457 7.12474 3.59576 7.32579 3.44662C7.67677 3.19715 8.05127 2.98005 8.44929 2.79533C8.84752 2.61061 9.26207 2.46731 9.69296 2.36542V1.70946C9.69296 1.23501 9.85911 0.831541 10.1914 0.499041C10.5237 0.166347 10.9272 0 11.4018 0C11.8765 0 12.2807 0.166347 12.6146 0.499041C12.9484 0.831541 13.1154 1.2353 13.1154 1.71033V2.36746ZM11.4024 22.9008C10.8169 22.9008 10.299 22.733 9.84871 22.3974C9.39818 22.0618 9.17292 21.6159 9.17292 21.0598C9.17292 20.926 9.21929 20.817 9.31204 20.7328C9.40479 20.6484 9.52311 20.6063 9.667 20.6063H13.1513C13.286 20.6063 13.402 20.6484 13.4992 20.7328C13.5964 20.817 13.645 20.926 13.645 21.0598C13.645 21.6159 13.4176 22.0618 12.9628 22.3974C12.508 22.733 11.9879 22.9008 11.4024 22.9008Z'
10
+ />
11
+ </Svg>
12
+ );
13
+ export default SvgComponent;
@@ -0,0 +1,13 @@
1
+ import Svg, { Path } from "react-native-svg";
2
+ import type { SvgProps } from "react-native-svg";
3
+ // Unsave — a bookmark with a cross. The design's own 16x17 artboard, kept as the viewBox so the
4
+ // glyph is not re-scaled; `color` replaces the exported #252B37 fill so it follows the theme.
5
+ const SvgComponent = ({ height, width, color }: SvgProps) => (
6
+ <Svg width={width} height={height} fill='none' viewBox='0 0 16 17'>
7
+ <Path
8
+ fill={color}
9
+ d='M6.871 14.8L2.2125 16.7875C1.682 17.0152 1.18067 16.9733 0.7085 16.6618C0.236167 16.3501 0 15.9058 0 15.329V1.58325C0 1.15608 0.157167 0.785418 0.4715 0.471251C0.785667 0.157084 1.15633 0 1.5835 0H7.6125C7.82833 0 8.01358 0.0775833 8.16825 0.23275C8.32275 0.38775 8.4 0.573584 8.4 0.790251C8.4 1.01342 8.32275 1.20133 8.16825 1.354C8.01358 1.50683 7.82833 1.58325 7.6125 1.58325H1.5835V15.3333L6.86675 13.0805L12.15 15.3333V8.2875C12.15 8.07167 12.2274 7.88642 12.3823 7.73175C12.5369 7.57725 12.7244 7.5 12.9448 7.5C13.1649 7.5 13.3514 7.57725 13.5043 7.73175C13.6571 7.88642 13.7335 8.07167 13.7335 8.2875V15.329C13.7335 15.9058 13.4973 16.3501 13.025 16.6618C12.5528 16.9733 12.0542 17.0152 11.5293 16.7875L6.871 14.8ZM6.86675 1.58325H1.5835H8.4H6.86675ZM11.822 2.95825L10.8528 1.98898C10.6957 1.83189 10.6174 1.64409 10.6178 1.4256C10.6182 1.20722 10.6963 1.02013 10.8521 0.86433C11.0078 0.708649 11.1941 0.63128 11.4112 0.632222C11.6283 0.633165 11.8154 0.712185 11.9725 0.869281L12.9418 1.83855L13.9169 0.863447C14.0695 0.71083 14.2552 0.63458 14.4741 0.634698C14.6927 0.634816 14.8799 0.712774 15.0357 0.868573C15.1914 1.02425 15.2686 1.21075 15.2674 1.42807C15.2661 1.64551 15.1892 1.83053 15.0366 1.98315L14.0615 2.95825L15.0366 3.93335C15.1892 4.08597 15.2653 4.27182 15.2649 4.4909C15.2645 4.70987 15.1876 4.89596 15.0344 5.04917C14.8767 5.20685 14.6892 5.2851 14.4719 5.28392C14.2545 5.28263 14.0695 5.20567 13.9169 5.05305L12.9418 4.07795L11.9725 5.04722C11.8154 5.20432 11.6275 5.28251 11.4087 5.2818C11.19 5.2811 11.004 5.20414 10.8508 5.05093C10.6931 4.89325 10.6148 4.70586 10.6157 4.48878C10.6167 4.2717 10.6957 4.08461 10.8528 3.92752L11.822 2.95825Z'
10
+ />
11
+ </Svg>
12
+ );
13
+ export default SvgComponent;
@@ -268,6 +268,8 @@ import rightArrow from "./components/right-arrow";
268
268
  import Sunny from "./components/sunny";
269
269
  import SunnyFill from "./components/sunny-fill";
270
270
  import Symbols from "./components/symbols";
271
+ import ThreadFollow from "./components/thread-follow";
272
+ import ThreadUnfollow from "./components/thread-unfollow";
271
273
  import ThumbDown from "./components/thumb-down";
272
274
  import ThumbDownFill from "./components/thumb-down-fill";
273
275
  import ThumbUp from "./components/thumb-up";
@@ -322,6 +324,7 @@ import AIChatHistory from "./components/ai-chat-history";
322
324
  import AICopyOption from "./components/ai-copy-option";
323
325
  import EmptySearch from "./components/empty-search";
324
326
  import Unread from "./components/unread";
327
+ import Unsave from "./components/unsave";
325
328
  import DocumentIcon from "./components/documents";
326
329
 
327
330
  import MessageBlocked from "./components/message-blocked";
@@ -588,6 +591,8 @@ export const ICONS = {
588
591
  "right-arrow": rightArrow,
589
592
  sunny: Sunny,
590
593
  "sunny-fill": SunnyFill,
594
+ "thread-follow": ThreadFollow,
595
+ "thread-unfollow": ThreadUnfollow,
591
596
  "thumb-down": ThumbDown,
592
597
  "thumb-down-fill": ThumbDownFill,
593
598
  "thumb-up": ThumbUp,
@@ -657,6 +662,7 @@ export const ICONS = {
657
662
 
658
663
  "empty-search": EmptySearch,
659
664
  "unread":Unread,
665
+ unsave: Unsave,
660
666
  "documents":DocumentIcon,
661
667
  "message-blocked": MessageBlocked,
662
668
 
@@ -146,6 +146,43 @@ export { CometChatUIKit, CometChatUIKitHelper, UIKitSettings } from "./CometChat
146
146
  export type { CometChatMessageComposerAction } from "./helper/types";
147
147
 
148
148
  export { messageStatus } from "./utils/CometChatMessageHelper/index";
149
+ export {
150
+ ThreadSubscriptionConfig,
151
+ applyIncomingReply,
152
+ applyEditedMessage,
153
+ applySentMessage,
154
+ applyOwnIncomingMessage,
155
+ isThreadSubscribed,
156
+ stampThreadSubscribed,
157
+ toggleThreadSubscription,
158
+ } from "./utils/ThreadSubscriptionHelper";
159
+
160
+ /**
161
+ * Pin & Save. PinSaveConfig is the opt-in gate and MUST be exported — without it
162
+ * the feature is unreachable and therefore permanently off for every integrator.
163
+ * The read helpers come too, so a custom bubble can render its own indicator
164
+ * without re-deriving "presence is the boolean" and getting it wrong.
165
+ */
166
+ export {
167
+ PinConversationConfig,
168
+ isConversationPinned,
169
+ isSystemPinnedConversation,
170
+ } from "./utils/PinConversationHelper";
171
+ export {
172
+ resolvePinSaveFeatures,
173
+ refreshPinSaveFeatures,
174
+ getPinSaveFeatures,
175
+ resetPinSaveFeatures,
176
+ PIN_SAVE_FEATURES_DISABLED,
177
+ } from "./utils/PinSaveFeatureGates";
178
+
179
+ export {
180
+ PinSaveConfig,
181
+ isPinned,
182
+ isSaved,
183
+ isSystemPin,
184
+ SYSTEM_PINNER,
185
+ } from "./utils/PinSaveHelper";
149
186
 
150
187
  export { getCometChatTranslation, getCurrentLanguage} from "./resources/CometChatLocalizeNew/LocalizationManager";
151
188
  export { useLocalizedDate } from "./helper/useLocalizedDateHook";