@planningcenter/chat-react-native 3.18.0-rc.7 → 3.18.0-rc.8

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 (37) hide show
  1. package/build/components/conversation/message.d.ts.map +1 -1
  2. package/build/components/conversation/message.js +21 -11
  3. package/build/components/conversation/message.js.map +1 -1
  4. package/build/components/conversation/message_form.d.ts.map +1 -1
  5. package/build/components/conversation/message_form.js +2 -4
  6. package/build/components/conversation/message_form.js.map +1 -1
  7. package/build/components/conversation/typing_indicator.d.ts +1 -5
  8. package/build/components/conversation/typing_indicator.d.ts.map +1 -1
  9. package/build/components/conversation/typing_indicator.js +2 -2
  10. package/build/components/conversation/typing_indicator.js.map +1 -1
  11. package/build/contexts/conversation_context.d.ts +13 -0
  12. package/build/contexts/conversation_context.d.ts.map +1 -0
  13. package/build/contexts/conversation_context.js +14 -0
  14. package/build/contexts/conversation_context.js.map +1 -0
  15. package/build/hooks/use_broadcast_typing_status.d.ts +1 -1
  16. package/build/hooks/use_broadcast_typing_status.d.ts.map +1 -1
  17. package/build/hooks/use_broadcast_typing_status.js +7 -3
  18. package/build/hooks/use_broadcast_typing_status.js.map +1 -1
  19. package/build/hooks/use_typing_indicators.d.ts +1 -1
  20. package/build/hooks/use_typing_indicators.d.ts.map +1 -1
  21. package/build/hooks/use_typing_indicators.js +16 -3
  22. package/build/hooks/use_typing_indicators.js.map +1 -1
  23. package/build/screens/conversation_screen.d.ts.map +1 -1
  24. package/build/screens/conversation_screen.js +8 -1
  25. package/build/screens/conversation_screen.js.map +1 -1
  26. package/build/types/jolt_events/typing_events.d.ts +1 -0
  27. package/build/types/jolt_events/typing_events.d.ts.map +1 -1
  28. package/build/types/jolt_events/typing_events.js.map +1 -1
  29. package/package.json +2 -2
  30. package/src/components/conversation/message.tsx +32 -15
  31. package/src/components/conversation/message_form.tsx +2 -9
  32. package/src/components/conversation/typing_indicator.tsx +2 -6
  33. package/src/contexts/conversation_context.tsx +34 -0
  34. package/src/hooks/use_broadcast_typing_status.ts +7 -3
  35. package/src/hooks/use_typing_indicators.ts +15 -3
  36. package/src/screens/conversation_screen.tsx +15 -1
  37. package/src/types/jolt_events/typing_events.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"use_broadcast_typing_status.js","sourceRoot":"","sources":["../../src/hooks/use_broadcast_typing_status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE/C,MAAM,iBAAiB,GAAG,IAAI,CAAA,CAAC,YAAY;AAE3C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,cAA+B,EAAE,EAAE;IAC1E,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,iBAAiB,GAAG,MAAM,CAAS,CAAC,CAAC,CAAA;IAE3C,MAAM,qBAAqB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAEtB,IAAI,GAAG,GAAG,iBAAiB,CAAC,OAAO,GAAG,iBAAiB,EAAE,CAAC;YACxD,OAAM;QACR,CAAC;QAED,iBAAiB,CAAC,OAAO,GAAG,GAAG,CAAA;QAE/B,SAAS,CAAC,IAAI;aACX,IAAI,CAAC;YACJ,GAAG,EAAE,qBAAqB,cAAc,0BAA0B;YAClE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE;SACzD,CAAC;aACD,KAAK,CAAC,KAAK,CAAC,EAAE;YACb,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAA;QAC5D,CAAC,CAAC,CAAA;IACN,CAAC,EAAE,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAA;IAE/B,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA","sourcesContent":["import { useCallback, useRef } from 'react'\nimport { useApiClient } from './use_api_client'\n\nconst THROTTLE_INTERVAL = 3000 // 3 seconds\n\n/**\n * Hook for broadcasting typing status to other users in a conversation\n *\n * We only broadcast once every 3 seconds, but we show the typing indicator for 6 seconds\n * after receiving a typing event. This is how we can show a steady typing indicator even\n * if the user types once every 2.9 seconds.\n */\nexport const useBroadcastTypingStatus = (conversationId: string | number) => {\n const apiClient = useApiClient()\n const lastBroadcastTime = useRef<number>(0)\n\n const broadcastTypingStatus = useCallback(() => {\n const now = Date.now()\n\n if (now - lastBroadcastTime.current < THROTTLE_INTERVAL) {\n return\n }\n\n lastBroadcastTime.current = now\n\n apiClient.chat\n .post({\n url: `/me/conversations/${conversationId}/broadcast_typing_status`,\n data: { data: { type: 'TypingStatus', attributes: {} } },\n })\n .catch(error => {\n console.error('Failed to broadcast typing status:', error)\n })\n }, [apiClient, conversationId])\n\n return broadcastTypingStatus\n}\n"]}
