@planningcenter/chat-react-native 3.38.0-rc.1 → 3.38.0-rc.11

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 (223) hide show
  1. package/build/components/conversation/jump_to_bottom_button.d.ts +1 -2
  2. package/build/components/conversation/jump_to_bottom_button.d.ts.map +1 -1
  3. package/build/components/conversation/jump_to_bottom_button.js +7 -39
  4. package/build/components/conversation/jump_to_bottom_button.js.map +1 -1
  5. package/build/components/conversation/message_list.d.ts +10 -0
  6. package/build/components/conversation/message_list.d.ts.map +1 -0
  7. package/build/components/conversation/message_list.js +13 -0
  8. package/build/components/conversation/message_list.js.map +1 -0
  9. package/build/components/conversation/reply_shadow_message.d.ts +2 -1
  10. package/build/components/conversation/reply_shadow_message.d.ts.map +1 -1
  11. package/build/components/conversation/reply_shadow_message.js.map +1 -1
  12. package/build/components/display/conversation_avatar.d.ts +2 -1
  13. package/build/components/display/conversation_avatar.d.ts.map +1 -1
  14. package/build/components/display/conversation_avatar.js +6 -5
  15. package/build/components/display/conversation_avatar.js.map +1 -1
  16. package/build/components/display/emoji_avatar.d.ts +3 -1
  17. package/build/components/display/emoji_avatar.d.ts.map +1 -1
  18. package/build/components/display/emoji_avatar.js +2 -2
  19. package/build/components/display/emoji_avatar.js.map +1 -1
  20. package/build/components/display/icon_avatar.d.ts +3 -1
  21. package/build/components/display/icon_avatar.d.ts.map +1 -1
  22. package/build/components/display/icon_avatar.js +2 -2
  23. package/build/components/display/icon_avatar.js.map +1 -1
  24. package/build/contexts/conversation_context.d.ts +1 -8
  25. package/build/contexts/conversation_context.d.ts.map +1 -1
  26. package/build/contexts/conversation_context.js +3 -21
  27. package/build/contexts/conversation_context.js.map +1 -1
  28. package/build/hooks/groups/use_group_chat_conversation_payload.d.ts.map +1 -1
  29. package/build/hooks/groups/use_group_chat_conversation_payload.js +1 -0
  30. package/build/hooks/groups/use_group_chat_conversation_payload.js.map +1 -1
  31. package/build/hooks/index.d.ts +1 -0
  32. package/build/hooks/index.d.ts.map +1 -1
  33. package/build/hooks/index.js +1 -0
  34. package/build/hooks/index.js.map +1 -1
  35. package/build/hooks/use_conversation_messages.d.ts +6 -15
  36. package/build/hooks/use_conversation_messages.d.ts.map +1 -1
  37. package/build/hooks/use_conversation_messages.js +9 -62
  38. package/build/hooks/use_conversation_messages.js.map +1 -1
  39. package/build/hooks/use_conversation_messages_jolt_events.d.ts.map +1 -1
  40. package/build/hooks/use_conversation_messages_jolt_events.js +4 -4
  41. package/build/hooks/use_conversation_messages_jolt_events.js.map +1 -1
  42. package/build/hooks/use_conversations_actions.d.ts +0 -5
  43. package/build/hooks/use_conversations_actions.d.ts.map +1 -1
  44. package/build/hooks/use_conversations_actions.js +0 -12
  45. package/build/hooks/use_conversations_actions.js.map +1 -1
  46. package/build/hooks/use_features.d.ts +0 -1
  47. package/build/hooks/use_features.d.ts.map +1 -1
  48. package/build/hooks/use_features.js +0 -1
  49. package/build/hooks/use_features.js.map +1 -1
  50. package/build/hooks/use_mark_latest_message_read.d.ts +1 -1
  51. package/build/hooks/use_mark_latest_message_read.d.ts.map +1 -1
  52. package/build/hooks/use_mark_latest_message_read.js +1 -17
  53. package/build/hooks/use_mark_latest_message_read.js.map +1 -1
  54. package/build/hooks/use_preview_avatar_diameter.d.ts +2 -0
  55. package/build/hooks/use_preview_avatar_diameter.d.ts.map +1 -0
  56. package/build/hooks/use_preview_avatar_diameter.js +11 -0
  57. package/build/hooks/use_preview_avatar_diameter.js.map +1 -0
  58. package/build/hooks/use_suspense_api.d.ts +0 -1
  59. package/build/hooks/use_suspense_api.d.ts.map +1 -1
  60. package/build/hooks/use_suspense_api.js +1 -1
  61. package/build/hooks/use_suspense_api.js.map +1 -1
  62. package/build/jest.js +1 -1
  63. package/build/jest.js.map +1 -1
  64. package/build/screens/avatar_picker/avatar_picker_screen.d.ts.map +1 -1
  65. package/build/screens/avatar_picker/avatar_picker_screen.js +11 -9
  66. package/build/screens/avatar_picker/avatar_picker_screen.js.map +1 -1
  67. package/build/screens/avatar_picker/avatar_preview.d.ts.map +1 -1
  68. package/build/screens/avatar_picker/avatar_preview.js +13 -5
  69. package/build/screens/avatar_picker/avatar_preview.js.map +1 -1
  70. package/build/screens/avatar_picker/emoji_tab.d.ts.map +1 -1
  71. package/build/screens/avatar_picker/emoji_tab.js +3 -7
  72. package/build/screens/avatar_picker/emoji_tab.js.map +1 -1
  73. package/build/screens/avatar_picker/upload_tab.d.ts.map +1 -1
  74. package/build/screens/avatar_picker/upload_tab.js +2 -1
  75. package/build/screens/avatar_picker/upload_tab.js.map +1 -1
  76. package/build/screens/conversation_details_screen.d.ts.map +1 -1
  77. package/build/screens/conversation_details_screen.js +5 -2
  78. package/build/screens/conversation_details_screen.js.map +1 -1
  79. package/build/screens/conversation_filter_recipients/components/header_row.d.ts.map +1 -1
  80. package/build/screens/conversation_filter_recipients/components/header_row.js +3 -2
  81. package/build/screens/conversation_filter_recipients/components/header_row.js.map +1 -1
  82. package/build/screens/conversation_filter_recipients/hooks/use_flattened_array_of_service_types_with_teams.d.ts.map +1 -1
  83. package/build/screens/conversation_filter_recipients/hooks/use_flattened_array_of_service_types_with_teams.js +47 -18
  84. package/build/screens/conversation_filter_recipients/hooks/use_flattened_array_of_service_types_with_teams.js.map +1 -1
  85. package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.d.ts +2 -1
  86. package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.d.ts.map +1 -1
  87. package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.js +23 -26
  88. package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.js.map +1 -1
  89. package/build/screens/conversation_filter_recipients/types.d.ts +1 -1
  90. package/build/screens/conversation_filter_recipients/types.d.ts.map +1 -1
  91. package/build/screens/conversation_filter_recipients/types.js.map +1 -1
  92. package/build/screens/conversation_screen.d.ts +0 -1
  93. package/build/screens/conversation_screen.d.ts.map +1 -1
  94. package/build/screens/conversation_screen.js +45 -96
  95. package/build/screens/conversation_screen.js.map +1 -1
  96. package/build/screens/conversation_select_recipients/components/recipient_link_row.d.ts +1 -1
  97. package/build/screens/conversation_select_recipients/components/recipient_link_row.d.ts.map +1 -1
  98. package/build/screens/conversation_select_recipients/components/recipient_link_row.js +3 -3
  99. package/build/screens/conversation_select_recipients/components/recipient_link_row.js.map +1 -1
  100. package/build/screens/conversation_select_recipients/components/team_recipient_row.d.ts.map +1 -1
  101. package/build/screens/conversation_select_recipients/components/team_recipient_row.js +1 -1
  102. package/build/screens/conversation_select_recipients/components/team_recipient_row.js.map +1 -1
  103. package/build/screens/team_conversation_screen.d.ts.map +1 -1
  104. package/build/screens/team_conversation_screen.js +24 -1
  105. package/build/screens/team_conversation_screen.js.map +1 -1
  106. package/build/utils/cache/messages_cache.d.ts +0 -1
  107. package/build/utils/cache/messages_cache.d.ts.map +1 -1
  108. package/build/utils/cache/messages_cache.js +0 -4
  109. package/build/utils/cache/messages_cache.js.map +1 -1
  110. package/build/utils/client/client.d.ts +1 -1
  111. package/build/utils/client/client.d.ts.map +1 -1
  112. package/build/utils/client/client.js +7 -6
  113. package/build/utils/client/client.js.map +1 -1
  114. package/build/utils/client/instrumented_fetch.js +3 -5
  115. package/build/utils/client/instrumented_fetch.js.map +1 -1
  116. package/build/utils/group_messages.d.ts +2 -9
  117. package/build/utils/group_messages.d.ts.map +1 -1
  118. package/build/utils/group_messages.js +1 -20
  119. package/build/utils/group_messages.js.map +1 -1
  120. package/package.json +4 -4
  121. package/src/__tests__/hooks/use_group_chat_conversation_payload.test.tsx +50 -0
  122. package/src/__tests__/jest.ts +1 -1
  123. package/src/__tests__/utils/client.ts +32 -0
  124. package/src/components/conversation/__tests__/message_list.test.tsx +14 -0
  125. package/src/components/conversation/jump_to_bottom_button.tsx +8 -57
  126. package/src/components/conversation/message_list.tsx +42 -0
  127. package/src/components/conversation/reply_shadow_message.tsx +1 -1
  128. package/src/components/display/conversation_avatar.tsx +7 -5
  129. package/src/components/display/emoji_avatar.tsx +10 -2
  130. package/src/components/display/icon_avatar.tsx +10 -2
  131. package/src/contexts/conversation_context.tsx +2 -30
  132. package/src/hooks/groups/use_group_chat_conversation_payload.ts +1 -0
  133. package/src/hooks/index.ts +1 -0
  134. package/src/hooks/use_conversation_messages.ts +20 -120
  135. package/src/hooks/use_conversation_messages_jolt_events.ts +3 -4
  136. package/src/hooks/use_conversations_actions.ts +0 -15
  137. package/src/hooks/use_features.ts +0 -1
  138. package/src/hooks/use_mark_latest_message_read.ts +2 -16
  139. package/src/hooks/use_preview_avatar_diameter.ts +12 -0
  140. package/src/hooks/use_suspense_api.ts +1 -1
  141. package/src/jest.ts +1 -1
  142. package/src/screens/avatar_picker/avatar_picker_screen.tsx +25 -9
  143. package/src/screens/avatar_picker/avatar_preview.tsx +14 -5
  144. package/src/screens/avatar_picker/emoji_tab.tsx +3 -6
  145. package/src/screens/avatar_picker/upload_tab.tsx +2 -0
  146. package/src/screens/conversation_details_screen.tsx +10 -1
  147. package/src/screens/conversation_filter_recipients/components/header_row.tsx +3 -2
  148. package/src/screens/conversation_filter_recipients/hooks/__tests__/use_service_types_with_teams.test.ts +108 -0
  149. package/src/screens/conversation_filter_recipients/hooks/use_flattened_array_of_service_types_with_teams.tsx +46 -19
  150. package/src/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.ts +31 -29
  151. package/src/screens/conversation_filter_recipients/types.tsx +1 -1
  152. package/src/screens/conversation_screen.tsx +69 -186
  153. package/src/screens/conversation_select_recipients/components/recipient_link_row.tsx +6 -4
  154. package/src/screens/conversation_select_recipients/components/team_recipient_row.tsx +2 -1
  155. package/src/screens/team_conversation_screen.tsx +33 -1
  156. package/src/utils/__tests__/group_messages.test.ts +0 -71
  157. package/src/utils/cache/messages_cache.ts +0 -5
  158. package/src/utils/client/__tests__/instrumented_fetch.test.ts +9 -5
  159. package/src/utils/client/client.ts +9 -7
  160. package/src/utils/client/instrumented_fetch.ts +3 -6
  161. package/src/utils/group_messages.ts +2 -42
  162. package/build/components/conversation/unread_divider.d.ts +0 -6
  163. package/build/components/conversation/unread_divider.d.ts.map +0 -1
  164. package/build/components/conversation/unread_divider.js +0 -59
  165. package/build/components/conversation/unread_divider.js.map +0 -1
  166. package/build/hooks/use_flat_list_viewability.d.ts +0 -20
  167. package/build/hooks/use_flat_list_viewability.d.ts.map +0 -1
  168. package/build/hooks/use_flat_list_viewability.js +0 -30
  169. package/build/hooks/use_flat_list_viewability.js.map +0 -1
  170. package/build/hooks/use_jump_to_bottom_action.d.ts +0 -9
  171. package/build/hooks/use_jump_to_bottom_action.d.ts.map +0 -1
  172. package/build/hooks/use_jump_to_bottom_action.js +0 -62
  173. package/build/hooks/use_jump_to_bottom_action.js.map +0 -1
  174. package/build/hooks/use_jump_to_unread_anchor.d.ts +0 -20
  175. package/build/hooks/use_jump_to_unread_anchor.d.ts.map +0 -1
  176. package/build/hooks/use_jump_to_unread_anchor.js +0 -53
  177. package/build/hooks/use_jump_to_unread_anchor.js.map +0 -1
  178. package/build/hooks/use_jump_to_unread_gates.d.ts +0 -5
  179. package/build/hooks/use_jump_to_unread_gates.d.ts.map +0 -1
  180. package/build/hooks/use_jump_to_unread_gates.js +0 -10
  181. package/build/hooks/use_jump_to_unread_gates.js.map +0 -1
  182. package/build/hooks/use_scroll_tracking.d.ts +0 -13
  183. package/build/hooks/use_scroll_tracking.d.ts.map +0 -1
  184. package/build/hooks/use_scroll_tracking.js +0 -45
  185. package/build/hooks/use_scroll_tracking.js.map +0 -1
  186. package/build/hooks/use_track_highest_seen_message.d.ts +0 -4
  187. package/build/hooks/use_track_highest_seen_message.d.ts.map +0 -1
  188. package/build/hooks/use_track_highest_seen_message.js +0 -35
  189. package/build/hooks/use_track_highest_seen_message.js.map +0 -1
  190. package/build/utils/conversation_messages.d.ts +0 -10
  191. package/build/utils/conversation_messages.d.ts.map +0 -1
  192. package/build/utils/conversation_messages.js +0 -22
  193. package/build/utils/conversation_messages.js.map +0 -1
  194. package/build/utils/highest_seen_tracker.d.ts +0 -12
  195. package/build/utils/highest_seen_tracker.d.ts.map +0 -1
  196. package/build/utils/highest_seen_tracker.js +0 -37
  197. package/build/utils/highest_seen_tracker.js.map +0 -1
  198. package/build/utils/message_viewability.d.ts +0 -24
  199. package/build/utils/message_viewability.d.ts.map +0 -1
  200. package/build/utils/message_viewability.js +0 -29
  201. package/build/utils/message_viewability.js.map +0 -1
  202. package/build/utils/unread_divider_helpers.d.ts +0 -18
  203. package/build/utils/unread_divider_helpers.d.ts.map +0 -1
  204. package/build/utils/unread_divider_helpers.js +0 -13
  205. package/build/utils/unread_divider_helpers.js.map +0 -1
  206. package/src/__tests__/hooks/use_conversation_messages.test.tsx +0 -109
  207. package/src/__tests__/hooks/use_mark_latest_message_read.test.tsx +0 -154
  208. package/src/__tests__/utils/cache/messages_cache.test.ts +0 -54
  209. package/src/components/conversation/unread_divider.tsx +0 -90
  210. package/src/hooks/use_flat_list_viewability.ts +0 -50
  211. package/src/hooks/use_jump_to_bottom_action.ts +0 -75
  212. package/src/hooks/use_jump_to_unread_anchor.ts +0 -68
  213. package/src/hooks/use_jump_to_unread_gates.ts +0 -10
  214. package/src/hooks/use_scroll_tracking.ts +0 -64
  215. package/src/hooks/use_track_highest_seen_message.ts +0 -43
  216. package/src/utils/__tests__/conversation_messages.test.ts +0 -105
  217. package/src/utils/__tests__/highest_seen_tracker.test.ts +0 -82
  218. package/src/utils/__tests__/message_viewability.test.ts +0 -168
  219. package/src/utils/__tests__/unread_divider_helpers.test.ts +0 -85
  220. package/src/utils/conversation_messages.ts +0 -37
  221. package/src/utils/highest_seen_tracker.ts +0 -42
  222. package/src/utils/message_viewability.ts +0 -49
  223. package/src/utils/unread_divider_helpers.ts +0 -25
