@cometchat/chat-uikit-react-native 5.4.0 → 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 (72) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/CometChatClipboardModule.kt +34 -0
  2. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +605 -6
  3. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +20 -1
  4. package/ios/CometChatClipboardModule.m +5 -0
  5. package/ios/CometChatClipboardModule.swift +22 -0
  6. package/ios/RichTextEditorView.swift +648 -35
  7. package/ios/RichTextEditorViewManager.m +2 -0
  8. package/ios/RichTextEditorViewManager.swift +16 -0
  9. package/package.json +2 -1
  10. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +245 -55
  11. package/src/CometChatCompactMessageComposer/index.ts +2 -0
  12. package/src/CometChatConversations/CometChatConversations.tsx +291 -14
  13. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +181 -12
  14. package/src/CometChatMessageList/CometChatMessageList.tsx +568 -15
  15. package/src/CometChatMessageList/components/MessageModals.tsx +30 -0
  16. package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +14 -1
  17. package/src/CometChatMessageList/components/MessageQuickActions.tsx +162 -0
  18. package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +940 -0
  19. package/src/CometChatPinnedMessages/index.ts +5 -0
  20. package/src/CometChatPinnedMessages/style.ts +216 -0
  21. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +5 -0
  22. package/src/CometChatRichTextEditor/index.tsx +27 -1
  23. package/src/CometChatRichTextEditor/types.ts +19 -1
  24. package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +634 -0
  25. package/src/CometChatSavedMessages/index.ts +5 -0
  26. package/src/CometChatSavedMessages/style.ts +159 -0
  27. package/src/CometChatSearch/CometChatSearch.tsx +47 -340
  28. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +22 -2
  29. package/src/index.ts +60 -0
  30. package/src/shared/CometChatUiKit/CometChatUIKit.ts +16 -0
  31. package/src/shared/base/Types.ts +5 -0
  32. package/src/shared/constants/UIKitConstants.ts +13 -0
  33. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +34 -0
  34. package/src/shared/events/CometChatUIEventHandler/Listener.ts +37 -0
  35. package/src/shared/events/ListenerInitializer.ts +20 -1
  36. package/src/shared/events/messages.ts +18 -0
  37. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +95 -8
  38. package/src/shared/formatters/index.ts +14 -0
  39. package/src/shared/formatters/richTextWireFormat.ts +165 -0
  40. package/src/shared/framework/MessageDataSource.tsx +296 -3
  41. package/src/shared/icons/components/thread-follow.tsx +13 -0
  42. package/src/shared/icons/components/thread-unfollow.tsx +13 -0
  43. package/src/shared/icons/components/unsave.tsx +13 -0
  44. package/src/shared/icons/icon-mapping.tsx +6 -0
  45. package/src/shared/index.ts +37 -0
  46. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +54 -0
  47. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +2 -1
  48. package/src/shared/utils/MarkdownUtils.ts +25 -4
  49. package/src/shared/utils/MessageUtils.tsx +80 -5
  50. package/src/shared/utils/PinConversationHelper.ts +245 -0
  51. package/src/shared/utils/PinSaveFeatureGates.ts +178 -0
  52. package/src/shared/utils/PinSaveHelper.ts +549 -0
  53. package/src/shared/utils/SavedMessagesHelper.ts +231 -0
  54. package/src/shared/utils/ThreadSubscriptionHelper.ts +427 -0
  55. package/src/shared/utils/conversationUtils.ts +8 -1
  56. package/src/shared/utils/elementType.tsx +38 -0
  57. package/src/shared/utils/stripRichText.ts +7 -0
  58. package/src/shared/views/ClipboardPasteHandler/ClipboardPasteHandler.ts +21 -0
  59. package/src/shared/views/ClipboardPasteHandler/NativeCometChatClipboardModule.ts +6 -0
  60. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +4 -0
  61. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +17 -5
  62. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +28 -14
  63. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +2 -0
  64. package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +91 -20
  65. package/src/shared/views/CometChatList/CometChatList.tsx +6 -1
  66. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +4 -0
  67. package/src/shared/views/CometChatRetryButton/CometChatRetryButton.tsx +1 -0
  68. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +4 -0
  69. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +4 -3
  70. package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +4 -1
  71. package/src/theme/default/default.ts +6 -0
  72. package/src/theme/type.ts +4 -0