1
+ {"version":3,"file":"use_broadcast_typing_status.js","sourceRoot":"","sources":["../../src/hooks/use_broadcast_typing_status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAA;AAEzE,MAAM,iBAAiB,GAAG,IAAI,CAAA,CAAC,YAAY;AAE3C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,MAAM,EAAE,cAAc,EAAE,sBAAsB,EAAE,GAAG,sBAAsB,EAAE,CAAA;IAC3E,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,iBAAiB,GAAG,MAAM,CAAS,CAAC,CAAC,CAAA;IAE3C,MAAM,qBAAqB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAEtB,IAAI,GAAG,GAAG,iBAAiB,CAAC,OAAO,GAAG,iBAAiB,EAAE,CAAC;YACxD,OAAM;QACR,CAAC;QAED,iBAAiB,CAAC,OAAO,GAAG,GAAG,CAAA;QAE/B,SAAS,CAAC,IAAI;aACX,IAAI,CAAC;YACJ,GAAG,EAAE,qBAAqB,cAAc,0BAA0B;YAClE,IAAI,EAAE;gBACJ,IAAI,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,aAAa,EAAE,sBAAsB,EAAE,EAAE;aACtF;SACF,CAAC;aACD,KAAK,CAAC,KAAK,CAAC,EAAE;YACb,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAA;QAC5D,CAAC,CAAC,CAAA;IACN,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,sBAAsB,CAAC,CAAC,CAAA;IAE5D,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA","sourcesContent":["import { useCallback, useRef } from 'react'\nimport { useApiClient } from './use_api_client'\nimport { useConversationContext } from '../contexts/conversation_context'\n\nconst THROTTLE_INTERVAL = 3000 // 3 seconds\n\n/**\n * Hook for broadcasting typing status to other users in a conversation\n *\n * We only broadcast once every 3 seconds, but we show the typing indicator for 6 seconds\n * after receiving a typing event. This is how we can show a steady typing indicator even\n * if the user types once every 2.9 seconds.\n */\nexport const useBroadcastTypingStatus = () => {\n const { conversationId, currentPageReplyRootId } = useConversationContext()\n const apiClient = useApiClient()\n const lastBroadcastTime = useRef<number>(0)\n\n const broadcastTypingStatus = useCallback(() => {\n const now = Date.now()\n\n if (now - lastBroadcastTime.current < THROTTLE_INTERVAL) {\n return\n }\n\n lastBroadcastTime.current = now\n\n apiClient.chat\n .post({\n url: `/me/conversations/${conversationId}/broadcast_typing_status`,\n data: {\n data: { type: 'TypingStatus', attributes: { reply_root_id: currentPageReplyRootId } },\n },\n })\n .catch(error => {\n console.error('Failed to broadcast typing status:', error)\n })\n }, [apiClient.chat, conversationId, currentPageReplyRootId])\n\n return broadcastTypingStatus\n}\n"]}
@@ -5,7 +5,7 @@ import { PersonTyping } from './use_typing_status_cache';
5
5
  * The query function itself doesn't do anything, but we add to the cache
6
6
  * from useTypingStatusCache when we receive a typing event.
7
7
  */
8
- export declare const useTypingIndicators: (conversationId: number) => PersonTyping[];
8
+ export declare const useTypingIndicators: () => PersonTyping[];
9
9
  /**
10
10
  * Format text for typing indicators based on the number of people typing
11
11
  */
@@ -1 +1 @@
1
- {"version":3,"file":"use_typing_indicators.d.ts","sourceRoot":"","sources":["../../src/hooks/use_typing_indicators.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAGxD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,mBAAoB,MAAM,mBAYzD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,WAAY,YAAY,EAAE,KAAG,MAU/D,CAAA"}
1
+ {"version":3,"file":"use_typing_indicators.d.ts","sourceRoot":"","sources":["../../src/hooks/use_typing_indicators.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,sBAuB/B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,WAAY,YAAY,EAAE,KAAG,MAU/D,CAAA"}
@@ -1,23 +1,36 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
2
  import { useMemo } from 'react';
3
3
  import { useCurrentPerson } from './use_current_person';
4
+ import { useConversationContext } from '../contexts/conversation_context';
4
5
  /**
5
6
  * Hook for getting people currently typing in a conversation
6
7
  *
7
8
  * The query function itself doesn't do anything, but we add to the cache
8
9
  * from useTypingStatusCache when we receive a typing event.
9
10
  */
10
- export const useTypingIndicators = (conversationId) => {
11
+ export const useTypingIndicators = () => {
12
+ const { conversationId, currentPageReplyRootId } = useConversationContext();
11
13
  const cacheKey = useMemo(() => ['conversationTyping', String(conversationId)], [conversationId]);
12
14
  const currentPerson = useCurrentPerson();
15
+ const isCurrentPerson = (authorId) => authorId === currentPerson?.id;
16
+ const inMainConversationView = !currentPageReplyRootId;
13
17
  const now = Date.now();
14
18
  const { data } = useQuery({
15
19
  queryKey: cacheKey,
16
20
  queryFn: () => stableArray,
17
21
  initialData: stableArray,
18
22
  });
19
- // Filter out expired entries and the current user
20
- return data.filter(person => person.expires > now && person.author_id !== currentPerson?.id);
23
+ return data.filter(({ author_id, expires, reply_root_id }) => {
24
+ if (isCurrentPerson(author_id))
25
+ return false;
26
+ if (now > expires)
27
+ return false;
28
+ // If you are in the main conversation view, you will see any message sent
29
+ if (inMainConversationView)
30
+ return true;
31
+ // If you are in a reply view, you will only see messages sent in this reply thread
32
+ return reply_root_id === currentPageReplyRootId;
33
+ });
21
34
  };
22
35
  /**
23
36
  * Format text for typing indicators based on the number of people typing
@@ -1 +1 @@
1
- {"version":3,"file":"use_typing_indicators.js","sourceRoot":"","sources":["../../src/hooks/use_typing_indicators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,cAAsB,EAAE,EAAE;IAC5D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,oBAAoB,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAA;IAChG,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IACxC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IACtB,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;QACxB,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW;QAC1B,WAAW,EAAE,WAAW;KACzB,CAAC,CAAA;IAEF,kDAAkD;IAClD,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,GAAG,GAAG,IAAI,MAAM,CAAC,SAAS,KAAK,aAAa,EAAE,EAAE,CAAC,CAAA;AAC9F,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,MAAsB,EAAU,EAAE;IACvE,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,OAAO,EAAE,CAAA;IAE7B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,eAAe,CAAA;IAChD,CAAC;SAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,QAAQ,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,gBAAgB,CAAA;IAC9E,CAAC;SAAM,CAAC;QACN,OAAO,8BAA8B,CAAA;IACvC,CAAC;AACH,CAAC,CAAA;AAED,MAAM,WAAW,GAAmB,EAAE,CAAA","sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { useMemo } from 'react'\nimport { PersonTyping } from './use_typing_status_cache'\nimport { useCurrentPerson } from './use_current_person'\n\n/**\n * Hook for getting people currently typing in a conversation\n *\n * The query function itself doesn't do anything, but we add to the cache\n * from useTypingStatusCache when we receive a typing event.\n */\nexport const useTypingIndicators = (conversationId: number) => {\n const cacheKey = useMemo(() => ['conversationTyping', String(conversationId)], [conversationId])\n const currentPerson = useCurrentPerson()\n const now = Date.now()\n const { data } = useQuery({\n queryKey: cacheKey,\n queryFn: () => stableArray,\n initialData: stableArray,\n })\n\n // Filter out expired entries and the current user\n return data.filter(person => person.expires > now && person.author_id !== currentPerson?.id)\n}\n\n/**\n * Format text for typing indicators based on the number of people typing\n */\nexport const getTypingIndicatorText = (people: PersonTyping[]): string => {\n if (!people.length) return ''\n\n if (people.length === 1) {\n return `${people[0].author_name} is typing...`\n } else if (people.length === 2) {\n return `${people[0].author_name} and ${people[1].author_name} are typing...`\n } else {\n return 'Several people are typing...'\n }\n}\n\nconst stableArray: PersonTyping[] = []\n"]}
1
+ {"version":3,"file":"use_typing_indicators.js","sourceRoot":"","sources":["../../src/hooks/use_typing_indicators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAA;AAEzE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,EAAE,cAAc,EAAE,sBAAsB,EAAE,GAAG,sBAAsB,EAAE,CAAA;IAC3E,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,oBAAoB,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAA;IAChG,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IACxC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,QAAQ,KAAK,aAAa,EAAE,EAAE,CAAA;IAC5E,MAAM,sBAAsB,GAAG,CAAC,sBAAsB,CAAA;IACtD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IACtB,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;QACxB,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW;QAC1B,WAAW,EAAE,WAAW;KACzB,CAAC,CAAA;IAEF,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,EAAE;QAC3D,IAAI,eAAe,CAAC,SAAS,CAAC;YAAE,OAAO,KAAK,CAAA;QAC5C,IAAI,GAAG,GAAG,OAAO;YAAE,OAAO,KAAK,CAAA;QAE/B,0EAA0E;QAC1E,IAAI,sBAAsB;YAAE,OAAO,IAAI,CAAA;QAEvC,mFAAmF;QACnF,OAAO,aAAa,KAAK,sBAAsB,CAAA;IACjD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,MAAsB,EAAU,EAAE;IACvE,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,OAAO,EAAE,CAAA;IAE7B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,eAAe,CAAA;IAChD,CAAC;SAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,QAAQ,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,gBAAgB,CAAA;IAC9E,CAAC;SAAM,CAAC;QACN,OAAO,8BAA8B,CAAA;IACvC,CAAC;AACH,CAAC,CAAA;AAED,MAAM,WAAW,GAAmB,EAAE,CAAA","sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { useMemo } from 'react'\nimport { PersonTyping } from './use_typing_status_cache'\nimport { useCurrentPerson } from './use_current_person'\nimport { useConversationContext } from '../contexts/conversation_context'\n\n/**\n * Hook for getting people currently typing in a conversation\n *\n * The query function itself doesn't do anything, but we add to the cache\n * from useTypingStatusCache when we receive a typing event.\n */\nexport const useTypingIndicators = () => {\n const { conversationId, currentPageReplyRootId } = useConversationContext()\n const cacheKey = useMemo(() => ['conversationTyping', String(conversationId)], [conversationId])\n const currentPerson = useCurrentPerson()\n const isCurrentPerson = (authorId: number) => authorId === currentPerson?.id\n const inMainConversationView = !currentPageReplyRootId\n const now = Date.now()\n const { data } = useQuery({\n queryKey: cacheKey,\n queryFn: () => stableArray,\n initialData: stableArray,\n })\n\n return data.filter(({ author_id, expires, reply_root_id }) => {\n if (isCurrentPerson(author_id)) return false\n if (now > expires) return false\n\n // If you are in the main conversation view, you will see any message sent\n if (inMainConversationView) return true\n\n // If you are in a reply view, you will only see messages sent in this reply thread\n return reply_root_id === currentPageReplyRootId\n })\n}\n\n/**\n * Format text for typing indicators based on the number of people typing\n */\nexport const getTypingIndicatorText = (people: PersonTyping[]): string => {\n if (!people.length) return ''\n\n if (people.length === 1) {\n return `${people[0].author_name} is typing...`\n } else if (people.length === 2) {\n return `${people[0].author_name} and ${people[1].author_name} are typing...`\n } else {\n return 'Several people are typing...'\n }\n}\n\nconst stableArray: PersonTyping[] = []\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"conversation_screen.d.ts","sourceRoot":"","sources":["../../src/screens/conversation_screen.tsx"],"names":[],"mappings":"AACA,OAAO,EAAe,gBAAgB,EAAqB,MAAM,4BAA4B,CAAA;AAC7F,OAAO,EAGL,iBAAiB,EAIlB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAmD,MAAM,OAAO,CAAA;AAkBvE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAA;AAMjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAA;AAGpF,MAAM,MAAM,sBAAsB,GAAG;IACnC,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CA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E,CAAA;IACrB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,eAAO,MAAM,aAAa,2CAIvB,kBAAkB,6DAiFpB,CAAA;AACD,UAAU,4BAA6B,SAAQ,gBAAgB;IAC7D,eAAe,EAAE,MAAM,CAAA;IACvB,KAAK,CAAC,EAAE,yBAAyB,CAAA;IACjC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,uBAAuB,0DAMjC,4BAA4B,sBAiC9B,CAAA"}
@@ -24,7 +24,14 @@ import { useConversationJoltEvents } from '../hooks/use_conversation_jolt_events
24
24
  import { JumpToBottomButton } from '../components/conversation/jump_to_bottom_button';
25
25
  import { ReplyShadowMessage } from '../components/conversation/reply_shadow_message';
26
26
  import { availableFeatures, useFeatures } from '../hooks/use_features';
27
+ import { ConversationContextProvider } from '../contexts/conversation_context';
27
28
  export function ConversationScreen({ route }) {
29
+ const { conversation_id, reply_root_id } = route.params;
30
+ return (<ConversationContextProvider conversationId={conversation_id} currentPageReplyRootId={reply_root_id ?? null}>
31
+ <ConversationScreenContent route={route}/>
32
+ </ConversationContextProvider>);
33
+ }
34
+ function ConversationScreenContent({ route }) {
28
35
  const styles = useStyles();
29
36
  const navigation = useNavigation();
30
37
  const { conversation_id, editing_message_id, reply_root_id, reply_root_author_name } = route.params;
@@ -102,7 +109,7 @@ export function ConversationScreen({ route }) {
102
109
  return (<Message {...item} canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages} conversation_id={conversation_id} latestReadMessageSortKey={conversation?.latestReadMessageSortKey} inReplyScreen={!!reply_root_id} repliesEnabled={repliesEnabled}/>);
103
110
  }} onEndReached={() => fetchNextPage()} ListHeaderComponent={<View style={styles.listHeader}/>}/>)}
104
111
  <JumpToBottomButton onPress={handleReturnToBottom} visible={showJumpToBottomButton}/>
105
- {!noMessages && <TypingIndicator conversationId={conversation_id}/>}
112
+ {!noMessages && <TypingIndicator />}
106
113
  {showLeaderDisabledReplyBanner && <LeaderDisabledRepliesBanner />}
107
114
  {canReply ? (<MessageForm.Root replyRootAuthorFirstName={replyRootAuthorFirstName} conversation={conversation} replyRootId={reply_root_id} currentlyEditingMessage={currentlyEditingMessage}
108
115
  // We use a separate key so that it remounts component when switching between new
@@ -1 +1 @@
1
- {"version":3,"file":"conversation_screen.js","sourceRoot":"","sources":["../../src/screens/conversation_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAE,WAAW,EAAoB,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC7F,OAAO,EACL,aAAa,EAGb,aAAa,EACb,QAAQ,IAAI,kBAAkB,EAC9B,QAAQ,GACT,MAAM,0BAA0B,CAAA;AACjC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,qDAAqD,CAAA;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,2DAA2D,CAAA;AACvG,OAAO,UAAU,MAAM,+CAA+C,CAAA;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AAClE,OA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;YACrE,MAAM,EAAE,EAAE;SACX;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,iCAAiC,GAAG,GAAG,EAAE;IAC7C,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAA+C,CAAA;IAE1E,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,eAAe,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAA;QAC7C,MAAM,MAAM,GAAG,eAAe,EAAE,MAAM,IAAI,EAAE,CAAA;QAC5C,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CAAC,CAAA;QAEvE,IAAI,kBAAkB;YAAE,OAAM;QAE9B,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YAC1B,OAAO,aAAa,CAAC,KAAK,CAAC;gBACzB,GAAG,KAAK;gBACR,MAAM,EAAE;oBACN,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,mBAAmB,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE;oBACvF,GAAG,MAAM;iBACV;gBACD,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC;aACvB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAA;AAC/C,CAAC,CAAA","sourcesContent":["import { date as formatDate } from '@planningcenter/datetime-fmt'\nimport { HeaderTitle, HeaderTitleProps, PlatformPressable } from '@react-navigation/elements'\nimport {\n CommonActions,\n RouteProp,\n StaticScreenProps,\n useNavigation,\n useTheme as useNavigationTheme,\n useRoute,\n} from '@react-navigation/native'\nimport moment from 'moment'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { FlatList, Platform, StyleSheet, View } from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Badge, Icon, Text } from '../components'\nimport {\n LeaderDisabledRepliesBanner,\n MemberDisabledRepliesBanner,\n} from '../components/conversation/disabled_replies_banners'\nimport { EmptyConversationBlankState } from '../components/conversation/empty_conversation_blank_state'\nimport BlankState from '../components/primitive/blank_state_primitive'\nimport { Message } from '../components/conversation/message'\nimport { MessageForm } from '../components/conversation/message_form'\nimport { TypingIndicator } from '../components/conversation/typing_indicator'\nimport { KeyboardView } from '../components/display/keyboard_view'\nimport { useTheme } from '../hooks'\nimport { useConversation } from '../hooks/use_conversation'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useConversationMessagesJoltEvents } from '../hooks/use_conversation_messages_jolt_events'\nimport { MessageResource } from '../types'\nimport { ConversationBadgeResource } from '../types/resources/conversation_badge'\nimport { getRelativeDateStatus } from '../utils/date'\nimport { useMarkLatestMessageRead } from '../hooks/use_mark_latest_message_read'\nimport { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../utils/styles'\nimport { useConversationJoltEvents } from '../hooks/use_conversation_jolt_events'\nimport { JumpToBottomButton } from '../components/conversation/jump_to_bottom_button'\nimport { ReplyShadowMessage } from '../components/conversation/reply_shadow_message'\nimport { availableFeatures, useFeatures } from '../hooks/use_features'\n\nexport type ConversationRouteProps = {\n conversation_id: number\n reply_root_id?: string | null\n reply_root_author_name?: string\n chat_group_graph_id?: string\n clear_input?: boolean\n editing_message_id?: number | null\n title?: string\n subtitle?: string\n badge?: ConversationBadgeResource\n deleted?: boolean\n}\n\nexport type ConversationScreenProps = StaticScreenProps<ConversationRouteProps>\n\nexport function ConversationScreen({ route }: ConversationScreenProps) {\n const styles = useStyles()\n const navigation = useNavigation()\n const { conversation_id, editing_message_id, reply_root_id, reply_root_author_name } =\n route.params\n const { data: conversation } = useConversation(route.params)\n const { messages, refetch, isRefetching, fetchNextPage } = useConversationMessages({\n conversation_id,\n reply_root_id,\n })\n useConversationJoltEvents({ conversationId: conversation_id })\n useConversationMessagesJoltEvents({ conversationId: conversation_id })\n useEnsureConversationsRouteExists()\n useMarkLatestMessageRead({ conversation, messages })\n const { featureEnabled } = useFeatures()\n const repliesEnabled = featureEnabled(availableFeatures.threaded_replies)\n const messagesWithSeparators = groupMessages({\n ms: messages,\n inReplyScreen: !!reply_root_id,\n repliesEnabled,\n })\n const noMessages = messagesWithSeparators.length === 0\n\n const { repliesDisabled, memberAbility, badges, title } = conversation\n const canReply = memberAbility?.canReply\n const showLeaderDisabledReplyBanner = canReply && repliesDisabled\n const canDeleteNonAuthoredMessages = memberAbility?.canDeleteNonAuthoredMessages ?? false\n const currentlyEditingMessage = messages.find(m => String(m.id) === String(editing_message_id))\n const replyRootAuthorFirstName = reply_root_author_name?.split(' ')[0]\n const replyHeaderTitle = replyRootAuthorFirstName\n ? `Reply to ${replyRootAuthorFirstName}`\n : 'Reply'\n\n const listRef = useRef<FlatList>(null)\n const [showJumpToBottomButton, setShowJumpToBottomButton] = useState(false)\n\n const trackScroll = (event: any) => {\n const offsetY = event.nativeEvent.contentOffset.y\n setShowJumpToBottomButton(offsetY > 200)\n }\n\n const handleReturnToBottom = useCallback(() => {\n listRef.current?.scrollToOffset({\n offset: 0,\n })\n }, [])\n\n useEffect(() => {\n if (reply_root_id) {\n navigation.setParams({\n title: replyHeaderTitle,\n })\n } else {\n navigation.setParams({\n title: title,\n badge: badges?.[0],\n deleted: conversation?.deleted,\n })\n }\n }, [navigation, title, badges, conversation?.deleted, reply_root_id, replyHeaderTitle])\n\n if (!conversation || conversation.deleted) {\n return (\n <View style={styles.container}>\n <BlankState.Root>\n <BlankState.Imagery name=\"general.outlinedTextMessage\" />\n <BlankState.Content>\n <BlankState.Heading>This conversation has been deleted</BlankState.Heading>\n </BlankState.Content>\n <BlankState.Button\n onPress={navigation.goBack}\n title=\"Back to conversations\"\n accessibilityHint=\"Navigates back to the conversations list\"\n accessibilityRole=\"link\"\n />\n </BlankState.Root>\n </View>\n )\n }\n\n return (\n <View style={styles.container}>\n <KeyboardView>\n {noMessages ? (\n <EmptyConversationBlankState />\n ) : (\n <FlatList\n inverted\n ref={listRef}\n contentContainerStyle={styles.listContainer}\n refreshing={isRefetching}\n onRefresh={refetch}\n data={messagesWithSeparators}\n keyExtractor={item => item.id}\n onScroll={trackScroll}\n scrollEventThrottle={10}\n renderItem={({ item }) => {\n if (item.type === 'DateSeparator') {\n return <InlineDateSeparator {...item} />\n }\n\n if (item.type === 'ReplyShadowMessage') {\n return (\n <ReplyShadowMessage\n {...item}\n conversation_id={conversation_id}\n inReplyScreen={!!reply_root_id}\n />\n )\n }\n\n return (\n <Message\n {...item}\n canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages}\n conversation_id={conversation_id}\n latestReadMessageSortKey={conversation?.latestReadMessageSortKey}\n inReplyScreen={!!reply_root_id}\n repliesEnabled={repliesEnabled}\n />\n )\n }}\n onEndReached={() => fetchNextPage()}\n ListHeaderComponent={<View style={styles.listHeader} />}\n />\n )}\n <JumpToBottomButton onPress={handleReturnToBottom} visible={showJumpToBottomButton} />\n {!noMessages && <TypingIndicator conversationId={conversation_id} />}\n {showLeaderDisabledReplyBanner && <LeaderDisabledRepliesBanner />}\n {canReply ? (\n <MessageForm.Root\n replyRootAuthorFirstName={replyRootAuthorFirstName}\n conversation={conversation}\n replyRootId={reply_root_id}\n currentlyEditingMessage={currentlyEditingMessage}\n // We use a separate key so that it remounts component when switching between new\n // and edit message. This simplifies internal state handling.\n key={\n currentlyEditingMessage\n ? `edit-message-form-${currentlyEditingMessage.id}`\n : 'new-message-form'\n }\n >\n <MessageForm.AttachmentPicker />\n <MessageForm.Commands />\n <MessageForm.TextInput />\n <MessageForm.SubmitButton />\n </MessageForm.Root>\n ) : (\n <MemberDisabledRepliesBanner />\n )}\n </KeyboardView>\n </View>\n )\n}\n\nexport type DateSeparator = { type: 'DateSeparator'; id: string; date: string }\n\nfunction InlineDateSeparator({ date }: DateSeparator) {\n const styles = useDateSeparatorStyles()\n const { isThisYear } = getRelativeDateStatus(date)\n const showYear = !isThisYear\n const dateStamp = formatDate(date, { style: 'long', year: showYear })\n\n return (\n <View style={styles.container}>\n <View style={styles.separator} />\n <Text variant=\"footnote\" style={styles.dateText}>\n {dateStamp}\n </Text>\n <View style={styles.separator} />\n </View>\n )\n}\n\nconst useDateSeparatorStyles = () => {\n const theme = useTheme()\n return StyleSheet.create({\n container: {\n alignItems: 'center',\n flexDirection: 'row',\n paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,\n paddingVertical: 16,\n },\n separator: {\n flex: 1,\n height: 1,\n borderTopWidth: 1,\n borderTopColor: theme.colors.borderColorDefaultBase,\n },\n dateText: {\n paddingHorizontal: 8,\n },\n })\n}\n\ntype ReplyShadowMessage = {\n type: 'ReplyShadowMessage'\n id: string\n messageId: string\n isReplyShadowMessage: boolean\n nextRendersAuthor: boolean\n}\n\ninterface GroupMessagesProps {\n ms: MessageResource[]\n inReplyScreen?: boolean\n repliesEnabled?: boolean\n}\n\nexport const groupMessages = ({\n ms,\n inReplyScreen,\n repliesEnabled = false,\n}: GroupMessagesProps) => {\n let enrichedMessages: (MessageResource | DateSeparator | ReplyShadowMessage)[] = []\n let encounteredOneOfMyMessages = false\n\n ms.forEach((message, i) => {\n const prevMessage = ms[i + 1]\n const nextMessage = ms[i - 1]\n const date = moment(message.createdAt).format('YYYY-MM-DD')\n const inThread = message.replyRootId !== null\n const nextMessageInThread = nextMessage?.replyRootId !== null\n const threadRoot = message.replyRootId === message.id\n const nextMessageThreadRoot = nextMessage?.replyRootId === nextMessage?.id\n const prevMessageDifferentThread = message.replyRootId !== prevMessage?.replyRootId\n const nextMessageDifferentThread = message.replyRootId !== nextMessage?.replyRootId\n const prevMessageDifferentAuthor = message.author?.id !== prevMessage?.author?.id\n const nextMessageDifferentAuthor = message.author?.id !== nextMessage?.author?.id\n const prevMessageMoreThan5Minutes =\n prevMessage &&\n new Date(message.createdAt).getTime() - new Date(prevMessage.createdAt).getTime() > 60000 * 5\n const nextMessageMoreThan5Minutes =\n nextMessage &&\n new Date(nextMessage.createdAt).getTime() - new Date(message.createdAt).getTime() > 60000 * 5\n const prevMessageIsDateSeparator =\n prevMessage && date !== moment(prevMessage.createdAt).format('YYYY-MM-DD')\n const nextMessageIsDateSeparator =\n nextMessage && date !== moment(nextMessage.createdAt).format('YYYY-MM-DD')\n const insertReplyShadowMessage =\n message.replyRootId &&\n !threadRoot &&\n (prevMessageDifferentThread || prevMessageIsDateSeparator)\n\n if (message.mine && !encounteredOneOfMyMessages) {\n encounteredOneOfMyMessages = true\n message.myLatestInConversation = true\n } else {\n message.myLatestInConversation = false\n }\n message.lastInGroup = !nextMessage || nextMessageDifferentAuthor || nextMessageMoreThan5Minutes\n message.renderAuthor =\n !message.mine && (!prevMessage || prevMessageDifferentAuthor || prevMessageMoreThan5Minutes)\n message.threadPosition = null\n message.nextRendersAuthor = nextMessage?.renderAuthor\n message.isReplyShadowMessage = false\n message.nextIsReplyShadowMessage =\n repliesEnabled &&\n nextMessageInThread &&\n !nextMessageThreadRoot &&\n (nextMessageDifferentThread || nextMessageIsDateSeparator)\n\n if (!inReplyScreen && inThread) {\n message.prevIsMyReply = prevMessage?.mine\n message.nextIsMyReply = nextMessage?.mine\n\n const firstInThread = threadRoot\n const lastInThread = nextMessageDifferentThread || nextMessageIsDateSeparator\n\n if (firstInThread && lastInThread)\n message.threadPosition = null // ensures we don't render a connector for root replies that aren't immediately followed up a reply\n else if (firstInThread) message.threadPosition = 'first'\n else if (lastInThread) message.threadPosition = 'last'\n else message.threadPosition = 'center'\n }\n\n enrichedMessages.push(message)\n\n if (insertReplyShadowMessage && repliesEnabled) {\n enrichedMessages.push({\n type: 'ReplyShadowMessage',\n id: `${message.id}-${message.replyRootId}`,\n messageId: message.replyRootId!,\n isReplyShadowMessage: true,\n nextRendersAuthor: message?.renderAuthor,\n })\n }\n\n if (!prevMessage || date !== moment(prevMessage.createdAt).format('YYYY-MM-DD')) {\n enrichedMessages.push({ type: 'DateSeparator', id: `day-divider-${message.id}`, date })\n }\n })\n\n return enrichedMessages\n}\ninterface ConversationScreenTitleProps extends HeaderTitleProps {\n conversation_id: number\n badge?: ConversationBadgeResource\n deleted?: boolean\n}\n\nexport const ConversationScreenTitle = ({\n conversation_id,\n badge,\n children,\n style,\n deleted,\n}: ConversationScreenTitleProps) => {\n const styles = usePressableHeaderStyle()\n const navigation = useNavigation()\n const resourceType = badge?.pcoResourceType || ''\n const productName = badge?.appName\n const name = badge?.text || undefined\n\n return (\n <PlatformPressable\n accessibilityHint=\"Opens details about members and settings\"\n style={styles.container}\n onPress={() => {\n if (deleted) return\n\n navigation.navigate('ConversationDetails', { conversation_id })\n }}\n >\n <View style={styles.titleWrapper}>\n <HeaderTitle maxFontSizeMultiplier={1} style={style}>\n {children}\n </HeaderTitle>\n {!deleted && <Icon name=\"general.downChevron\" size={12} />}\n </View>\n <Badge\n variant=\"metaSubtle\"\n productLogoName={productName}\n label={resourceType}\n metaLabel={name}\n style={styles.badge}\n maxFontSizeMultiplier={1}\n />\n </PlatformPressable>\n )\n}\n\nconst usePressableHeaderStyle = () => {\n return StyleSheet.create({\n container: {\n alignItems: Platform.select({ android: 'flex-start', default: 'center' }),\n marginRight: Platform.select({ ios: 20, default: 16 }),\n },\n titleWrapper: {\n alignItems: 'center',\n columnGap: 4,\n flexDirection: 'row',\n flexShrink: 1,\n },\n badge: {\n alignSelf: Platform.select({ android: 'flex-start', default: 'center' }),\n marginTop: 2,\n },\n })\n}\n\nconst useStyles = () => {\n const navigationTheme = useNavigationTheme()\n const { bottom } = useSafeAreaInsets()\n\n return StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n backgroundColor: navigationTheme.colors.card,\n paddingBottom: bottom,\n },\n listContainer: {\n paddingVertical: 12,\n },\n listHeader: {\n // Just whitespace to provide space where the typing indicator can be\n height: 16,\n },\n })\n}\n\n/**\n * useEnsureConversationsRouteExists\n */\nconst useEnsureConversationsRouteExists = () => {\n const navigation = useNavigation()\n const { params } = useRoute<RouteProp<ConversationScreenProps['route']>>()\n\n useEffect(() => {\n const navigationState = navigation.getState()\n const routes = navigationState?.routes || []\n const conversationsRoute = routes.find(r => r.name === 'Conversations')\n\n if (conversationsRoute) return\n\n navigation.dispatch(state => {\n return CommonActions.reset({\n ...state,\n routes: [\n { name: 'Conversations', params: { chat_group_graph_id: params?.chat_group_graph_id } },\n ...routes,\n ],\n index: state.index + 1,\n })\n })\n }, [navigation, params?.chat_group_graph_id])\n}\n"]}
1
+ {"version":3,"file":"conversation_screen.js","sourceRoot":"","sources":["../../src/screens/conversation_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAE,WAAW,EAAoB,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC7F,OAAO,EACL,aAAa,EAGb,aAAa,EACb,QAAQ,IAAI,kBAAkB,EAC9B,QAAQ,GACT,MAAM,0BAA0B,CAAA;AACjC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,qDAAqD,CAAA;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,2DAA2D,CAAA;AACvG,OAAO,UAAU,MAAM,+CAA+C,CAAA;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAA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EAAE;oBACvF,GAAG,MAAM;iBACV;gBACD,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC;aACvB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAA;AAC/C,CAAC,CAAA","sourcesContent":["import { date as formatDate } from '@planningcenter/datetime-fmt'\nimport { HeaderTitle, HeaderTitleProps, PlatformPressable } from '@react-navigation/elements'\nimport {\n CommonActions,\n RouteProp,\n StaticScreenProps,\n useNavigation,\n useTheme as useNavigationTheme,\n useRoute,\n} from '@react-navigation/native'\nimport moment from 'moment'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { FlatList, Platform, StyleSheet, View } from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Badge, Icon, Text } from '../components'\nimport {\n LeaderDisabledRepliesBanner,\n MemberDisabledRepliesBanner,\n} from '../components/conversation/disabled_replies_banners'\nimport { EmptyConversationBlankState } from '../components/conversation/empty_conversation_blank_state'\nimport BlankState from '../components/primitive/blank_state_primitive'\nimport { Message } from '../components/conversation/message'\nimport { MessageForm } from '../components/conversation/message_form'\nimport { TypingIndicator } from '../components/conversation/typing_indicator'\nimport { KeyboardView } from '../components/display/keyboard_view'\nimport { useTheme } from '../hooks'\nimport { useConversation } from '../hooks/use_conversation'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useConversationMessagesJoltEvents } from '../hooks/use_conversation_messages_jolt_events'\nimport { MessageResource } from '../types'\nimport { ConversationBadgeResource } from '../types/resources/conversation_badge'\nimport { getRelativeDateStatus } from '../utils/date'\nimport { useMarkLatestMessageRead } from '../hooks/use_mark_latest_message_read'\nimport { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../utils/styles'\nimport { useConversationJoltEvents } from '../hooks/use_conversation_jolt_events'\nimport { JumpToBottomButton } from '../components/conversation/jump_to_bottom_button'\nimport { ReplyShadowMessage } from '../components/conversation/reply_shadow_message'\nimport { availableFeatures, useFeatures } from '../hooks/use_features'\nimport { ConversationContextProvider } from '../contexts/conversation_context'\n\nexport type ConversationRouteProps = {\n conversation_id: number\n reply_root_id?: string | null\n reply_root_author_name?: string\n chat_group_graph_id?: string\n clear_input?: boolean\n editing_message_id?: number | null\n title?: string\n subtitle?: string\n badge?: ConversationBadgeResource\n deleted?: boolean\n}\n\nexport type ConversationScreenProps = StaticScreenProps<ConversationRouteProps>\n\nexport function ConversationScreen({ route }: ConversationScreenProps) {\n const { conversation_id, reply_root_id } = route.params\n\n return (\n <ConversationContextProvider\n conversationId={conversation_id}\n currentPageReplyRootId={reply_root_id ?? null}\n >\n <ConversationScreenContent route={route} />\n </ConversationContextProvider>\n )\n}\n\nfunction ConversationScreenContent({ route }: ConversationScreenProps) {\n const styles = useStyles()\n const navigation = useNavigation()\n const { conversation_id, editing_message_id, reply_root_id, reply_root_author_name } =\n route.params\n const { data: conversation } = useConversation(route.params)\n const { messages, refetch, isRefetching, fetchNextPage } = useConversationMessages({\n conversation_id,\n reply_root_id,\n })\n useConversationJoltEvents({ conversationId: conversation_id })\n useConversationMessagesJoltEvents({ conversationId: conversation_id })\n useEnsureConversationsRouteExists()\n useMarkLatestMessageRead({ conversation, messages })\n const { featureEnabled } = useFeatures()\n const repliesEnabled = featureEnabled(availableFeatures.threaded_replies)\n const messagesWithSeparators = groupMessages({\n ms: messages,\n inReplyScreen: !!reply_root_id,\n repliesEnabled,\n })\n const noMessages = messagesWithSeparators.length === 0\n\n const { repliesDisabled, memberAbility, badges, title } = conversation\n const canReply = memberAbility?.canReply\n const showLeaderDisabledReplyBanner = canReply && repliesDisabled\n const canDeleteNonAuthoredMessages = memberAbility?.canDeleteNonAuthoredMessages ?? false\n const currentlyEditingMessage = messages.find(m => String(m.id) === String(editing_message_id))\n const replyRootAuthorFirstName = reply_root_author_name?.split(' ')[0]\n const replyHeaderTitle = replyRootAuthorFirstName\n ? `Reply to ${replyRootAuthorFirstName}`\n : 'Reply'\n\n const listRef = useRef<FlatList>(null)\n const [showJumpToBottomButton, setShowJumpToBottomButton] = useState(false)\n\n const trackScroll = (event: any) => {\n const offsetY = event.nativeEvent.contentOffset.y\n setShowJumpToBottomButton(offsetY > 200)\n }\n\n const handleReturnToBottom = useCallback(() => {\n listRef.current?.scrollToOffset({\n offset: 0,\n })\n }, [])\n\n useEffect(() => {\n if (reply_root_id) {\n navigation.setParams({\n title: replyHeaderTitle,\n })\n } else {\n navigation.setParams({\n title: title,\n badge: badges?.[0],\n deleted: conversation?.deleted,\n })\n }\n }, [navigation, title, badges, conversation?.deleted, reply_root_id, replyHeaderTitle])\n\n if (!conversation || conversation.deleted) {\n return (\n <View style={styles.container}>\n <BlankState.Root>\n <BlankState.Imagery name=\"general.outlinedTextMessage\" />\n <BlankState.Content>\n <BlankState.Heading>This conversation has been deleted</BlankState.Heading>\n </BlankState.Content>\n <BlankState.Button\n onPress={navigation.goBack}\n title=\"Back to conversations\"\n accessibilityHint=\"Navigates back to the conversations list\"\n accessibilityRole=\"link\"\n />\n </BlankState.Root>\n </View>\n )\n }\n\n return (\n <View style={styles.container}>\n <KeyboardView>\n {noMessages ? (\n <EmptyConversationBlankState />\n ) : (\n <FlatList\n inverted\n ref={listRef}\n contentContainerStyle={styles.listContainer}\n refreshing={isRefetching}\n onRefresh={refetch}\n data={messagesWithSeparators}\n keyExtractor={item => item.id}\n onScroll={trackScroll}\n scrollEventThrottle={10}\n renderItem={({ item }) => {\n if (item.type === 'DateSeparator') {\n return <InlineDateSeparator {...item} />\n }\n\n if (item.type === 'ReplyShadowMessage') {\n return (\n <ReplyShadowMessage\n {...item}\n conversation_id={conversation_id}\n inReplyScreen={!!reply_root_id}\n />\n )\n }\n\n return (\n <Message\n {...item}\n canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages}\n conversation_id={conversation_id}\n latestReadMessageSortKey={conversation?.latestReadMessageSortKey}\n inReplyScreen={!!reply_root_id}\n repliesEnabled={repliesEnabled}\n />\n )\n }}\n onEndReached={() => fetchNextPage()}\n ListHeaderComponent={<View style={styles.listHeader} />}\n />\n )}\n <JumpToBottomButton onPress={handleReturnToBottom} visible={showJumpToBottomButton} />\n {!noMessages && <TypingIndicator />}\n {showLeaderDisabledReplyBanner && <LeaderDisabledRepliesBanner />}\n {canReply ? (\n <MessageForm.Root\n replyRootAuthorFirstName={replyRootAuthorFirstName}\n conversation={conversation}\n replyRootId={reply_root_id}\n currentlyEditingMessage={currentlyEditingMessage}\n // We use a separate key so that it remounts component when switching between new\n // and edit message. This simplifies internal state handling.\n key={\n currentlyEditingMessage\n ? `edit-message-form-${currentlyEditingMessage.id}`\n : 'new-message-form'\n }\n >\n <MessageForm.AttachmentPicker />\n <MessageForm.Commands />\n <MessageForm.TextInput />\n <MessageForm.SubmitButton />\n </MessageForm.Root>\n ) : (\n <MemberDisabledRepliesBanner />\n )}\n </KeyboardView>\n </View>\n )\n}\n\nexport type DateSeparator = { type: 'DateSeparator'; id: string; date: string }\n\nfunction InlineDateSeparator({ date }: DateSeparator) {\n const styles = useDateSeparatorStyles()\n const { isThisYear } = getRelativeDateStatus(date)\n const showYear = !isThisYear\n const dateStamp = formatDate(date, { style: 'long', year: showYear })\n\n return (\n <View style={styles.container}>\n <View style={styles.separator} />\n <Text variant=\"footnote\" style={styles.dateText}>\n {dateStamp}\n </Text>\n <View style={styles.separator} />\n </View>\n )\n}\n\nconst useDateSeparatorStyles = () => {\n const theme = useTheme()\n return StyleSheet.create({\n container: {\n alignItems: 'center',\n flexDirection: 'row',\n paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,\n paddingVertical: 16,\n },\n separator: {\n flex: 1,\n height: 1,\n borderTopWidth: 1,\n borderTopColor: theme.colors.borderColorDefaultBase,\n },\n dateText: {\n paddingHorizontal: 8,\n },\n })\n}\n\ntype ReplyShadowMessage = {\n type: 'ReplyShadowMessage'\n id: string\n messageId: string\n isReplyShadowMessage: boolean\n nextRendersAuthor: boolean\n}\n\ninterface GroupMessagesProps {\n ms: MessageResource[]\n inReplyScreen?: boolean\n repliesEnabled?: boolean\n}\n\nexport const groupMessages = ({\n ms,\n inReplyScreen,\n repliesEnabled = false,\n}: GroupMessagesProps) => {\n let enrichedMessages: (MessageResource | DateSeparator | ReplyShadowMessage)[] = []\n let encounteredOneOfMyMessages = false\n\n ms.forEach((message, i) => {\n const prevMessage = ms[i + 1]\n const nextMessage = ms[i - 1]\n const date = moment(message.createdAt).format('YYYY-MM-DD')\n const inThread = message.replyRootId !== null\n const nextMessageInThread = nextMessage?.replyRootId !== null\n const threadRoot = message.replyRootId === message.id\n const nextMessageThreadRoot = nextMessage?.replyRootId === nextMessage?.id\n const prevMessageDifferentThread = message.replyRootId !== prevMessage?.replyRootId\n const nextMessageDifferentThread = message.replyRootId !== nextMessage?.replyRootId\n const prevMessageDifferentAuthor = message.author?.id !== prevMessage?.author?.id\n const nextMessageDifferentAuthor = message.author?.id !== nextMessage?.author?.id\n const prevMessageMoreThan5Minutes =\n prevMessage &&\n new Date(message.createdAt).getTime() - new Date(prevMessage.createdAt).getTime() > 60000 * 5\n const nextMessageMoreThan5Minutes =\n nextMessage &&\n new Date(nextMessage.createdAt).getTime() - new Date(message.createdAt).getTime() > 60000 * 5\n const prevMessageIsDateSeparator =\n prevMessage && date !== moment(prevMessage.createdAt).format('YYYY-MM-DD')\n const nextMessageIsDateSeparator =\n nextMessage && date !== moment(nextMessage.createdAt).format('YYYY-MM-DD')\n const insertReplyShadowMessage =\n message.replyRootId &&\n !threadRoot &&\n (prevMessageDifferentThread || prevMessageIsDateSeparator)\n\n if (message.mine && !encounteredOneOfMyMessages) {\n encounteredOneOfMyMessages = true\n message.myLatestInConversation = true\n } else {\n message.myLatestInConversation = false\n }\n message.lastInGroup = !nextMessage || nextMessageDifferentAuthor || nextMessageMoreThan5Minutes\n message.renderAuthor =\n !message.mine && (!prevMessage || prevMessageDifferentAuthor || prevMessageMoreThan5Minutes)\n message.threadPosition = null\n message.nextRendersAuthor = nextMessage?.renderAuthor\n message.isReplyShadowMessage = false\n message.nextIsReplyShadowMessage =\n repliesEnabled &&\n nextMessageInThread &&\n !nextMessageThreadRoot &&\n (nextMessageDifferentThread || nextMessageIsDateSeparator)\n\n if (!inReplyScreen && inThread) {\n message.prevIsMyReply = prevMessage?.mine\n message.nextIsMyReply = nextMessage?.mine\n\n const firstInThread = threadRoot\n const lastInThread = nextMessageDifferentThread || nextMessageIsDateSeparator\n\n if (firstInThread && lastInThread)\n message.threadPosition = null // ensures we don't render a connector for root replies that aren't immediately followed up a reply\n else if (firstInThread) message.threadPosition = 'first'\n else if (lastInThread) message.threadPosition = 'last'\n else message.threadPosition = 'center'\n }\n\n enrichedMessages.push(message)\n\n if (insertReplyShadowMessage && repliesEnabled) {\n enrichedMessages.push({\n type: 'ReplyShadowMessage',\n id: `${message.id}-${message.replyRootId}`,\n messageId: message.replyRootId!,\n isReplyShadowMessage: true,\n nextRendersAuthor: message?.renderAuthor,\n })\n }\n\n if (!prevMessage || date !== moment(prevMessage.createdAt).format('YYYY-MM-DD')) {\n enrichedMessages.push({ type: 'DateSeparator', id: `day-divider-${message.id}`, date })\n }\n })\n\n return enrichedMessages\n}\ninterface ConversationScreenTitleProps extends HeaderTitleProps {\n conversation_id: number\n badge?: ConversationBadgeResource\n deleted?: boolean\n}\n\nexport const ConversationScreenTitle = ({\n conversation_id,\n badge,\n children,\n style,\n deleted,\n}: ConversationScreenTitleProps) => {\n const styles = usePressableHeaderStyle()\n const navigation = useNavigation()\n const resourceType = badge?.pcoResourceType || ''\n const productName = badge?.appName\n const name = badge?.text || undefined\n\n return (\n <PlatformPressable\n accessibilityHint=\"Opens details about members and settings\"\n style={styles.container}\n onPress={() => {\n if (deleted) return\n\n navigation.navigate('ConversationDetails', { conversation_id })\n }}\n >\n <View style={styles.titleWrapper}>\n <HeaderTitle maxFontSizeMultiplier={1} style={style}>\n {children}\n </HeaderTitle>\n {!deleted && <Icon name=\"general.downChevron\" size={12} />}\n </View>\n <Badge\n variant=\"metaSubtle\"\n productLogoName={productName}\n label={resourceType}\n metaLabel={name}\n style={styles.badge}\n maxFontSizeMultiplier={1}\n />\n </PlatformPressable>\n )\n}\n\nconst usePressableHeaderStyle = () => {\n return StyleSheet.create({\n container: {\n alignItems: Platform.select({ android: 'flex-start', default: 'center' }),\n marginRight: Platform.select({ ios: 20, default: 16 }),\n },\n titleWrapper: {\n alignItems: 'center',\n columnGap: 4,\n flexDirection: 'row',\n flexShrink: 1,\n },\n badge: {\n alignSelf: Platform.select({ android: 'flex-start', default: 'center' }),\n marginTop: 2,\n },\n })\n}\n\nconst useStyles = () => {\n const navigationTheme = useNavigationTheme()\n const { bottom } = useSafeAreaInsets()\n\n return StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n backgroundColor: navigationTheme.colors.card,\n paddingBottom: bottom,\n },\n listContainer: {\n paddingVertical: 12,\n },\n listHeader: {\n // Just whitespace to provide space where the typing indicator can be\n height: 16,\n },\n })\n}\n\n/**\n * useEnsureConversationsRouteExists\n */\nconst useEnsureConversationsRouteExists = () => {\n const navigation = useNavigation()\n const { params } = useRoute<RouteProp<ConversationScreenProps['route']>>()\n\n useEffect(() => {\n const navigationState = navigation.getState()\n const routes = navigationState?.routes || []\n const conversationsRoute = routes.find(r => r.name === 'Conversations')\n\n if (conversationsRoute) return\n\n navigation.dispatch(state => {\n return CommonActions.reset({\n ...state,\n routes: [\n { name: 'Conversations', params: { chat_group_graph_id: params?.chat_group_graph_id } },\n ...routes,\n ],\n index: state.index + 1,\n })\n })\n }, [navigation, params?.chat_group_graph_id])\n}\n"]}
@@ -10,6 +10,7 @@ export interface TypingBroadcastDataAttributes {
10
10
  author_id: number;
11
11
  author_name: string;
12
12
  id: string;
13
+ reply_root_id: string | null;
13
14
  }
14
15
  export {};
15
16
  //# sourceMappingURL=typing_events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typing_events.d.ts","sourceRoot":"","sources":["../../../src/types/jolt_events/typing_events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uDAAuD,CAAA;AAE1F,UAAU,mBAAoB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,IAAI,EAAE,6BAA6B,CAAA;CACpC;AAED,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,KAAK,EAAE,kBAAkB,CAAA;IACzB,IAAI,EAAE,mBAAmB,CAAA;CAC1B;AAED,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,EAAE,EAAE,MAAM,CAAA;CACX"}
1
+ {"version":3,"file":"typing_events.d.ts","sourceRoot":"","sources":["../../../src/types/jolt_events/typing_events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uDAAuD,CAAA;AAE1F,UAAU,mBAAoB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,IAAI,EAAE,6BAA6B,CAAA;CACpC;AAED,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,KAAK,EAAE,kBAAkB,CAAA;IACzB,IAAI,EAAE,mBAAmB,CAAA;CAC1B;AAED,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"typing_events.js","sourceRoot":"","sources":["../../../src/types/jolt_events/typing_events.ts"],"names":[],"mappings":"","sourcesContent":["import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'\n\ninterface TypingBroadcastData extends Record<string, unknown> {\n data: TypingBroadcastDataAttributes\n}\n\nexport interface TypingBroadcastEvent extends CustomMessage {\n event: 'typing.broadcast'\n data: TypingBroadcastData\n}\n\nexport interface TypingBroadcastDataAttributes {\n author_id: number\n author_name: string\n id: string\n}\n"]}
1
+ {"version":3,"file":"typing_events.js","sourceRoot":"","sources":["../../../src/types/jolt_events/typing_events.ts"],"names":[],"mappings":"","sourcesContent":["import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'\n\ninterface TypingBroadcastData extends Record<string, unknown> {\n data: TypingBroadcastDataAttributes\n}\n\nexport interface TypingBroadcastEvent extends CustomMessage {\n event: 'typing.broadcast'\n data: TypingBroadcastData\n}\n\nexport interface TypingBroadcastDataAttributes {\n author_id: number\n author_name: string\n id: string\n reply_root_id: string | null\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "3.18.0-rc.7",
3
+ "version": "3.18.0-rc.8",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -58,5 +58,5 @@
58
58
  "react-native-url-polyfill": "^2.0.0",
59
59
  "typescript": "<5.6.0"
60
60
  },
61
- "gitHead": "6d7c028cd363cb5e85d262ff1e8f9df72f1cd9e7"
61
+ "gitHead": "fff0564227516dace7a52c0cb1896b23b6c0e395"
62
62
  }
@@ -80,7 +80,6 @@ export function Message({
80
80
  const isReplyRootMessage = message.replyRootId === message.id
81
81
  const isDeletedReplyRootMessage = isReplyRootMessage && !!message.deletedAt
82
82
 
83
- const messageText = isDeletedReplyRootMessage ? 'Message deleted' : text
84
83
  const replyCountText = pluralize(message.replyCount, 'reply')
85
84
  const messagePendingLabel = isPersisted ? 'Saving' : 'Sending'
86
85
  const replyRootAuthorName = message.replyRootId
@@ -118,6 +117,10 @@ export function Message({
118
117
  }
119
118
  }
120
119
 
120
+ const handleMessagePress = () => {
121
+ setShowMessageMetaToggle(!showMessageMetaToggle)
122
+ }
123
+
121
124
  const handleMessageLongPress = () => {
122
125
  if (!isPersisted) return
123
126
 
@@ -130,6 +133,7 @@ export function Message({
130
133
  reply_root_author_name: replyRootAuthorName,
131
134
  })
132
135
  }
136
+
133
137
  const handleReactionLongPress = (reaction: ReactionCountResource) => {
134
138
  Haptic.impactLight()
135
139
  navigation.navigate('Reactions', {
@@ -162,11 +166,12 @@ export function Message({
162
166
  return (
163
167
  <Pressable
164
168
  onLongPress={handleMessageLongPress}
165
- onPress={() => setShowMessageMetaToggle(!showMessageMetaToggle)}
169
+ onPress={handleMessagePress}
166
170
  onPressIn={handleMessagePressIn}
167
171
  onPressOut={handleMessagePressOut}
168
172
  android_ripple={{ color: colors.androidRippleNeutral, borderless: false, foreground: true }}
169
173
  accessibilityHint="Long press to view message actions like reacting and copying."
174
+ disabled={isDeletedReplyRootMessage}
170
175
  >
171
176
  <Animated.View style={[styles.message, animatedBackgroundColor]}>
172
177
  {!message.mine && (
@@ -190,7 +195,7 @@ export function Message({
190
195
  </View>
191
196
  )}
192
197
  <View style={[styles.messageContent, { marginBottom: messageBottomMargin }]}>
193
- {renderAuthor && (
198
+ {renderAuthor && !isDeletedReplyRootMessage && (
194
199
  <Text variant="footnote" style={styles.authorName}>
195
200
  {message.author.name}
196
201
  </Text>
@@ -199,18 +204,26 @@ export function Message({
199
204
  style={styles.messageBubble}
200
205
  onLayout={e => setMessageBubbleHeight(e.nativeEvent.layout.height)}
201
206
  >
202
- <ErrorBoundary>
203
- <MessageAttachments
204
- attachments={message.attachments}
205
- metaProps={metaProps}
206
- onMessageAttachmentLongPress={handleMessageAttachmentLongPress}
207
- onMessageLongPress={handleMessageLongPress}
208
- />
209
- </ErrorBoundary>
210
- {messageText && (
207
+ {isDeletedReplyRootMessage ? (
211
208
  <View style={styles.messageText}>
212
- <MessageMarkdown text={messageText} />
209
+ <Text style={styles.replyRootDeletedText}>Message deleted</Text>
213
210
  </View>
211
+ ) : (
212
+ <>
213
+ <ErrorBoundary>
214
+ <MessageAttachments
215
+ attachments={message.attachments}
216
+ metaProps={metaProps}
217
+ onMessageAttachmentLongPress={handleMessageAttachmentLongPress}
218
+ onMessageLongPress={handleMessageLongPress}
219
+ />
220
+ </ErrorBoundary>
221
+ {text && (
222
+ <View style={styles.messageText}>
223
+ <MessageMarkdown text={text} />
224
+ </View>
225
+ )}
226
+ </>
214
227
  )}
215
228
  </View>
216
229
  {showReplyCountButton && (
@@ -224,7 +237,7 @@ export function Message({
224
237
  {replyCountText}
225
238
  </TextButton>
226
239
  )}
227
- {hasReactions && (
240
+ {hasReactions && !isDeletedReplyRootMessage && (
228
241
  <View style={styles.messageReactions}>
229
242
  {reactionCounts.map(reaction => (
230
243
  <MessageReaction
@@ -237,7 +250,7 @@ export function Message({
237
250
  ))}
238
251
  </View>
239
252
  )}
240
- {showMessageMeta && (
253
+ {showMessageMeta && !isDeletedReplyRootMessage && (
241
254
  <View style={styles.messageMeta}>
242
255
  {message.mine && !pending && !error && (
243
256
  <MessageReadReceipts
@@ -365,5 +378,9 @@ const useMessageStyles = ({ mine }: MessageResource) => {
365
378
  errorText: {
366
379
  color: colors.statusErrorText,
367
380
  },
381
+ replyRootDeletedText: {
382
+ color: colors.textColorDefaultSecondary,
383
+ fontStyle: 'italic',
384
+ },
368
385
  })
369
386
  }
@@ -1,9 +1,4 @@
1
- import {
2
- RouteProp,
3
- useNavigation,
4
- useTheme as useNavigationTheme,
5
- useRoute,
6
- } from '@react-navigation/native'
1
+ import { useNavigation, useTheme as useNavigationTheme, useRoute } from '@react-navigation/native'
7
2
  import React, { useCallback, useContext, useEffect, useState } from 'react'
8
3
  import {
9
4
  Platform,
@@ -319,9 +314,7 @@ function MessageFormInput() {
319
314
  React.useContext(MessageFormContext)
320
315
  const attachmentError = attachmentUploader?.errorMessage
321
316
 
322
- const route = useRoute<RouteProp<ConversationScreenProps['route']>>()
323
- const conversationId = route.params.conversation_id
324
- const broadcastTypingStatus = useBroadcastTypingStatus(conversationId)
317
+ const broadcastTypingStatus = useBroadcastTypingStatus()
325
318
 
326
319
  const handleTextChange = (newText: string) => {
327
320
  setText(newText)
@@ -41,16 +41,12 @@ const TypingDots = () => {
41
41
  )
42
42
  }
43
43
 
44
- interface TypingIndicatorProps {
45
- conversationId: number
46
- }
47
-
48
44
  /**
49
45
  * Component to display typing indicators in a conversation
50
46
  * Shows "X is typing..." with animated dots
51
47
  */
52
- export const TypingIndicator = ({ conversationId }: TypingIndicatorProps) => {
53
- const typingPeople = useTypingIndicators(conversationId)
48
+ export const TypingIndicator = () => {
49
+ const typingPeople = useTypingIndicators()
54
50
  const styles = useStyles()
55
51
  const enabled = typingPeople.length > 0
56
52
 
@@ -0,0 +1,34 @@
1
+ import React, { createContext, PropsWithChildren, useContext, useMemo } from 'react'
2
+
3
+ interface ConversationContextValue {
4
+ conversationId: number
5
+ currentPageReplyRootId: string | null
6
+ }
7
+
8
+ interface ConversationContextProviderProps extends PropsWithChildren {
9
+ conversationId: number
10
+ currentPageReplyRootId: string | null
11
+ }
12
+
13
+ const ConversationContext = createContext<ConversationContextValue>({
14
+ conversationId: 0,
15
+ currentPageReplyRootId: null,
16
+ })
17
+
18
+ export const ConversationContextProvider = ({
19
+ children,
20
+ conversationId,
21
+ currentPageReplyRootId,
22
+ }: ConversationContextProviderProps) => {
23
+ const value = useMemo(
24
+ () => ({
25
+ conversationId,
26
+ currentPageReplyRootId,
27
+ }),
28
+ [conversationId, currentPageReplyRootId]
29
+ )
30
+
31
+ return <ConversationContext.Provider value={value}>{children}</ConversationContext.Provider>
32
+ }
33
+
34
+ export const useConversationContext = () => useContext(ConversationContext)
@@ -1,5 +1,6 @@
1
1
  import { useCallback, useRef } from 'react'
2
2
  import { useApiClient } from './use_api_client'
3
+ import { useConversationContext } from '../contexts/conversation_context'
3
4
 
4
5
  const THROTTLE_INTERVAL = 3000 // 3 seconds
5
6
 
@@ -10,7 +11,8 @@ const THROTTLE_INTERVAL = 3000 // 3 seconds
10
11
  * after receiving a typing event. This is how we can show a steady typing indicator even
11
12
  * if the user types once every 2.9 seconds.
12
13
  */
13
- export const useBroadcastTypingStatus = (conversationId: string | number) => {
14
+ export const useBroadcastTypingStatus = () => {
15
+ const { conversationId, currentPageReplyRootId } = useConversationContext()
14
16
  const apiClient = useApiClient()
15
17
  const lastBroadcastTime = useRef<number>(0)
16
18
 
@@ -26,12 +28,14 @@ export const useBroadcastTypingStatus = (conversationId: string | number) => {
26
28
  apiClient.chat
27
29
  .post({
28
30
  url: `/me/conversations/${conversationId}/broadcast_typing_status`,
29
- data: { data: { type: 'TypingStatus', attributes: {} } },
31
+ data: {
32
+ data: { type: 'TypingStatus', attributes: { reply_root_id: currentPageReplyRootId } },
33
+ },
30
34
  })
31
35
  .catch(error => {
32
36
  console.error('Failed to broadcast typing status:', error)
33
37
  })
34
- }, [apiClient, conversationId])
38
+ }, [apiClient.chat, conversationId, currentPageReplyRootId])
35
39
 
36
40
  return broadcastTypingStatus
37
41
  }
@@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query'
2
2
  import { useMemo } from 'react'
3
3
  import { PersonTyping } from './use_typing_status_cache'
4
4
  import { useCurrentPerson } from './use_current_person'
5
+ import { useConversationContext } from '../contexts/conversation_context'
5
6
 
6
7
  /**
7
8
  * Hook for getting people currently typing in a conversation
@@ -9,9 +10,12 @@ import { useCurrentPerson } from './use_current_person'
9
10
  * The query function itself doesn't do anything, but we add to the cache
10
11
  * from useTypingStatusCache when we receive a typing event.
11
12
  */
12
- export const useTypingIndicators = (conversationId: number) => {
13
+ export const useTypingIndicators = () => {
14
+ const { conversationId, currentPageReplyRootId } = useConversationContext()
13
15
  const cacheKey = useMemo(() => ['conversationTyping', String(conversationId)], [conversationId])
14
16
  const currentPerson = useCurrentPerson()
17
+ const isCurrentPerson = (authorId: number) => authorId === currentPerson?.id
18
+ const inMainConversationView = !currentPageReplyRootId
15
19
  const now = Date.now()
16
20
  const { data } = useQuery({
17
21
  queryKey: cacheKey,
@@ -19,8 +23,16 @@ export const useTypingIndicators = (conversationId: number) => {
19
23
  initialData: stableArray,
20
24
  })
21
25
 
22
- // Filter out expired entries and the current user
23
- return data.filter(person => person.expires > now && person.author_id !== currentPerson?.id)
26
+ return data.filter(({ author_id, expires, reply_root_id }) => {
27
+ if (isCurrentPerson(author_id)) return false
28
+ if (now > expires) return false
29
+
30
+ // If you are in the main conversation view, you will see any message sent
31
+ if (inMainConversationView) return true
32
+
33
+ // If you are in a reply view, you will only see messages sent in this reply thread
34
+ return reply_root_id === currentPageReplyRootId
35
+ })
24
36
  }
25
37
 
26
38
  /**
@@ -36,6 +36,7 @@ import { useConversationJoltEvents } from '../hooks/use_conversation_jolt_events
36
36
  import { JumpToBottomButton } from '../components/conversation/jump_to_bottom_button'
37
37
  import { ReplyShadowMessage } from '../components/conversation/reply_shadow_message'
38
38
  import { availableFeatures, useFeatures } from '../hooks/use_features'
39
+ import { ConversationContextProvider } from '../contexts/conversation_context'
39
40
 
40
41
  export type ConversationRouteProps = {
41
42
  conversation_id: number
@@ -53,6 +54,19 @@ export type ConversationRouteProps = {
53
54
  export type ConversationScreenProps = StaticScreenProps<ConversationRouteProps>
54
55
 
55
56
  export function ConversationScreen({ route }: ConversationScreenProps) {
57
+ const { conversation_id, reply_root_id } = route.params
58
+
59
+ return (
60
+ <ConversationContextProvider
61
+ conversationId={conversation_id}
62
+ currentPageReplyRootId={reply_root_id ?? null}
63
+ >
64
+ <ConversationScreenContent route={route} />
65
+ </ConversationContextProvider>
66
+ )
67
+ }
68
+
69
+ function ConversationScreenContent({ route }: ConversationScreenProps) {
56
70
  const styles = useStyles()
57
71
  const navigation = useNavigation()
58
72
  const { conversation_id, editing_message_id, reply_root_id, reply_root_author_name } =
@@ -179,7 +193,7 @@ export function ConversationScreen({ route }: ConversationScreenProps) {
179
193
  />
180
194
  )}
181
195
  <JumpToBottomButton onPress={handleReturnToBottom} visible={showJumpToBottomButton} />
182
- {!noMessages && <TypingIndicator conversationId={conversation_id} />}
196
+ {!noMessages && <TypingIndicator />}
183
197
  {showLeaderDisabledReplyBanner && <LeaderDisabledRepliesBanner />}
184
198
  {canReply ? (
185
199
  <MessageForm.Root
@@ -13,4 +13,5 @@ export interface TypingBroadcastDataAttributes {
13
13
  author_id: number
14
14
  author_name: string
15
15
  id: string
16
+ reply_root_id: string | null
16
17
  }