@@ -9,6 +9,7 @@ export const HeaderRow = ({ data, nativeID, style, setTeamFilters }) => {
9
9
  const styles = useStyles();
10
10
  const route = useRoute();
11
11
  const { serviceTypeName, teamIdsForServiceType } = data;
12
+ const displayName = serviceTypeName ?? 'No service type';
12
13
  const { team_ids: currentTeamIds = [] } = route.params;
13
14
  const newTeamIdsAdded = [...new Set([...currentTeamIds, ...teamIdsForServiceType])];
14
15
  const newTeamIdsRemoved = currentTeamIds.filter(id => !teamIdsForServiceType.includes(id));
@@ -16,7 +17,7 @@ export const HeaderRow = ({ data, nativeID, style, setTeamFilters }) => {
16
17
  const showSelectAll = teamIdsForServiceType.length <= BULK_SELECT_LIMIT;
17
18
  const selectLabel = allTeamsSelected ? 'Deselect' : 'Select';
18
19
  const headingAccessibilityHint = `${pluralize(teamIdsForServiceType.length, 'team')} available to select`;
19
- const selectAllAccessibilityLabel = `${selectLabel} ${pluralize(teamIdsForServiceType.length, 'team')} for ${serviceTypeName}`;
20
+ const selectAllAccessibilityLabel = `${selectLabel} ${pluralize(teamIdsForServiceType.length, 'team')} for ${displayName}`;
20
21
  const handleSelectAll = () => {
21
22
  setTeamFilters({
22
23
  team_ids: allTeamsSelected ? newTeamIdsRemoved : newTeamIdsAdded,
@@ -26,7 +27,7 @@ export const HeaderRow = ({ data, nativeID, style, setTeamFilters }) => {
26
27
  <View style={styles.headerContent}>
27
28
  <Icon name="services.folderClosed" style={styles.headerIcon}/>
28
29
  <Heading variant="h3" style={styles.headerText} numberOfLines={2} nativeID={nativeID} accessibilityHint={headingAccessibilityHint}>
29
- {serviceTypeName}
30
+ {displayName}
30
31
  </Heading>
31
32
  </View>
32
33
 
@@ -1 +1 @@
1
- {"version":3,"file":"header_row.js","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/components/header_row.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,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eAAe,EAAE,MAAM,CAAC,eAAe;SACxC;QACD,UAAU,EAAE;YACV,UAAU,EAAE,QAAQ;YACpB,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,MAAM,CAAC,uBAAuB;YACrC,QAAQ,EAAE,MAAM,CAAC,UAAU;SAC5B;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,EAAE;YACP,IAAI,EAAE,CAAC;SACR;QACD,UAAU,EAAE;YACV,KAAK,EAAE,MAAM,CAAC,WAAW;YACzB,QAAQ,EAAE,MAAM,CAAC,UAAU;SAC5B;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useRoute, type RouteProp } from '@react-navigation/native'\nimport { View, StyleSheet, type ViewStyle } from 'react-native'\nimport { Icon, Heading, TextButton } from '../../../components'\nimport { useTheme } from '../../../hooks'\nimport { pluralize } from '../../../utils'\nimport { tokens } from '../../../vendor/tapestry/tokens'\nimport type {\n ConversationFilterRecipientsScreenProps,\n ServiceTypeProps,\n SetTeamFilters,\n} from '../types'\n\nconst BULK_SELECT_LIMIT = 10\n\ninterface HeaderRowProps {\n data: ServiceTypeProps\n nativeID: string\n style?: ViewStyle\n setTeamFilters: SetTeamFilters\n}\n\nexport const HeaderRow = ({ data, nativeID, style, setTeamFilters }: HeaderRowProps) => {\n const styles = useStyles()\n const route = useRoute<RouteProp<ConversationFilterRecipientsScreenProps['route']>>()\n\n const { serviceTypeName, teamIdsForServiceType } = data\n const { team_ids: currentTeamIds = [] } = route.params\n\n const newTeamIdsAdded = [...new Set([...currentTeamIds, ...teamIdsForServiceType])]\n const newTeamIdsRemoved = currentTeamIds.filter(id => !teamIdsForServiceType.includes(id))\n\n const allTeamsSelected = teamIdsForServiceType.every(id => currentTeamIds.includes(id))\n const showSelectAll = teamIdsForServiceType.length <= BULK_SELECT_LIMIT\n const selectLabel = allTeamsSelected ? 'Deselect' : 'Select'\n\n const headingAccessibilityHint = `${pluralize(teamIdsForServiceType.length, 'team')} available to select`\n const selectAllAccessibilityLabel = `${selectLabel} ${pluralize(teamIdsForServiceType.length, 'team')} for ${serviceTypeName}`\n\n const handleSelectAll = () => {\n setTeamFilters({\n team_ids: allTeamsSelected ? newTeamIdsRemoved : newTeamIdsAdded,\n })\n }\n\n return (\n <View style={[styles.headerRow, style]}>\n <View style={styles.headerContent}>\n <Icon name=\"services.folderClosed\" style={styles.headerIcon} />\n <Heading\n variant=\"h3\"\n style={styles.headerText}\n numberOfLines={2}\n nativeID={nativeID}\n accessibilityHint={headingAccessibilityHint}\n >\n {serviceTypeName}\n </Heading>\n </View>\n\n {showSelectAll && (\n <TextButton\n variant=\"tertiary\"\n onPress={handleSelectAll}\n accessibilityLabel={selectAllAccessibilityLabel}\n >\n {selectLabel} all\n </TextButton>\n )}\n </View>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n headerRow: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n padding: 16,\n gap: 12,\n backgroundColor: colors.surfaceColor100,\n },\n headerText: {\n fontWeight: 'normal',\n flex: 1,\n color: colors.textColorDefaultPrimary,\n fontSize: tokens.fontSizeSm,\n },\n headerContent: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 12,\n flex: 1,\n },\n headerIcon: {\n color: colors.interaction,\n fontSize: tokens.fontSizeMd,\n },\n })\n}\n"]}
1
+ {"version":3,"file":"header_row.js","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/components/header_row.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,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B,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,EAAE;YACX,GAAG,EAAE,EAAE;YACP,eAAe,EAAE,MAAM,CAAC,eAAe;SACxC;QACD,UAAU,EAAE;YACV,UAAU,EAAE,QAAQ;YACpB,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,MAAM,CAAC,uBAAuB;YACrC,QAAQ,EAAE,MAAM,CAAC,UAAU;SAC5B;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,EAAE;YACP,IAAI,EAAE,CAAC;SACR;QACD,UAAU,EAAE;YACV,KAAK,EAAE,MAAM,CAAC,WAAW;YACzB,QAAQ,EAAE,MAAM,CAAC,UAAU;SAC5B;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useRoute, type RouteProp } from '@react-navigation/native'\nimport { View, StyleSheet, type ViewStyle } from 'react-native'\nimport { Icon, Heading, TextButton } from '../../../components'\nimport { useTheme } from '../../../hooks'\nimport { pluralize } from '../../../utils'\nimport { tokens } from '../../../vendor/tapestry/tokens'\nimport type {\n ConversationFilterRecipientsScreenProps,\n ServiceTypeProps,\n SetTeamFilters,\n} from '../types'\n\nconst BULK_SELECT_LIMIT = 10\n\ninterface HeaderRowProps {\n data: ServiceTypeProps\n nativeID: string\n style?: ViewStyle\n setTeamFilters: SetTeamFilters\n}\n\nexport const HeaderRow = ({ data, nativeID, style, setTeamFilters }: HeaderRowProps) => {\n const styles = useStyles()\n const route = useRoute<RouteProp<ConversationFilterRecipientsScreenProps['route']>>()\n\n const { serviceTypeName, teamIdsForServiceType } = data\n const displayName = serviceTypeName ?? 'No service type'\n const { team_ids: currentTeamIds = [] } = route.params\n\n const newTeamIdsAdded = [...new Set([...currentTeamIds, ...teamIdsForServiceType])]\n const newTeamIdsRemoved = currentTeamIds.filter(id => !teamIdsForServiceType.includes(id))\n\n const allTeamsSelected = teamIdsForServiceType.every(id => currentTeamIds.includes(id))\n const showSelectAll = teamIdsForServiceType.length <= BULK_SELECT_LIMIT\n const selectLabel = allTeamsSelected ? 'Deselect' : 'Select'\n\n const headingAccessibilityHint = `${pluralize(teamIdsForServiceType.length, 'team')} available to select`\n const selectAllAccessibilityLabel = `${selectLabel} ${pluralize(teamIdsForServiceType.length, 'team')} for ${displayName}`\n\n const handleSelectAll = () => {\n setTeamFilters({\n team_ids: allTeamsSelected ? newTeamIdsRemoved : newTeamIdsAdded,\n })\n }\n\n return (\n <View style={[styles.headerRow, style]}>\n <View style={styles.headerContent}>\n <Icon name=\"services.folderClosed\" style={styles.headerIcon} />\n <Heading\n variant=\"h3\"\n style={styles.headerText}\n numberOfLines={2}\n nativeID={nativeID}\n accessibilityHint={headingAccessibilityHint}\n >\n {displayName}\n </Heading>\n </View>\n\n {showSelectAll && (\n <TextButton\n variant=\"tertiary\"\n onPress={handleSelectAll}\n accessibilityLabel={selectAllAccessibilityLabel}\n >\n {selectLabel} all\n </TextButton>\n )}\n </View>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n headerRow: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n padding: 16,\n gap: 12,\n backgroundColor: colors.surfaceColor100,\n },\n headerText: {\n fontWeight: 'normal',\n flex: 1,\n color: colors.textColorDefaultPrimary,\n fontSize: tokens.fontSizeSm,\n },\n headerContent: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 12,\n flex: 1,\n },\n headerIcon: {\n color: colors.interaction,\n fontSize: tokens.fontSizeMd,\n },\n })\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"use_flattened_array_of_service_types_with_teams.d.ts","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/hooks/use_flattened_array_of_service_types_with_teams.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAgB,KAAK,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAExF,UAAU,KAAK;IACb,IAAI,EAAE,oBAAoB,EAAE,CAAA;IAC5B,aAAa,EAAE,SAAS,CAAA;IACxB,YAAY,EAAE,SAAS,CAAA;CACxB;AAED,wBAAgB,wCAAwC,CAAC,EACvD,IAAI,EACJ,aAAa,EACb,YAAY,GACb,EAAE,KAAK,mBAmCP"}
1
+ {"version":3,"file":"use_flattened_array_of_service_types_with_teams.d.ts","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/hooks/use_flattened_array_of_service_types_with_teams.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAgB,KAAK,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAExF,UAAU,KAAK;IACb,IAAI,EAAE,oBAAoB,EAAE,CAAA;IAC5B,aAAa,EAAE,SAAS,CAAA;IACxB,YAAY,EAAE,SAAS,CAAA;CACxB;AAED,wBAAgB,wCAAwC,CAAC,EACvD,IAAI,EACJ,aAAa,EACb,YAAY,GACb,EAAE,KAAK,mBA8DP"}
@@ -1,32 +1,61 @@
1
1
  import { useMemo } from 'react';
2
2
  import { SectionTypes } from '../types';
3
3
  export function useFlattenedArrayOfServiceTypesWithTeams({ data, firstRowStyle, lastRowStyle, }) {
4
- const flattenedData = useMemo(() => data.flatMap(serviceType => {
5
- const teamIdsForServiceType = serviceType.teams.map(team => team.id);
6
- return [
7
- {
8
- type: SectionTypes.header,
9
- data: {
10
- serviceTypeName: serviceType.name,
11
- serviceTypeId: serviceType.id,
12
- teamIdsForServiceType,
4
+ const flattenedData = useMemo(() => {
5
+ const serviceTypeRows = data
6
+ .filter(serviceType => serviceType.id > 0)
7
+ .flatMap(serviceType => {
8
+ const teamIdsForServiceType = serviceType.teams.map(team => team.id);
9
+ return [
10
+ {
11
+ type: SectionTypes.header,
12
+ data: {
13
+ serviceTypeName: serviceType.name,
14
+ serviceTypeId: serviceType.id,
15
+ teamIdsForServiceType,
16
+ },
17
+ sectionStyle: firstRowStyle,
13
18
  },
14
- sectionStyle: firstRowStyle,
15
- },
16
- ...serviceType.teams.map((team, teamIdx) => {
17
- const isLastTeamInServiceType = teamIdx === serviceType.teams.length - 1;
18
- return {
19
+ ...serviceType.teams.map((team, teamIdx) => ({
19
20
  type: SectionTypes.team,
20
21
  data: {
21
22
  teamName: team.name,
22
23
  teamId: team.id,
23
24
  serviceTypeId: serviceType.id,
24
25
  },
25
- sectionStyle: isLastTeamInServiceType ? lastRowStyle : undefined,
26
- };
27
- }),
26
+ sectionStyle: teamIdx === serviceType.teams.length - 1 ? lastRowStyle : undefined,
27
+ })),
28
+ ];
29
+ });
30
+ // Teams without a service type (id < 0) are merged under a single "No service type" section.
31
+ // Service type ID 0 is a safe sentinel — real IDs are always positive.
32
+ const serviceTypelessTeams = data
33
+ .filter(serviceType => serviceType.id < 0)
34
+ .flatMap(serviceType => serviceType.teams);
35
+ if (serviceTypelessTeams.length === 0)
36
+ return serviceTypeRows;
37
+ const serviceTypelessRows = [
38
+ {
39
+ type: SectionTypes.header,
40
+ data: {
41
+ serviceTypeName: null,
42
+ serviceTypeId: 0,
43
+ teamIdsForServiceType: serviceTypelessTeams.map(t => t.id),
44
+ },
45
+ sectionStyle: firstRowStyle,
46
+ },
47
+ ...serviceTypelessTeams.map((team, teamIdx) => ({
48
+ type: SectionTypes.team,
49
+ data: {
50
+ teamName: team.name,
51
+ teamId: team.id,
52
+ serviceTypeId: 0,
53
+ },
54
+ sectionStyle: teamIdx === serviceTypelessTeams.length - 1 ? lastRowStyle : undefined,
55
+ })),
28
56
  ];
29
- }), [data, firstRowStyle, lastRowStyle]);
57
+ return [...serviceTypelessRows, ...serviceTypeRows];
58
+ }, [data, firstRowStyle, lastRowStyle]);
30
59
  return flattenedData;
31
60
  }
32
61
  //# sourceMappingURL=use_flattened_array_of_service_types_with_teams.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use_flattened_array_of_service_types_with_teams.js","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/hooks/use_flattened_array_of_service_types_with_teams.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,YAAY,EAAmD,MAAM,UAAU,CAAA;AAQxF,MAAM,UAAU,wCAAwC,CAAC,EACvD,IAAI,EACJ,aAAa,EACb,YAAY,GACN;IACN,MAAM,aAAa,GAAoB,OAAO,CAC5C,GAAG,EAAE,CACH,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QACzB,MAAM,qBAAqB,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAEpE,OAAO;YACL;gBACE,IAAI,EAAE,YAAY,CAAC,MAAe;gBAClC,IAAI,EAAE;oBACJ,eAAe,EAAE,WAAW,CAAC,IAAI;oBACjC,aAAa,EAAE,WAAW,CAAC,EAAE;oBAC7B,qBAAqB;iBACtB;gBACD,YAAY,EAAE,aAAa;aAC5B;YACD,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;gBACzC,MAAM,uBAAuB,GAAG,OAAO,KAAK,WAAW,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;gBAExE,OAAO;oBACL,IAAI,EAAE,YAAY,CAAC,IAAa;oBAChC,IAAI,EAAE;wBACJ,QAAQ,EAAE,IAAI,CAAC,IAAI;wBACnB,MAAM,EAAE,IAAI,CAAC,EAAE;wBACf,aAAa,EAAE,WAAW,CAAC,EAAE;qBAC9B;oBACD,YAAY,EAAE,uBAAuB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;iBACjE,CAAA;YACH,CAAC,CAAC;SACH,CAAA;IACH,CAAC,CAAC,EACJ,CAAC,IAAI,EAAE,aAAa,EAAE,YAAY,CAAC,CACpC,CAAA;IAED,OAAO,aAAa,CAAA;AACtB,CAAC","sourcesContent":["import { useMemo } from 'react'\nimport { type ViewStyle } from 'react-native'\nimport { SectionTypes, type SectionListData, type ServiceTypeWithTeams } from '../types'\n\ninterface Props {\n data: ServiceTypeWithTeams[]\n firstRowStyle: ViewStyle\n lastRowStyle: ViewStyle\n}\n\nexport function useFlattenedArrayOfServiceTypesWithTeams({\n data,\n firstRowStyle,\n lastRowStyle,\n}: Props) {\n const flattenedData: SectionListData = useMemo(\n () =>\n data.flatMap(serviceType => {\n const teamIdsForServiceType = serviceType.teams.map(team => team.id)\n\n return [\n {\n type: SectionTypes.header as const,\n data: {\n serviceTypeName: serviceType.name,\n serviceTypeId: serviceType.id,\n teamIdsForServiceType,\n },\n sectionStyle: firstRowStyle,\n },\n ...serviceType.teams.map((team, teamIdx) => {\n const isLastTeamInServiceType = teamIdx === serviceType.teams.length - 1\n\n return {\n type: SectionTypes.team as const,\n data: {\n teamName: team.name,\n teamId: team.id,\n serviceTypeId: serviceType.id,\n },\n sectionStyle: isLastTeamInServiceType ? lastRowStyle : undefined,\n }\n }),\n ]\n }),\n [data, firstRowStyle, lastRowStyle]\n )\n\n return flattenedData\n}\n"]}
1
+ {"version":3,"file":"use_flattened_array_of_service_types_with_teams.js","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/hooks/use_flattened_array_of_service_types_with_teams.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,YAAY,EAAmD,MAAM,UAAU,CAAA;AAQxF,MAAM,UAAU,wCAAwC,CAAC,EACvD,IAAI,EACJ,aAAa,EACb,YAAY,GACN;IACN,MAAM,aAAa,GAAoB,OAAO,CAAC,GAAG,EAAE;QAClD,MAAM,eAAe,GAAG,IAAI;aACzB,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC,CAAC;aACzC,OAAO,CAAC,WAA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E,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC3D;gBACD,YAAY,EAAE,aAAa;aAC5B;YACD,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;gBAC9C,IAAI,EAAE,YAAY,CAAC,IAAa;gBAChC,IAAI,EAAE;oBACJ,QAAQ,EAAE,IAAI,CAAC,IAAI;oBACnB,MAAM,EAAE,IAAI,CAAC,EAAE;oBACf,aAAa,EAAE,CAAC;iBACjB;gBACD,YAAY,EAAE,OAAO,KAAK,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;aACrF,CAAC,CAAC;SACJ,CAAA;QAED,OAAO,CAAC,GAAG,mBAAmB,EAAE,GAAG,eAAe,CAAC,CAAA;IACrD,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC,CAAA;IAEvC,OAAO,aAAa,CAAA;AACtB,CAAC","sourcesContent":["import { useMemo } from 'react'\nimport { type ViewStyle } from 'react-native'\nimport { SectionTypes, type SectionListData, type ServiceTypeWithTeams } from '../types'\n\ninterface Props {\n data: ServiceTypeWithTeams[]\n firstRowStyle: ViewStyle\n lastRowStyle: ViewStyle\n}\n\nexport function useFlattenedArrayOfServiceTypesWithTeams({\n data,\n firstRowStyle,\n lastRowStyle,\n}: Props) {\n const flattenedData: SectionListData = useMemo(() => {\n const serviceTypeRows = data\n .filter(serviceType => serviceType.id > 0)\n .flatMap(serviceType => {\n const teamIdsForServiceType = serviceType.teams.map(team => team.id)\n\n return [\n {\n type: SectionTypes.header as const,\n data: {\n serviceTypeName: serviceType.name,\n serviceTypeId: serviceType.id,\n teamIdsForServiceType,\n },\n sectionStyle: firstRowStyle,\n },\n ...serviceType.teams.map((team, teamIdx) => ({\n type: SectionTypes.team as const,\n data: {\n teamName: team.name,\n teamId: team.id,\n serviceTypeId: serviceType.id,\n },\n sectionStyle: teamIdx === serviceType.teams.length - 1 ? lastRowStyle : undefined,\n })),\n ]\n })\n\n // Teams without a service type (id < 0) are merged under a single \"No service type\" section.\n // Service type ID 0 is a safe sentinel — real IDs are always positive.\n const serviceTypelessTeams = data\n .filter(serviceType => serviceType.id < 0)\n .flatMap(serviceType => serviceType.teams)\n\n if (serviceTypelessTeams.length === 0) return serviceTypeRows\n\n const serviceTypelessRows: SectionListData = [\n {\n type: SectionTypes.header as const,\n data: {\n serviceTypeName: null,\n serviceTypeId: 0,\n teamIdsForServiceType: serviceTypelessTeams.map(t => t.id),\n },\n sectionStyle: firstRowStyle,\n },\n ...serviceTypelessTeams.map((team, teamIdx) => ({\n type: SectionTypes.team as const,\n data: {\n teamName: team.name,\n teamId: team.id,\n serviceTypeId: 0,\n },\n sectionStyle: teamIdx === serviceTypelessTeams.length - 1 ? lastRowStyle : undefined,\n })),\n ]\n\n return [...serviceTypelessRows, ...serviceTypeRows]\n }, [data, firstRowStyle, lastRowStyle])\n\n return flattenedData\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { ServicesChatResource } from '../../../types';
1
+ import { ServicesChatResource, TeamResponseItem } from '../../../types';
2
2
  import { ServiceTypeWithTeams, TeamFilterTypes } from '../types';
3
3
  export declare function useServiceTypesWithTeams({ filterType, searchQuery, }?: {
4
4
  filterType?: TeamFilterTypes;
@@ -172,4 +172,5 @@ export declare function useServiceTypesWithTeams({ filterType, searchQuery, }?:
172
172
  meta?: Record<string, unknown> | undefined;
173
173
  serviceTypes: ServiceTypeWithTeams[];
174
174
  };
175
+ export declare function decorateTeamResponseItems(teamResponseItems: TeamResponseItem[], searchQuery?: string): ServiceTypeWithTeams[];
175
176
  //# sourceMappingURL=use_service_types_with_teams.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use_service_types_with_teams.d.ts","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,gBAAgB,CAAA;AACvE,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAEhE,wBAAgB,wBAAwB,CAAC,EACvC,UAAuC,EACvC,WAAW,GACZ,GAAE;IACD,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAA;CAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWL"}
1
+ {"version":3,"file":"use_service_types_with_teams.d.ts","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACvE,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAEhE,wBAAgB,wBAAwB,CAAC,EACvC,UAAuC,EACvC,WAAW,GACZ,GAAE;IACD,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAA;CAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWL;AAsCD,wBAAgB,yBAAyB,CACvC,iBAAiB,EAAE,gBAAgB,EAAE,EACrC,WAAW,CAAC,EAAE,MAAM,0BAyCrB"}
@@ -44,43 +44,40 @@ const useTeams = ({ filterType }) => {
44
44
  }, [data, filterType]);
45
45
  return { data: result || [], ...rest };
46
46
  };
47
- function decorateTeamResponseItems(teamResponseItems, searchQuery) {
48
- return teamResponseItems
49
- .filter(item => {
47
+ export function decorateTeamResponseItems(teamResponseItems, searchQuery) {
48
+ const filtered = teamResponseItems.filter(item => {
50
49
  if (!searchQuery)
51
50
  return true;
52
51
  const evalMatch = (str) => str.toLowerCase().includes(searchQuery.toLowerCase());
53
- const teamNameMatch = evalMatch(item.name);
54
- const serviceTypeNamesMatch = evalMatch(item.serviceTypeNames?.join(',') || '');
55
- return teamNameMatch || serviceTypeNamesMatch;
56
- })
57
- .map(({ value, serviceTypeNames, teamName }) => {
58
- return {
59
- service_types: value.serviceTypeIds.map((serviceTypeId, i) => ({
60
- id: serviceTypeId,
61
- name: serviceTypeNames[i],
62
- })),
63
- team: {
64
- id: value.teamId,
65
- name: teamName,
66
- },
67
- };
68
- })
52
+ return evalMatch(item.name) || evalMatch(item.serviceTypeNames?.join(',') || '');
53
+ });
54
+ const withServiceTypes = filtered.filter(item => item.value.serviceTypeIds.length > 0);
55
+ const withoutServiceTypes = filtered.filter(item => item.value.serviceTypeIds.length === 0);
56
+ // Negative team ID is used as a unique sentinel — real service type IDs are always positive.
57
+ const typelessEntries = withoutServiceTypes.map(({ value, teamName }) => ({
58
+ id: -value.teamId,
59
+ name: teamName,
60
+ teams: [{ id: value.teamId, name: teamName }],
61
+ }));
62
+ const typedEntries = withServiceTypes
63
+ .map(({ value, serviceTypeNames, teamName }) => ({
64
+ service_types: value.serviceTypeIds.map((serviceTypeId, i) => ({
65
+ id: serviceTypeId,
66
+ name: serviceTypeNames[i],
67
+ })),
68
+ team: { id: value.teamId, name: teamName },
69
+ }))
69
70
  .reduce((acc, { service_types, team }) => {
70
71
  service_types.forEach(serviceType => {
71
72
  let serviceTypeEntry = acc.find(entry => entry.id === serviceType.id);
72
73
  if (!serviceTypeEntry) {
73
- serviceTypeEntry = {
74
- id: serviceType.id,
75
- name: serviceType.name,
76
- teams: [],
77
- };
74
+ serviceTypeEntry = { id: serviceType.id, name: serviceType.name, teams: [] };
78
75
  acc.push(serviceTypeEntry);
79
76
  }
80
- const initialTeams = serviceTypeEntry.teams;
81
- serviceTypeEntry.teams = uniqBy([...initialTeams, team], 'id');
77
+ serviceTypeEntry.teams = uniqBy([...serviceTypeEntry.teams, team], 'id');
82
78
  });
83
79
  return acc;
84
80
  }, []);
81
+ return [...typelessEntries, ...typedEntries];
85
82
  }
86
83
  //# sourceMappingURL=use_service_types_with_teams.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use_service_types_with_teams.js","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAElD,OAAO,EAAwB,eAAe,EAAE,MAAM,UAAU,CAAA;AAEhE,MAAM,UAAU,wBAAwB,CAAC,EACvC,UAAU,GAAG,eAAe,CAAC,UAAU,EACvC,WAAW,MAIT,EAAE;IACJ,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC,CAAA;IAElD,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,EAAE;QACrC,OAAO,yBAAyB,CAAC,IAA0B,EAAE,WAAW,CAAC,CAAA;IAC3E,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAA;IAEvB,OAAO;QACL,YAAY,EAAE,iBAAiB;QAC/B,GAAG,IAAI;KACR,CAAA;AACH,CAAC;AAED,MAAM,QAAQ,GAAG,CAAC,EAAE,UAAU,EAAmC,EAAE,EAAE;IACnE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE;QAChC,QAAQ,UAAU,EAAE,CAAC;YACnB,KAAK,eAAe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QACF,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,CAAC,CAAA;AACV,CAAC","sourcesContent":["import { uniqBy } from 'lodash'\nimport { useMemo } from 'react'\nimport { useApiGet } from '../../../hooks/use_api'\nimport { ServicesChatResource, TeamResponseItem } from '../../../types'\nimport { ServiceTypeWithTeams, TeamFilterTypes } from '../types'\n\nexport function useServiceTypesWithTeams({\n filterType = TeamFilterTypes.TeamsIlead,\n searchQuery,\n}: {\n filterType?: TeamFilterTypes\n searchQuery?: string\n} = {}) {\n const { data, ...rest } = useTeams({ filterType })\n\n const decoratedResponse = useMemo(() => {\n return decorateTeamResponseItems(data as TeamResponseItem[], searchQuery)\n }, [data, searchQuery])\n\n return {\n serviceTypes: decoratedResponse,\n ...rest,\n }\n}\n\nconst useTeams = ({ filterType }: { filterType: TeamFilterTypes }) => {\n const requestField = useMemo(() => {\n switch (filterType) {\n case TeamFilterTypes.All:\n return 'teams'\n case TeamFilterTypes.MyTeams:\n return 'my_teams'\n default:\n return 'teams_i_lead'\n }\n }, [filterType])\n\n const { data, ...rest } = useApiGet<ServicesChatResource>({\n url: '/chat',\n data: {\n fields: {\n Chat: [requestField],\n },\n },\n app: 'services',\n })\n\n const result: TeamResponseItem[] = useMemo(() => {\n switch (filterType) {\n case TeamFilterTypes.All:\n return data?.teams || []\n case TeamFilterTypes.MyTeams:\n return data?.myTeams || []\n default:\n return data?.teamsILead || []\n }\n }, [data, filterType])\n\n return { data: result || [], ...rest }\n}\n\nfunction decorateTeamResponseItems(teamResponseItems: TeamResponseItem[], searchQuery?: string) {\n return teamResponseItems\n .filter(item => {\n if (!searchQuery) return true\n\n const evalMatch = (str: string) => str.toLowerCase().includes(searchQuery.toLowerCase())\n const teamNameMatch = evalMatch(item.name)\n const serviceTypeNamesMatch = evalMatch(item.serviceTypeNames?.join(',') || '')\n\n return teamNameMatch || serviceTypeNamesMatch\n })\n .map(({ value, serviceTypeNames, teamName }) => {\n return {\n service_types: value.serviceTypeIds.map((serviceTypeId, i) => ({\n id: serviceTypeId,\n name: serviceTypeNames[i],\n })),\n team: {\n id: value.teamId,\n name: teamName,\n },\n }\n })\n .reduce((acc: ServiceTypeWithTeams[], { service_types, team }) => {\n service_types.forEach(serviceType => {\n let serviceTypeEntry = acc.find(entry => entry.id === serviceType.id)\n\n if (!serviceTypeEntry) {\n serviceTypeEntry = {\n id: serviceType.id,\n name: serviceType.name,\n teams: [],\n }\n acc.push(serviceTypeEntry)\n }\n\n const initialTeams = serviceTypeEntry.teams\n serviceTypeEntry.teams = uniqBy([...initialTeams, team], 'id')\n })\n return acc\n }, [])\n}\n"]}
1
+ {"version":3,"file":"use_service_types_with_teams.js","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAElD,OAAO,EAAwB,eAAe,EAAE,MAAM,UAAU,CAAA;AAEhE,MAAM,UAAU,wBAAwB,CAAC,EACvC,UAAU,GAAG,eAAe,CAAC,UAAU,EACvC,WAAW,MAIT,EAAE;IACJ,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC,CAAA;IAElD,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,EAAE;QACrC,OAAO,yBAAyB,CAAC,IAA0B,EAAE,WAAW,CAAC,CAAA;IAC3E,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAA;IAEvB,OAAO;QACL,YAAY,EAAE,iBAAiB;QAC/B,GAAG,IAAI;KACR,CAAA;AACH,CAAC;AAED,MAAM,QAAQ,GAAG,CAAC,EAAE,UAAU,EAAmC,EAAE,EAAE;IACnE,MAAM,YAAY,GAAG,OAAO,CAAC,G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aAAa,EAAE,IAAI,EAAE,EAAE,EAAE;QAC/D,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;YAClC,IAAI,gBAAgB,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,WAAW,CAAC,EAAE,CAAC,CAAA;YACrE,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACtB,gBAAgB,GAAG,EAAE,EAAE,EAAE,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;gBAC5E,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;YAC5B,CAAC;YACD,gBAAgB,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,GAAG,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;QAC1E,CAAC,CAAC,CAAA;QACF,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,CAAC,CAAA;IAER,OAAO,CAAC,GAAG,eAAe,EAAE,GAAG,YAAY,CAAC,CAAA;AAC9C,CAAC","sourcesContent":["import { uniqBy } from 'lodash'\nimport { useMemo } from 'react'\nimport { useApiGet } from '../../../hooks/use_api'\nimport { ServicesChatResource, TeamResponseItem } from '../../../types'\nimport { ServiceTypeWithTeams, TeamFilterTypes } from '../types'\n\nexport function useServiceTypesWithTeams({\n filterType = TeamFilterTypes.TeamsIlead,\n searchQuery,\n}: {\n filterType?: TeamFilterTypes\n searchQuery?: string\n} = {}) {\n const { data, ...rest } = useTeams({ filterType })\n\n const decoratedResponse = useMemo(() => {\n return decorateTeamResponseItems(data as TeamResponseItem[], searchQuery)\n }, [data, searchQuery])\n\n return {\n serviceTypes: decoratedResponse,\n ...rest,\n }\n}\n\nconst useTeams = ({ filterType }: { filterType: TeamFilterTypes }) => {\n const requestField = useMemo(() => {\n switch (filterType) {\n case TeamFilterTypes.All:\n return 'teams'\n case TeamFilterTypes.MyTeams:\n return 'my_teams'\n default:\n return 'teams_i_lead'\n }\n }, [filterType])\n\n const { data, ...rest } = useApiGet<ServicesChatResource>({\n url: '/chat',\n data: {\n fields: {\n Chat: [requestField],\n },\n },\n app: 'services',\n })\n\n const result: TeamResponseItem[] = useMemo(() => {\n switch (filterType) {\n case TeamFilterTypes.All:\n return data?.teams || []\n case TeamFilterTypes.MyTeams:\n return data?.myTeams || []\n default:\n return data?.teamsILead || []\n }\n }, [data, filterType])\n\n return { data: result || [], ...rest }\n}\n\nexport function decorateTeamResponseItems(\n teamResponseItems: TeamResponseItem[],\n searchQuery?: string\n) {\n const filtered = teamResponseItems.filter(item => {\n if (!searchQuery) return true\n const evalMatch = (str: string) => str.toLowerCase().includes(searchQuery.toLowerCase())\n return evalMatch(item.name) || evalMatch(item.serviceTypeNames?.join(',') || '')\n })\n\n const withServiceTypes = filtered.filter(item => item.value.serviceTypeIds.length > 0)\n const withoutServiceTypes = filtered.filter(item => item.value.serviceTypeIds.length === 0)\n\n // Negative team ID is used as a unique sentinel — real service type IDs are always positive.\n const typelessEntries: ServiceTypeWithTeams[] = withoutServiceTypes.map(\n ({ value, teamName }) => ({\n id: -value.teamId,\n name: teamName,\n teams: [{ id: value.teamId, name: teamName }],\n })\n )\n\n const typedEntries = withServiceTypes\n .map(({ value, serviceTypeNames, teamName }) => ({\n service_types: value.serviceTypeIds.map((serviceTypeId, i) => ({\n id: serviceTypeId,\n name: serviceTypeNames[i],\n })),\n team: { id: value.teamId, name: teamName },\n }))\n .reduce((acc: ServiceTypeWithTeams[], { service_types, team }) => {\n service_types.forEach(serviceType => {\n let serviceTypeEntry = acc.find(entry => entry.id === serviceType.id)\n if (!serviceTypeEntry) {\n serviceTypeEntry = { id: serviceType.id, name: serviceType.name, teams: [] }\n acc.push(serviceTypeEntry)\n }\n serviceTypeEntry.teams = uniqBy([...serviceTypeEntry.teams, team], 'id')\n })\n return acc\n }, [])\n\n return [...typelessEntries, ...typedEntries]\n}\n"]}
@@ -14,7 +14,7 @@ export declare enum SectionTypes {
14
14
  team = 1
15
15
  }
16
16
  export interface ServiceTypeProps {
17
- serviceTypeName: string;
17
+ serviceTypeName: string | null;
18
18
  serviceTypeId: number;
19
19
  teamIdsForServiceType: number[];
20
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/screens/conversation_filter_recipients/types.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAExD,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE;QACL,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,MAAM,CAAA;KACb,EAAE,CAAA;CACJ;AAED,oBAAY,YAAY;IACtB,MAAM,IAAA;IACN,IAAI,IAAA;CACL;AAED,MAAM,WAAW,gBAAgB;IAC/B,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,qBAAqB,EAAE,MAAM,EAAE,CAAA;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,MAAM,eAAe,GAAG,KAAK,CACjC,QAAQ,CAAC,gBAAgB,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,IAAI,CAAC,CACzF,CAAA;AAED,UAAU,QAAQ,CAAC,CAAC,EAAE,KAAK,SAAS,YAAY;IAC9C,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,EAAE,CAAC,CAAA;IACP,YAAY,CAAC,EAAE,SAAS,CAAA;CACzB;AAED,oBAAY,eAAe;IACzB,GAAG,cAAc;IACjB,OAAO,aAAa;IACpB,UAAU,iBAAiB;CAC5B;AAED,MAAM,MAAM,kCAAkC,GAAG;IAC/C,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,gBAAgB,CAAC,EAAE,eAAe,CAAA;IAClC,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,uCAAuC,GACjD,iBAAiB,CAAC,kCAAkC,CAAC,CAAA;AAEvD,MAAM,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,KAAK,IAAI,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/screens/conversation_filter_recipients/types.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAExD,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE;QACL,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,MAAM,CAAA;KACb,EAAE,CAAA;CACJ;AAED,oBAAY,YAAY;IACtB,MAAM,IAAA;IACN,IAAI,IAAA;CACL;AAED,MAAM,WAAW,gBAAgB;IAC/B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,aAAa,EAAE,MAAM,CAAA;IACrB,qBAAqB,EAAE,MAAM,EAAE,CAAA;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,MAAM,eAAe,GAAG,KAAK,CACjC,QAAQ,CAAC,gBAAgB,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,IAAI,CAAC,CACzF,CAAA;AAED,UAAU,QAAQ,CAAC,CAAC,EAAE,KAAK,SAAS,YAAY;IAC9C,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,EAAE,CAAC,CAAA;IACP,YAAY,CAAC,EAAE,SAAS,CAAA;CACzB;AAED,oBAAY,eAAe;IACzB,GAAG,cAAc;IACjB,OAAO,aAAa;IACpB,UAAU,iBAAiB;CAC5B;AAED,MAAM,MAAM,kCAAkC,GAAG;IAC/C,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,gBAAgB,CAAC,EAAE,eAAe,CAAA;IAClC,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,uCAAuC,GACjD,iBAAiB,CAAC,kCAAkC,CAAC,CAAA;AAEvD,MAAM,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,KAAK,IAAI,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/screens/conversation_filter_recipients/types.tsx"],"names":[],"mappings":"AAaA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,mDAAM,CAAA;IACN,+CAAI,CAAA;AACN,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAwBD,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,uCAAoB,CAAA;IACpB,8CAA2B,CAAA;AAC7B,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B","sourcesContent":["import { StaticScreenProps } from '@react-navigation/native'\nimport { type ViewStyle } from 'react-native'\nimport { AppName } from '../../types/resources/app_name'\n\nexport interface ServiceTypeWithTeams {\n id: number\n name: string\n teams: {\n id: number\n name: string\n }[]\n}\n\nexport enum SectionTypes {\n header,\n team,\n}\n\nexport interface ServiceTypeProps {\n serviceTypeName: string\n serviceTypeId: number\n teamIdsForServiceType: number[]\n}\n\nexport interface TeamProps {\n teamName: string\n teamId: number\n serviceTypeId: number\n}\n\nexport type SectionListData = Array<\n DataItem<ServiceTypeProps, SectionTypes.header> | DataItem<TeamProps, SectionTypes.team>\n>\n\ninterface DataItem<T, TName extends SectionTypes> {\n type: TName\n data: T\n sectionStyle?: ViewStyle\n}\n\nexport enum TeamFilterTypes {\n All = 'All teams',\n MyTeams = 'My teams',\n TeamsIlead = 'Teams I lead',\n}\n\nexport type ConversationFilterRecipientsParams = {\n source_app_name?: AppName\n team_ids?: number[]\n team_filter_type?: TeamFilterTypes\n search_query?: string\n}\n\nexport type ConversationFilterRecipientsScreenProps =\n StaticScreenProps<ConversationFilterRecipientsParams>\n\nexport type SetTeamFilters = ({ team_ids }: { team_ids: number[] }) => void\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/screens/conversation_filter_recipients/types.tsx"],"names":[],"mappings":"AAaA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,mDAAM,CAAA;IACN,+CAAI,CAAA;AACN,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAwBD,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,uCAAoB,CAAA;IACpB,8CAA2B,CAAA;AAC7B,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B","sourcesContent":["import { StaticScreenProps } from '@react-navigation/native'\nimport { type ViewStyle } from 'react-native'\nimport { AppName } from '../../types/resources/app_name'\n\nexport interface ServiceTypeWithTeams {\n id: number\n name: string\n teams: {\n id: number\n name: string\n }[]\n}\n\nexport enum SectionTypes {\n header,\n team,\n}\n\nexport interface ServiceTypeProps {\n serviceTypeName: string | null\n serviceTypeId: number\n teamIdsForServiceType: number[]\n}\n\nexport interface TeamProps {\n teamName: string\n teamId: number\n serviceTypeId: number\n}\n\nexport type SectionListData = Array<\n DataItem<ServiceTypeProps, SectionTypes.header> | DataItem<TeamProps, SectionTypes.team>\n>\n\ninterface DataItem<T, TName extends SectionTypes> {\n type: TName\n data: T\n sectionStyle?: ViewStyle\n}\n\nexport enum TeamFilterTypes {\n All = 'All teams',\n MyTeams = 'My teams',\n TeamsIlead = 'Teams I lead',\n}\n\nexport type ConversationFilterRecipientsParams = {\n source_app_name?: AppName\n team_ids?: number[]\n team_filter_type?: TeamFilterTypes\n search_query?: string\n}\n\nexport type ConversationFilterRecipientsScreenProps =\n StaticScreenProps<ConversationFilterRecipientsParams>\n\nexport type SetTeamFilters = ({ team_ids }: { team_ids: number[] }) => void\n"]}
@@ -9,7 +9,6 @@ export type ConversationRouteProps = {
9
9
  chat_group_graph_id?: string;
10
10
  clear_input?: boolean;
11
11
  editing_message_id?: number | null;
12
- message_id?: string;
13
12
  title?: string;
14
13
  subtitle?: string;
15
14
  badge?: ConversationBadgeResource;
@@ -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;AACjC,OAAO,KAA4D,MAAM,OAAO,CAAA;AA2ChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAA;AAiBjF,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,CAAA;IAC5B,WAAW,CAAC,EAAE,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G,IAAI,CAAA;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,yBAAyB,CAAA;IACjC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,sBAAsB,CAAC,CAAA;AAE/E,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,EAAE,uBAAuB,qBAkBpE;AA2ND,UAAU,4BAA6B,SAAQ,gBAAgB;IAC7D,eAAe,EAAE,MAAM,CAAA;IACvB,KAAK,CAAC,EAAE,yBAAyB,CAAA;IACjC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,eAAO,MAAM,uBAAuB,GAAI,8DAOrC,4BAA4B,sBAoC9B,CAAA"}
@@ -1,9 +1,8 @@
1
1
  import { date as formatDate } from '@planningcenter/datetime-fmt';
2
2
  import { HeaderTitle, PlatformPressable } from '@react-navigation/elements';
3
3
  import { CommonActions, useNavigation, useTheme as useNavigationTheme, useRoute, } from '@react-navigation/native';
4
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
- import { ActivityIndicator, FlatList, Platform, StyleSheet, View } from 'react-native';
6
- import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
4
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
5
+ import { FlatList, Platform, StyleSheet, View } from 'react-native';
7
6
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
8
7
  import { Badge, Icon, Text } from '../components';
9
8
  import { EmptyConversationBlankState } from '../components/conversation/empty_conversation_blank_state';
@@ -14,130 +13,73 @@ import { ConversationDisabledBanner, LeaderMessagesDisabledBanner, MemberMessage
14
13
  import { ReplyShadowMessage } from '../components/conversation/reply_shadow_message';
15
14
  import { SystemMessage } from '../components/conversation/system_message';
16
15
  import { TypingIndicator } from '../components/conversation/typing_indicator';
17
- import { UnreadDivider } from '../components/conversation/unread_divider';
18
16
  import { KeyboardView } from '../components/display/keyboard_view';
19
17
  import BlankState from '../components/primitive/blank_state_primitive';
20
- import { ConversationContextProvider, useConversationContext, } from '../contexts/conversation_context';
18
+ import { ConversationContextProvider } from '../contexts/conversation_context';
21
19
  import { useTheme } from '../hooks';
22
20
  import { useConversation } from '../hooks/use_conversation';
23
21
  import { useConversationJoltEvents } from '../hooks/use_conversation_jolt_events';
24
22
  import { useConversationMessages } from '../hooks/use_conversation_messages';
25
23
  import { useConversationMessagesJoltEvents } from '../hooks/use_conversation_messages_jolt_events';
26
- import { availableFeatures, useFeatures } from '../hooks/use_features';
27
- import { useFlatListViewability } from '../hooks/use_flat_list_viewability';
28
- import { useJumpToBottomAction } from '../hooks/use_jump_to_bottom_action';
29
- import { useJumpToUnreadAnchor } from '../hooks/use_jump_to_unread_anchor';
30
- import { useJumpToUnreadGates } from '../hooks/use_jump_to_unread_gates';
31
24
  import { useMarkLatestMessageRead } from '../hooks/use_mark_latest_message_read';
32
25
  import { analyticsEvents, normalizeAnalyticsMetadata, usePublishProductAnalyticsEvent, } from '../hooks/use_product_analytics';
33
- import { useScrollTracking } from '../hooks/use_scroll_tracking';
34
- import { useTrackHighestSeenMessage } from '../hooks/use_track_highest_seen_message';
35
26
  import { getRelativeDateStatus } from '../utils/date';
36
- import { groupMessages, UNREAD_DIVIDER_KEY, } from '../utils/group_messages';
37
- import { detectDividerExitTowardNewer, reportViewableMessages, } from '../utils/message_viewability';
27
+ import { groupMessages } from '../utils/group_messages';
38
28
  import { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../utils/styles';
39
29
  import { isSystemMessage } from '../utils/system_messages';
40
- const extractItemKey = (item) => String(item.id);
41
- const maintainVisibleContentPosition = { minIndexForVisible: 0 };
42
30
  export function ConversationScreen({ route }) {
43
- const { conversation_id, message_id, reply_root_id } = route.params;
31
+ const { conversation_id, reply_root_id } = route.params;
44
32
  const { data: conversation } = useConversation({ conversation_id });
45
- const { featureEnabled } = useFeatures();
46
33
  usePublishProductAnalyticsEvent(analyticsEvents.conversation_show_opened, {
47
34
  reply_root_id,
48
35
  ...normalizeAnalyticsMetadata(conversation),
49
36
  });
50
- const lastReadMessageSortKey = conversation.conversationMembership?.lastReadMessageSortKey ?? null;
51
- const jumpToUnreadAnchor = featureEnabled(availableFeatures.jump_to_unread) && !reply_root_id
52
- ? lastReadMessageSortKey
53
- : null;
54
- const initialMessageId = message_id ?? jumpToUnreadAnchor;
55
- const initialMessageIdIsAnchor = !!initialMessageId && !message_id;
56
- return (<ConversationContextProvider conversationId={conversation_id} currentPageReplyRootId={reply_root_id ?? null} initialMessageId={initialMessageId} initialMessageIdIsAnchor={initialMessageIdIsAnchor}>
37
+ return (<ConversationContextProvider conversationId={conversation_id} currentPageReplyRootId={reply_root_id ?? null}>
57
38
  <ConversationScreenContent route={route}/>
58
39
  </ConversationContextProvider>);
59
40
  }
60
41
  function ConversationScreenContent({ route }) {
61
42
  const styles = useStyles();
62
43
  const navigation = useNavigation();
63
- const { conversation_id: conversationId, editing_message_id: editingMessageId, reply_root_id: replyRootId, reply_root_author_name: replyRootAuthorName, } = route.params;
44
+ const { conversation_id, editing_message_id, reply_root_id, reply_root_author_name } = route.params;
64
45
  const { data: conversation } = useConversation(route.params);
65
- const { messages, fetchOlderMessages, fetchNewerMessages, hasMoreNewerMessages, isFetchingNewerMessages, cancelFetchNewerMessages, } = useConversationMessages({ conversation_id: conversationId, reply_root_id: replyRootId });
66
- const { jumpToUnreadActive } = useJumpToUnreadGates();
67
- const { initialMessageId } = useConversationContext();
68
- useConversationJoltEvents({ conversationId });
69
- useConversationMessagesJoltEvents({ conversationId });
46
+ const { messages, fetchNextPage } = useConversationMessages({
47
+ conversation_id,
48
+ reply_root_id,
49
+ });
50
+ useConversationJoltEvents({ conversationId: conversation_id });
51
+ useConversationMessagesJoltEvents({ conversationId: conversation_id });
70
52
  useEnsureConversationsRouteExists();
71
53
  useMarkLatestMessageRead({ conversation, messages });
72
- const { onMessageSeen } = useTrackHighestSeenMessage();
73
- const items = useMemo(() => groupMessages({
54
+ const messagesWithSeparators = groupMessages({
74
55
  ms: messages,
75
- inReplyScreen: !!replyRootId,
76
- jumpToUnreadActive,
77
- initialMessageId,
78
- }), [messages, replyRootId, jumpToUnreadActive, initialMessageId]);
79
- const noMessages = items.length === 0;
56
+ inReplyScreen: !!reply_root_id,
57
+ });
58
+ const noMessages = messagesWithSeparators.length === 0;
80
59
  const { repliesDisabled, memberAbility, badges, title } = conversation;
81
60
  const canReply = memberAbility?.canReply;
82
61
  const showLeaderDisabledReplyBanner = canReply && repliesDisabled;
83
62
  const canDeleteNonAuthoredMessages = memberAbility?.canDeleteNonAuthoredMessages ?? false;
84
- const currentlyEditingMessage = messages.find(m => String(m.id) === String(editingMessageId));
85
- const replyRootAuthorFirstName = replyRootAuthorName?.split(' ')[0];
63
+ const currentlyEditingMessage = messages.find(m => String(m.id) === String(editing_message_id));
64
+ const replyRootAuthorFirstName = reply_root_author_name?.split(' ')[0];
86
65
  const replyHeaderTitle = replyRootAuthorFirstName
87
66
  ? `Reply to ${replyRootAuthorFirstName}`
88
67
  : 'Reply';
89
68
  // Prefer the membership for optimistic updates.
90
69
  const muted = conversation.conversationMembership?.muted ?? conversation.muted;
91
70
  const listRef = useRef(null);
92
- const [dividerScrolledPast, setDividerScrolledPast] = useState(false);
93
- const observers = useMemo(() => [
94
- reportViewableMessages(onMessageSeen),
95
- detectDividerExitTowardNewer({
96
- dividerKey: UNREAD_DIVIDER_KEY,
97
- initialMessageId,
98
- onExited: () => setDividerScrolledPast(true),
99
- }),
100
- ], [onMessageSeen, initialMessageId]);
101
- const { viewabilityConfigCallbackPairs, onScrollBeginDrag: viewabilityOnScrollBeginDrag } = useFlatListViewability({ observers });
102
- const { onContentSizeChange, onScrollToIndexFailed, onScrollBeginDrag: anchorOnScrollBeginDrag, } = useJumpToUnreadAnchor({ listRef, items });
103
- const onScrollBeginDrag = useCallback(() => {
104
- viewabilityOnScrollBeginDrag();
105
- anchorOnScrollBeginDrag();
106
- }, [viewabilityOnScrollBeginDrag, anchorOnScrollBeginDrag]);
107
- const { onScroll, showJumpToBottomButton } = useScrollTracking({
108
- hasMoreNewerMessages,
109
- isFetchingNewerMessages,
110
- fetchNewerMessages,
111
- cancelFetchNewerMessages,
112
- });
113
- const { handleJumpToBottom, isJumpingToBottom } = useJumpToBottomAction({ listRef });
114
- const listHeader = useMemo(() => (<View>
115
- {isFetchingNewerMessages && (<Animated.View entering={FadeIn.duration(750)} exiting={FadeOut.duration(750)} style={styles.loadingFooter} accessibilityRole="progressbar" accessibilityLabel="Loading more messages">
116
- <ActivityIndicator />
117
- </Animated.View>)}
118
- <View style={styles.listHeader}/>
119
- </View>), [isFetchingNewerMessages, styles.loadingFooter, styles.listHeader]);
120
- const renderItem = useCallback(({ item }) => {
121
- if (item.type === 'DateSeparator')
122
- return <InlineDateSeparator {...item}/>;
123
- if (item.type === 'UnreadDivider')
124
- return <UnreadDivider scrolledPast={dividerScrolledPast}/>;
125
- if (item.type === 'ReplyShadowMessage') {
126
- return (<ReplyShadowMessage {...item} conversation_id={conversationId} inReplyScreen={!!replyRootId}/>);
127
- }
128
- if (isSystemMessage(item)) {
129
- return <SystemMessage message={item} conversationId={conversationId}/>;
130
- }
131
- return (<Message {...item} canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages} conversation_id={conversationId} latestReadMessageSortKey={conversation?.latestReadMessageSortKey} inReplyScreen={!!replyRootId}/>);
132
- }, [
133
- dividerScrolledPast,
134
- conversationId,
135
- replyRootId,
136
- canDeleteNonAuthoredMessages,
137
- conversation?.latestReadMessageSortKey,
138
- ]);
71
+ const [showJumpToBottomButton, setShowJumpToBottomButton] = useState(false);
72
+ const trackScroll = (event) => {
73
+ const offsetY = event.nativeEvent.contentOffset.y;
74
+ setShowJumpToBottomButton(offsetY > 200);
75
+ };
76
+ const handleReturnToBottom = useCallback(() => {
77
+ listRef.current?.scrollToOffset({
78
+ offset: 0,
79
+ });
80
+ }, []);
139
81
  useEffect(() => {
140
- if (replyRootId) {
82
+ if (reply_root_id) {
141
83
  navigation.setParams({
142
84
  title: replyHeaderTitle,
143
85
  });
@@ -150,7 +92,7 @@ function ConversationScreenContent({ route }) {
150
92
  muted,
151
93
  });
152
94
  }
153
- }, [navigation, title, badges, conversation?.deleted, replyRootId, replyHeaderTitle, muted]);
95
+ }, [navigation, title, badges, conversation?.deleted, reply_root_id, replyHeaderTitle, muted]);
154
96
  if (!conversation || conversation.deleted) {
155
97
  return (<View style={styles.container}>
156
98
  <BlankState.Root>
@@ -164,11 +106,22 @@ function ConversationScreenContent({ route }) {
164
106
  }
165
107
  return (<View style={styles.container}>
166
108
  <KeyboardView>
167
- {noMessages ? (<EmptyConversationBlankState />) : (<FlatList inverted ref={listRef} contentContainerStyle={styles.listContainer} maintainVisibleContentPosition={maintainVisibleContentPosition} data={items} keyExtractor={extractItemKey} onScroll={onScroll} onScrollBeginDrag={onScrollBeginDrag} scrollEventThrottle={64} viewabilityConfigCallbackPairs={viewabilityConfigCallbackPairs} onContentSizeChange={onContentSizeChange} onScrollToIndexFailed={onScrollToIndexFailed} renderItem={renderItem} onEndReached={() => fetchOlderMessages()} ListHeaderComponent={listHeader}/>)}
168
- <JumpToBottomButton onPress={handleJumpToBottom} visible={showJumpToBottomButton} loading={isJumpingToBottom}/>
109
+ {noMessages ? (<EmptyConversationBlankState />) : (<FlatList inverted ref={listRef} contentContainerStyle={styles.listContainer} data={messagesWithSeparators} keyExtractor={item => item.id} onScroll={trackScroll} scrollEventThrottle={10} renderItem={({ item }) => {
110
+ if (item.type === 'DateSeparator') {
111
+ return <InlineDateSeparator {...item}/>;
112
+ }
113
+ if (item.type === 'ReplyShadowMessage') {
114
+ return (<ReplyShadowMessage {...item} conversation_id={conversation_id} inReplyScreen={!!reply_root_id}/>);
115
+ }
116
+ if (isSystemMessage(item)) {
117
+ return <SystemMessage message={item} conversationId={conversation_id}/>;
118
+ }
119
+ return (<Message {...item} canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages} conversation_id={conversation_id} latestReadMessageSortKey={conversation?.latestReadMessageSortKey} inReplyScreen={!!reply_root_id}/>);
120
+ }} onEndReached={() => fetchNextPage()} ListHeaderComponent={<View style={styles.listHeader}/>}/>)}
121
+ <JumpToBottomButton onPress={handleReturnToBottom} visible={showJumpToBottomButton}/>
169
122
  {!noMessages && <TypingIndicator />}
170
123
  {showLeaderDisabledReplyBanner && <LeaderMessagesDisabledBanner />}
171
- <ConversationBottomBar conversation={conversation} canReply={canReply} replyRootAuthorFirstName={replyRootAuthorFirstName} replyRootId={replyRootId} currentlyEditingMessage={currentlyEditingMessage}/>
124
+ <ConversationBottomBar conversation={conversation} canReply={canReply} replyRootAuthorFirstName={replyRootAuthorFirstName} replyRootId={reply_root_id} currentlyEditingMessage={currentlyEditingMessage}/>
172
125
  </KeyboardView>
173
126
  </View>);
174
127
  }
@@ -282,10 +235,6 @@ const useStyles = () => {
282
235
  // Just whitespace to provide space where the typing indicator can be
283
236
  height: 16,
284
237
  },
285
- loadingFooter: {
286
- paddingVertical: 12,
287
- alignItems: 'center',
288
- },
289
238
  });
290
239
  };
291
240
  /**