@@ -44,6 +44,20 @@ import { stripMarkdown, preparePreviewText } from "../shared/utils/MarkdownUtils
44
44
  import { CometChatRichTextFormatter } from "../shared/formatters/CometChatRichTextFormatter";
45
45
  import { getMessagePreviewInternal, applyMentionsFormatting } from "../shared/utils/MessageUtils";
46
46
  import { CometChatBadge } from "../shared/views/CometChatBadge";
47
+ import { useToast } from "../shared/helper/useToast";
48
+ import {
49
+ PinConversationConfig,
50
+ isConversationPinned,
51
+ isSystemPinnedConversation,
52
+ conversationInsertIndex,
53
+ targetOf,
54
+ pinConversation as sdkPinConversation,
55
+ unpinConversation as sdkUnpinConversation,
56
+ isConversationCapError,
57
+ isConversationNotPinnable,
58
+ isConversationFeatureOff,
59
+ resolveConversationCapLimit,
60
+ } from "../shared/utils/PinConversationHelper";
47
61
  import { CometChatConfirmDialog } from "../shared/views/CometChatConfirmDialog";
48
62
  import { CometChatDate } from "../shared/views/CometChatDate";
49
63
  import { CometChatReceipt } from "../shared/views/CometChatReceipt";
@@ -228,6 +242,12 @@ export interface ConversationInterface {
228
242
  * Toggle delete conversation option visibilty.
229
243
  */
230
244
  deleteConversationOptionVisibility?: boolean;
245
+ /**
246
+ * Show Pin/Unpin in the conversation long-press menu. Also requires
247
+ * PinConversationConfig.enable() — the module gate — and the app's
248
+ * `features.ux.conversations.pinned.enabled` server flag.
249
+ */
250
+ pinConversationOptionVisibility?: boolean;
231
251
  /**
232
252
  * Toggle search bar visibility in the conversations header.
233
253
  */
@@ -291,6 +311,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
291
311
  usersStatusVisibility = true,
292
312
  groupTypeVisibility = true,
293
313
  deleteConversationOptionVisibility = true,
314
+ pinConversationOptionVisibility = true,
294
315
  showSearchBar = false,
295
316
  onSearchBarClicked,
296
317
  onSearchTextChanged,
@@ -300,6 +321,140 @@ export const CometChatConversations = (props: ConversationInterface) => {
300
321
 
301
322
  // Reference for accessing CometChatList methods
302
323
  const conversationListRef = React.useRef<CometChatListActionsInterface>(null);
324
+ const { showToast, ToastElement } = useToast();
325
+
326
+ /**
327
+ * Re-seat a conversation at its correct index — the ONE ordering rule, used by
328
+ * pin, unpin and every incoming message.
329
+ *
330
+ * Replaces bare updateAndMoveToFirst, which sent everything to index 0 and so
331
+ * broke two ways once pins existed: a message in a pinned chat reshuffled the
332
+ * pinned block by recency instead of leaving it in its pinned slot, and a message
333
+ * in an unpinned chat jumped it ABOVE the pins.
334
+ *
335
+ * With no pins in the list this is behaviourally identical to
336
+ * updateAndMoveToFirst for a newly-messaged row, so it is a safe generalisation.
337
+ */
338
+ const placeConversation = (row: any) => {
339
+ const id = row?.getConversationId?.();
340
+ if (id === undefined || id === null) return;
341
+
342
+ const all = conversationListRef.current?.getAllListItems?.() ?? [];
343
+ const currentIndex = all.findIndex(
344
+ (o: any) => String(o?.getConversationId?.() ?? "") === String(id)
345
+ );
346
+ const targetIndex = conversationInsertIndex(row, all);
347
+
348
+ // Not moving? Update in place. This is the COMMON case — a message arriving in
349
+ // a pinned chat, which must keep its slot — and it matters for more than
350
+ // efficiency: removeItemFromList flips the list to NO_DATA_FOUND the moment it
351
+ // empties, so a remove-then-add on a single-row list would flash the empty
352
+ // state. Updating in place never empties it.
353
+ // Not in the list at all — a brand-new conversation, or one the user deleted
354
+ // that just received a message. Insert at the ORDERED index, never at 0: a
355
+ // message in a deleted chat must not surface above the user's pins.
356
+ if (currentIndex === -1) {
357
+ conversationListRef.current?.addItemToList(row, targetIndex);
358
+ return;
359
+ }
360
+
361
+ // Not moving? Update in place. This is the COMMON case — a message arriving in
362
+ // a pinned chat, which must keep its slot — and it matters for more than
363
+ // efficiency: removeItemFromList flips the list to NO_DATA_FOUND the moment it
364
+ // empties, so a remove-then-add on a single-row list would flash the empty
365
+ // state. Updating in place never empties it.
366
+ if (currentIndex === targetIndex) {
367
+ conversationListRef.current?.updateList(row);
368
+ return;
369
+ }
370
+
371
+ conversationListRef.current?.removeItemFromList(id);
372
+ conversationListRef.current?.addItemToList(row, targetIndex);
373
+ };
374
+
375
+ /**
376
+ * Pin or unpin a conversation, OPTIMISTICALLY (owner decision).
377
+ *
378
+ * Unlike the message pin/save flow — which applies the server's response because
379
+ * every message call returns the full updated entity — a conversation pin's whole
380
+ * point is the ROW MOVING. Waiting a round trip before it moves reads as a dead
381
+ * tap, so the row moves first and reverts if the server refuses.
382
+ *
383
+ * Placement goes through placeConversation, the same single ordering rule the
384
+ * incoming-message paths use, so pin, unpin and a new message can never disagree
385
+ * about where a row belongs.
386
+ */
387
+ const togglePinConversation = (conversation: CometChat.Conversation) => {
388
+ const target = targetOf(conversation);
389
+ if (!target) return;
390
+
391
+ const wasPinned = isConversationPinned(conversation);
392
+ const clone: any = CommonUtils.clone(conversation);
393
+
394
+
395
+ // Optimistic flip. The timestamp is a local placeholder — the next fetch
396
+ // replaces it with the server's, and only PRESENCE is ever read anyway.
397
+ if (wasPinned) {
398
+ clone.setPinnedAt?.(undefined);
399
+ clone.setPinnedBy?.(undefined);
400
+ placeConversation(clone);
401
+ } else {
402
+ clone.setPinnedAt?.(Math.floor(Date.now() / 1000));
403
+ placeConversation(clone);
404
+ }
405
+
406
+ const call = wasPinned ? sdkUnpinConversation : sdkPinConversation;
407
+ call(target.id, target.type)
408
+ .then((updated: CometChat.Conversation) => {
409
+ // Replace the optimistic guess with the server's own row. The local
410
+ // pinnedAt above was a placeholder; this is the authoritative value, so a
411
+ // later refetch cannot appear to "change" the pin time.
412
+ if (updated) {
413
+ const settled: any = CommonUtils.clone(updated);
414
+ placeConversation(settled);
415
+ }
416
+ showToast(
417
+ wasPinned
418
+ ? (t("CONVERSATION_UNPINNED") ?? "Conversation unpinned")
419
+ : (t("CONVERSATION_PINNED") ?? "Conversation pinned")
420
+ );
421
+ })
422
+ .catch(async (error: any) => {
423
+ // Revert to exactly the object we started from, so a failed pin cannot
424
+ // leave a half-flipped row behind.
425
+ //
426
+ // Through placeConversation, NOT updateList (ENG-38898). The optimistic flip
427
+ // above MOVED the row — that is the whole point of it — so restoring the object
428
+ // is only half the revert. updateList rewrites the row in place and leaves it
429
+ // wherever the optimistic placement put it, which on a refused pin means an
430
+ // unpinned conversation sitting at the top of the list wearing no pin icon.
431
+ // placeConversation re-runs the same ordering rule that moved it and puts it
432
+ // back among the unpinned rows, so a refused pin leaves nothing behind at all.
433
+ placeConversation(CommonUtils.clone(conversation));
434
+
435
+ let messageText: string;
436
+ if (isConversationFeatureOff(error)) {
437
+ messageText = t("PIN_SAVE_FEATURE_OFF") ?? "This feature isn't available for this app.";
438
+ } else if (isConversationNotPinnable(error)) {
439
+ messageText = t("CONVERSATION_NOT_PINNABLE") ?? "This conversation can't be pinned yet.";
440
+ } else if (isConversationCapError(error)) {
441
+ // Cap is 5 here, not the messages' 100 — and the server usually does not
442
+ // send the number, so the no-count copy is the expected path.
443
+ // errorParams first, then app settings (SDK getter, ENG-37790).
444
+ const limit = await resolveConversationCapLimit(error);
445
+ messageText =
446
+ limit !== null
447
+ ? (t("PIN_CONVERSATION_LIMIT_REACHED") ??
448
+ "You can only pin {limit} chats. Unpin one to pin another.")
449
+ .replace("{limit}", String(limit))
450
+ : (t("PIN_CONVERSATION_LIMIT_REACHED_NO_COUNT") ??
451
+ "You've reached your pinned chats limit. Unpin one to pin another.");
452
+ } else {
453
+ messageText = t("PIN_SAVE_GENERIC_ERROR") ?? "Something went wrong. Please try again.";
454
+ }
455
+ showToast(messageText);
456
+ });
457
+ };
303
458
  // Store the logged in user for comparison and event handling.
304
459
  const loggedInUser = React.useRef<CometChat.User>(undefined);
305
460
  // Buffer receipts by messageId to handle race conditions where receipts arrive
@@ -307,6 +462,14 @@ export const CometChatConversations = (props: ConversationInterface) => {
307
462
  const pendingReceiptsMap = React.useRef<Map<string, { readAt?: number; deliveredAt?: number }>>(new Map());
308
463
  // State to control the confirmation dialog for deleting a conversation.
309
464
  const [confirmDelete, setConfirmDelete] = React.useState<string | undefined>(undefined);
465
+ /**
466
+ * The conversation awaiting unpin confirmation, or undefined. Holds the whole
467
+ * conversation rather than an id because togglePinConversation needs the object,
468
+ * and `longPressedConversation` has already moved on by the time the user answers.
469
+ */
470
+ const [confirmUnpin, setConfirmUnpin] = React.useState<CometChat.Conversation | undefined>(
471
+ undefined
472
+ );
310
473
  // State to control selection mode for conversation items.
311
474
  const [selecting, setSelecting] = React.useState(selectionMode === "none" ? false : true);
312
475
  const [selectedConversation, setSelectedConversations] = React.useState<
@@ -620,7 +783,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
620
783
  loggedInUser.current?.getUid()
621
784
  )
622
785
  newConversation.setUnreadMessageCount(1);
623
- conversationListRef.current?.addItemToList(newConversation, 0);
786
+ placeConversation(newConversation);
624
787
  })
625
788
  .catch((err) => onError && onError(err));
626
789
  return;
@@ -652,7 +815,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
652
815
  oldConversation.setLastMessage(newMessage);
653
816
  if (newMessage.getSender().getUid() != loggedInUser.current?.getUid())
654
817
  oldConversation.setUnreadMessageCount(oldConversation.getUnreadMessageCount() + 1);
655
- conversationListRef.current?.updateAndMoveToFirst(CommonUtils.clone(oldConversation));
818
+ placeConversation(CommonUtils.clone(oldConversation));
656
819
  })
657
820
  .catch((err) => {
658
821
  console.log("Error", err);
@@ -851,7 +1014,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
851
1014
  if (existingConv) {
852
1015
  groupHandler(message, otherDetails, _depth + 1);
853
1016
  } else {
854
- conversationListRef.current?.addItemToList(newConversation, 0);
1017
+ placeConversation(newConversation);
855
1018
  }
856
1019
  }).catch(() => {
857
1020
  // Silently ignore — conversation won't appear until next refresh
@@ -1194,11 +1357,48 @@ export const CometChatConversations = (props: ConversationInterface) => {
1194
1357
  * @param conversation - The conversation object.
1195
1358
  * @returns A JSX.Element for the trailing view.
1196
1359
  */
1360
+ /**
1361
+ * The pin glyph on its own, for the rows that render no date and no badge.
1362
+ *
1363
+ * A pin is state the user set deliberately, so it has to be visible wherever a pinned row
1364
+ * is — it is the only thing on screen telling them the row is pinned rather than merely
1365
+ * near the top. Two rows used to lose it (ENG, agent rows): an AGENT conversation, whose
1366
+ * trailing view is blanked on purpose so it shows no preview or timestamp, and any
1367
+ * conversation with NO last message, where the date-driven trailing view bailed out early.
1368
+ * Both kept the pin working everywhere except on screen.
1369
+ *
1370
+ * Deliberately NOT the full trailing view: the date and unread badge stay hidden on those
1371
+ * rows, because hiding them was a design decision and only the pin was collateral.
1372
+ */
1373
+ const getPinOnlyTrailingView = useCallback(
1374
+ (conversation: CometChat.Conversation) => {
1375
+ if (!isConversationPinned(conversation)) return <></>;
1376
+ return (
1377
+ <View
1378
+ style={[
1379
+ conversationPreviewStyles.trailingContainer,
1380
+ mergedStyles.itemStyle.trailingViewContainerStyle,
1381
+ ]}
1382
+ >
1383
+ <View
1384
+ accessible={true}
1385
+ accessibilityLabel={t("PINNED") ?? "Pinned"}
1386
+ style={{ marginRight: theme.spacing.margin.m1 }}
1387
+ >
1388
+ <Icon name='keep-fill' color={theme.color.iconSecondary} height={14} width={14} />
1389
+ </View>
1390
+ </View>
1391
+ );
1392
+ },
1393
+ [mergedStyles, theme, t]
1394
+ );
1395
+
1197
1396
  const getTrailingView = useCallback(
1198
1397
  (conversation: CometChat.Conversation) => {
1199
1398
  const customPattern = () => datePattern?.(conversation);
1200
1399
  const timestamp = conversation.getLastMessage()?.getSentAt();
1201
- if (!timestamp) return <></>;
1400
+ // No last message — nothing to date-stamp, but a pin still has to show.
1401
+ if (!timestamp) return getPinOnlyTrailingView(conversation);
1202
1402
  return (
1203
1403
  <View
1204
1404
  style={[
@@ -1212,14 +1412,27 @@ export const CometChatConversations = (props: ConversationInterface) => {
1212
1412
  pattern={"conversationDate"}
1213
1413
  style={mergedStyles?.itemStyle?.dateStyle}
1214
1414
  />
1215
- <CometChatBadge
1216
- count={conversation.getUnreadMessageCount()}
1217
- style={mergedStyles?.itemStyle?.badgeStyle}
1218
- />
1415
+ <View style={{ flexDirection: "row", alignItems: "center" }}>
1416
+ {/* Pin indicator. Sits with the badge rather than in the title so it
1417
+ cannot push a long conversation name into truncation. */}
1418
+ {isConversationPinned(conversation) ? (
1419
+ <View
1420
+ accessible={true}
1421
+ accessibilityLabel={t("PINNED") ?? "Pinned"}
1422
+ style={{ marginRight: theme.spacing.margin.m1 }}
1423
+ >
1424
+ <Icon name='keep-fill' color={theme.color.iconSecondary} height={14} width={14} />
1425
+ </View>
1426
+ ) : null}
1427
+ <CometChatBadge
1428
+ count={conversation.getUnreadMessageCount()}
1429
+ style={mergedStyles?.itemStyle?.badgeStyle}
1430
+ />
1431
+ </View>
1219
1432
  </View>
1220
1433
  );
1221
1434
  },
1222
- [mergedStyles, datePattern]
1435
+ [mergedStyles, datePattern, theme, t, getPinOnlyTrailingView]
1223
1436
  );
1224
1437
 
1225
1438
  /**
@@ -1239,7 +1452,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
1239
1452
  conversation = CommonUtils.clone(conversation);
1240
1453
  conversation.setLastMessage(message);
1241
1454
  conversation.setConversationWith(group);
1242
- conversationListRef.current?.updateAndMoveToFirst(conversation);
1455
+ placeConversation(conversation);
1243
1456
  } else {
1244
1457
  CometChat.CometChatHelper.getConversationFromMessage(message)
1245
1458
  .then((newConversation) => {
@@ -1248,7 +1461,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
1248
1461
  loggedInUser.current?.getUid()
1249
1462
  )
1250
1463
  newConversation.setUnreadMessageCount(1);
1251
- conversationListRef.current?.addItemToList(newConversation, 0);
1464
+ placeConversation(newConversation);
1252
1465
  })
1253
1466
  .catch((err) => onError && onError(err));
1254
1467
  }
@@ -1578,7 +1791,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
1578
1791
  group.getGuid(),
1579
1792
  CometChatUiKitConstants.ConversationTypeConstants.group
1580
1793
  ).then((conversation) => {
1581
- conversationListRef.current?.addItemToList(conversation, 0);
1794
+ placeConversation(conversation);
1582
1795
  });
1583
1796
  },
1584
1797
  ccGroupDeleted: ({ group }: { group: CometChat.Group }) => {
@@ -1849,10 +2062,13 @@ export const CometChatConversations = (props: ConversationInterface) => {
1849
2062
  const TrailingViewRaw = useCallback((conv: CometChat.Conversation) => {
1850
2063
  const conversationWith = conv.getConversationWith();
1851
2064
  if (conversationWith instanceof CometChat.User && conversationWith.getRole() === "@agentic") {
1852
- return <></>;
2065
+ // An agent row shows no preview, date or unread count — but it can be pinned like any
2066
+ // other conversation, and a pinned row with no pin is indistinguishable from an
2067
+ // unpinned one that happens to be sorted high.
2068
+ return getPinOnlyTrailingView(conv);
1853
2069
  }
1854
2070
  return getTrailingView(conv);
1855
- }, [getTrailingView]);
2071
+ }, [getTrailingView, getPinOnlyTrailingView]);
1856
2072
 
1857
2073
  return (
1858
2074
  <View style={mergedStyles.containerStyle}>
@@ -1927,6 +2143,47 @@ export const CometChatConversations = (props: ConversationInterface) => {
1927
2143
  ? options(longPressedConversation.current!)
1928
2144
  : [
1929
2145
  ...[
2146
+ // Pin sits ABOVE Delete: non-destructive actions should not be
2147
+ // below the one the user must not hit by accident.
2148
+ ...(PinConversationConfig.isEnabled() &&
2149
+ pinConversationOptionVisibility &&
2150
+ longPressedConversation.current &&
2151
+ // A user cannot unpin an admin/global pin, so offer nothing rather
2152
+ // than an option the server will refuse.
2153
+ !isSystemPinnedConversation(longPressedConversation.current)
2154
+ ? [
2155
+ {
2156
+ text: isConversationPinned(longPressedConversation.current)
2157
+ ? (t("UNPIN_CONVERSATION") ?? "Unpin")
2158
+ : (t("PIN_CONVERSATION") ?? "Pin"),
2159
+ onPress: () => {
2160
+ const target = longPressedConversation.current!;
2161
+ setTooltipVisible(false);
2162
+ // Unpin asks, pin does not — the same asymmetry the message
2163
+ // list applies (Jitvar, 2026-08-04): pinning is additive and
2164
+ // undoable in one tap, unpinning discards a deliberate act
2165
+ // with nothing on screen offering it back.
2166
+ if (isConversationPinned(target)) {
2167
+ setConfirmUnpin(target);
2168
+ return;
2169
+ }
2170
+ togglePinConversation(target);
2171
+ },
2172
+ icon: (
2173
+ <Icon
2174
+ name={
2175
+ isConversationPinned(longPressedConversation.current)
2176
+ ? "keep-off"
2177
+ : "keep"
2178
+ }
2179
+ color={theme.color.iconSecondary}
2180
+ height={theme.spacing.spacing.s6}
2181
+ width={theme.spacing.spacing.s6}
2182
+ />
2183
+ ),
2184
+ },
2185
+ ]
2186
+ : []),
1930
2187
  ...(deleteConversationOptionVisibility
1931
2188
  ? [
1932
2189
  {
@@ -1965,6 +2222,26 @@ export const CometChatConversations = (props: ConversationInterface) => {
1965
2222
  }}
1966
2223
  {...mergedStyles.confirmDialogStyle}
1967
2224
  />
2225
+ <CometChatConfirmDialog
2226
+ titleText={t("UNPIN_CONVERSATION_TITLE") ?? "Unpin Conversation"}
2227
+ icon={<Icon name='keep-off' size={theme.spacing.spacing.s12} color={theme.color.error} />}
2228
+ cancelButtonText={t("CANCEL")}
2229
+ confirmButtonText={t("UNPIN_CONVERSATION") ?? "Unpin"}
2230
+ messageText={
2231
+ t("UNPIN_CONVERSATION_CONFIRM") ??
2232
+ "Do you want to unpin this conversation from the top of your list?"
2233
+ }
2234
+ isOpen={confirmUnpin != undefined}
2235
+ onCancel={() => setConfirmUnpin(undefined)}
2236
+ onConfirm={() => {
2237
+ togglePinConversation(confirmUnpin!);
2238
+ setConfirmUnpin(undefined);
2239
+ }}
2240
+ {...mergedStyles.confirmDialogStyle}
2241
+ />
2242
+ {/* Without this the useToast hook runs but nothing ever appears — the
2243
+ conversation pin/unpin toasts and every error message are invisible. */}
2244
+ {ToastElement}
1968
2245
  </View>
1969
2246
  );
1970
2247
  };