@planningcenter/chat-react-native 4.7.1-rc.0 → 4.8.0-qa-staging.1

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 (321) hide show
  1. package/build/components/conversations/app_update_banner.d.ts +2 -0
  2. package/build/components/conversations/app_update_banner.d.ts.map +1 -0
  3. package/build/components/conversations/app_update_banner.js +52 -0
  4. package/build/components/conversations/app_update_banner.js.map +1 -0
  5. package/build/components/conversations/conversation_actions.d.ts.map +1 -1
  6. package/build/components/conversations/conversation_actions.js +333 -193
  7. package/build/components/conversations/conversation_actions.js.map +1 -1
  8. package/build/components/conversations/conversation_preview.d.ts.map +1 -1
  9. package/build/components/conversations/conversation_preview.js +106 -91
  10. package/build/components/conversations/conversation_preview.js.map +1 -1
  11. package/build/components/conversations/conversations.d.ts.map +1 -1
  12. package/build/components/conversations/conversations.js +63 -56
  13. package/build/components/conversations/conversations.js.map +1 -1
  14. package/build/components/conversations/conversations_blank_state.d.ts +2 -1
  15. package/build/components/conversations/conversations_blank_state.d.ts.map +1 -1
  16. package/build/components/conversations/conversations_blank_state.js +71 -39
  17. package/build/components/conversations/conversations_blank_state.js.map +1 -1
  18. package/build/components/conversations/hidden_indicator.d.ts +4 -0
  19. package/build/components/conversations/hidden_indicator.d.ts.map +1 -0
  20. package/build/components/conversations/hidden_indicator.js +52 -0
  21. package/build/components/conversations/hidden_indicator.js.map +1 -0
  22. package/build/components/conversations/hidden_results_footer.d.ts +2 -0
  23. package/build/components/conversations/hidden_results_footer.d.ts.map +1 -0
  24. package/build/components/conversations/hidden_results_footer.js +34 -0
  25. package/build/components/conversations/hidden_results_footer.js.map +1 -0
  26. package/build/components/display/toast.d.ts +3 -0
  27. package/build/components/display/toast.d.ts.map +1 -0
  28. package/build/components/display/toast.js +224 -0
  29. package/build/components/display/toast.js.map +1 -0
  30. package/build/components/group_conversation_list.d.ts.map +1 -1
  31. package/build/components/group_conversation_list.js +1 -0
  32. package/build/components/group_conversation_list.js.map +1 -1
  33. package/build/components/primitive/banner_primitive.js +7 -3
  34. package/build/components/primitive/banner_primitive.js.map +1 -1
  35. package/build/contexts/api_provider.d.ts.map +1 -1
  36. package/build/contexts/api_provider.js +2 -0
  37. package/build/contexts/api_provider.js.map +1 -1
  38. package/build/contexts/chat_context.d.ts +0 -2
  39. package/build/contexts/chat_context.d.ts.map +1 -1
  40. package/build/contexts/chat_context.js +16 -93
  41. package/build/contexts/chat_context.js.map +1 -1
  42. package/build/contexts/conversations_context.d.ts +3 -1
  43. package/build/contexts/conversations_context.d.ts.map +1 -1
  44. package/build/contexts/conversations_context.js +39 -31
  45. package/build/contexts/conversations_context.js.map +1 -1
  46. package/build/contexts/session_context.d.ts.map +1 -1
  47. package/build/contexts/session_context.js +3 -0
  48. package/build/contexts/session_context.js.map +1 -1
  49. package/build/hooks/groups/use_group_chat_conversation_payload.d.ts +11 -1
  50. package/build/hooks/groups/use_group_chat_conversation_payload.d.ts.map +1 -1
  51. package/build/hooks/groups/use_group_chat_conversation_payload.js +92 -47
  52. package/build/hooks/groups/use_group_chat_conversation_payload.js.map +1 -1
  53. package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +33 -25
  54. package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -1
  55. package/build/hooks/groups/use_group_members_for_new_conversation.js +125 -110
  56. package/build/hooks/groups/use_group_members_for_new_conversation.js.map +1 -1
  57. package/build/hooks/groups/use_groups_conversation_create.d.ts.map +1 -1
  58. package/build/hooks/groups/use_groups_conversation_create.js +39 -31
  59. package/build/hooks/groups/use_groups_conversation_create.js.map +1 -1
  60. package/build/hooks/groups/use_groups_proxy.d.ts +2 -0
  61. package/build/hooks/groups/use_groups_proxy.d.ts.map +1 -0
  62. package/build/hooks/groups/use_groups_proxy.js +18 -0
  63. package/build/hooks/groups/use_groups_proxy.js.map +1 -0
  64. package/build/hooks/use_api.d.ts +6 -0
  65. package/build/hooks/use_api.d.ts.map +1 -1
  66. package/build/hooks/use_api.js +8 -5
  67. package/build/hooks/use_api.js.map +1 -1
  68. package/build/hooks/use_clear_conversation_filters.d.ts.map +1 -1
  69. package/build/hooks/use_clear_conversation_filters.js +1 -0
  70. package/build/hooks/use_clear_conversation_filters.js.map +1 -1
  71. package/build/hooks/use_conversation.d.ts.map +1 -1
  72. package/build/hooks/use_conversation.js +1 -1
  73. package/build/hooks/use_conversation.js.map +1 -1
  74. package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -1
  75. package/build/hooks/use_conversation_jolt_events.js +3 -2
  76. package/build/hooks/use_conversation_jolt_events.js.map +1 -1
  77. package/build/hooks/use_conversations_actions.d.ts +9 -9
  78. package/build/hooks/use_conversations_actions.d.ts.map +1 -1
  79. package/build/hooks/use_conversations_actions.js +12 -7
  80. package/build/hooks/use_conversations_actions.js.map +1 -1
  81. package/build/hooks/use_conversations_cache.d.ts +1 -3
  82. package/build/hooks/use_conversations_cache.d.ts.map +1 -1
  83. package/build/hooks/use_conversations_cache.js +79 -124
  84. package/build/hooks/use_conversations_cache.js.map +1 -1
  85. package/build/hooks/use_conversations_jolt_events.d.ts.map +1 -1
  86. package/build/hooks/use_conversations_jolt_events.js +47 -20
  87. package/build/hooks/use_conversations_jolt_events.js.map +1 -1
  88. package/build/hooks/use_features.d.ts +2 -0
  89. package/build/hooks/use_features.d.ts.map +1 -1
  90. package/build/hooks/use_features.js +3 -1
  91. package/build/hooks/use_features.js.map +1 -1
  92. package/build/hooks/use_groups.d.ts +6 -0
  93. package/build/hooks/use_groups.d.ts.map +1 -1
  94. package/build/hooks/use_groups_groups.d.ts +6 -0
  95. package/build/hooks/use_groups_groups.d.ts.map +1 -1
  96. package/build/hooks/use_groups_groups.js +25 -9
  97. package/build/hooks/use_groups_groups.js.map +1 -1
  98. package/build/hooks/use_hidden_conversations_count.d.ts +2 -0
  99. package/build/hooks/use_hidden_conversations_count.d.ts.map +1 -0
  100. package/build/hooks/use_hidden_conversations_count.js +32 -0
  101. package/build/hooks/use_hidden_conversations_count.js.map +1 -0
  102. package/build/hooks/use_hide_conversation.d.ts +108 -0
  103. package/build/hooks/use_hide_conversation.d.ts.map +1 -0
  104. package/build/hooks/use_hide_conversation.js +243 -0
  105. package/build/hooks/use_hide_conversation.js.map +1 -0
  106. package/build/hooks/use_hide_conversations_enabled.d.ts +2 -0
  107. package/build/hooks/use_hide_conversations_enabled.d.ts.map +1 -0
  108. package/build/hooks/use_hide_conversations_enabled.js +18 -0
  109. package/build/hooks/use_hide_conversations_enabled.js.map +1 -0
  110. package/build/hooks/use_mark_latest_message_read.d.ts.map +1 -1
  111. package/build/hooks/use_mark_latest_message_read.js +5 -4
  112. package/build/hooks/use_mark_latest_message_read.js.map +1 -1
  113. package/build/hooks/use_new_conversation_from_filter.d.ts.map +1 -1
  114. package/build/hooks/use_new_conversation_from_filter.js +11 -1
  115. package/build/hooks/use_new_conversation_from_filter.js.map +1 -1
  116. package/build/hooks/use_product_analytics.d.ts.map +1 -1
  117. package/build/hooks/use_product_analytics.js +93 -75
  118. package/build/hooks/use_product_analytics.js.map +1 -1
  119. package/build/hooks/use_teams.d.ts +6 -0
  120. package/build/hooks/use_teams.d.ts.map +1 -1
  121. package/build/navigation/index.d.ts +5 -0
  122. package/build/navigation/index.d.ts.map +1 -1
  123. package/build/navigation/index.js +5 -0
  124. package/build/navigation/index.js.map +1 -1
  125. package/build/screens/conversation_actions_screen.d.ts +7 -0
  126. package/build/screens/conversation_actions_screen.d.ts.map +1 -0
  127. package/build/screens/conversation_actions_screen.js +89 -0
  128. package/build/screens/conversation_actions_screen.js.map +1 -0
  129. package/build/screens/conversation_details_screen.d.ts.map +1 -1
  130. package/build/screens/conversation_details_screen.js +460 -394
  131. package/build/screens/conversation_details_screen.js.map +1 -1
  132. package/build/screens/conversation_filters/components/conversation_filters.d.ts.map +1 -1
  133. package/build/screens/conversation_filters/components/conversation_filters.js +53 -12
  134. package/build/screens/conversation_filters/components/conversation_filters.js.map +1 -1
  135. package/build/screens/conversation_filters/components/rows.d.ts +6 -3
  136. package/build/screens/conversation_filters/components/rows.d.ts.map +1 -1
  137. package/build/screens/conversation_filters/components/rows.js +99 -62
  138. package/build/screens/conversation_filters/components/rows.js.map +1 -1
  139. package/build/screens/conversation_filters/context/conversation_filter_context.d.ts.map +1 -1
  140. package/build/screens/conversation_filters/context/conversation_filter_context.js +4 -0
  141. package/build/screens/conversation_filters/context/conversation_filter_context.js.map +1 -1
  142. package/build/screens/conversation_filters/filter_types.d.ts +1 -0
  143. package/build/screens/conversation_filters/filter_types.d.ts.map +1 -1
  144. package/build/screens/conversation_filters/filter_types.js +1 -0
  145. package/build/screens/conversation_filters/filter_types.js.map +1 -1
  146. package/build/screens/conversation_filters/hooks/filters.d.ts +12 -0
  147. package/build/screens/conversation_filters/hooks/filters.d.ts.map +1 -1
  148. package/build/screens/conversation_filters/screen_props.d.ts +1 -0
  149. package/build/screens/conversation_filters/screen_props.d.ts.map +1 -1
  150. package/build/screens/conversation_filters/screen_props.js.map +1 -1
  151. package/build/screens/conversation_new/components/groups_form.d.ts.map +1 -1
  152. package/build/screens/conversation_new/components/groups_form.js +96 -93
  153. package/build/screens/conversation_new/components/groups_form.js.map +1 -1
  154. package/build/screens/conversations/components/filter_dropdown_list_header_component.d.ts.map +1 -1
  155. package/build/screens/conversations/components/filter_dropdown_list_header_component.js +138 -126
  156. package/build/screens/conversations/components/filter_dropdown_list_header_component.js.map +1 -1
  157. package/build/screens/conversations/components/list_header_component.d.ts.map +1 -1
  158. package/build/screens/conversations/components/list_header_component.js +95 -90
  159. package/build/screens/conversations/components/list_header_component.js.map +1 -1
  160. package/build/screens/conversations/components/search_list_header_component.d.ts.map +1 -1
  161. package/build/screens/conversations/components/search_list_header_component.js +100 -95
  162. package/build/screens/conversations/components/search_list_header_component.js.map +1 -1
  163. package/build/screens/conversations/conversations_screen.d.ts +1 -0
  164. package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
  165. package/build/screens/conversations/conversations_screen.js +47 -21
  166. package/build/screens/conversations/conversations_screen.js.map +1 -1
  167. package/build/screens/get_help_screen.d.ts.map +1 -1
  168. package/build/screens/get_help_screen.js +4 -20
  169. package/build/screens/get_help_screen.js.map +1 -1
  170. package/build/screens/index.d.ts +1 -0
  171. package/build/screens/index.d.ts.map +1 -1
  172. package/build/screens/index.js +1 -0
  173. package/build/screens/index.js.map +1 -1
  174. package/build/types/jolt_events/index.d.ts +2 -0
  175. package/build/types/jolt_events/index.d.ts.map +1 -1
  176. package/build/types/jolt_events/index.js.map +1 -1
  177. package/build/types/jolt_events/person_events.d.ts +9 -0
  178. package/build/types/jolt_events/person_events.d.ts.map +1 -0
  179. package/build/types/jolt_events/person_events.js +2 -0
  180. package/build/types/jolt_events/person_events.js.map +1 -0
  181. package/build/types/resources/conversation_membership.d.ts +1 -0
  182. package/build/types/resources/conversation_membership.d.ts.map +1 -1
  183. package/build/types/resources/conversation_membership.js.map +1 -1
  184. package/build/types/resources/groups/groups_group_resource.d.ts +1 -1
  185. package/build/types/resources/groups/groups_group_resource.d.ts.map +1 -1
  186. package/build/types/resources/groups/groups_group_resource.js.map +1 -1
  187. package/build/types/resources/groups/groups_membership_resource.d.ts +11 -0
  188. package/build/types/resources/groups/groups_membership_resource.d.ts.map +1 -0
  189. package/build/types/resources/groups/groups_membership_resource.js +2 -0
  190. package/build/types/resources/groups/groups_membership_resource.js.map +1 -0
  191. package/build/types/resources/groups/index.d.ts +1 -0
  192. package/build/types/resources/groups/index.d.ts.map +1 -1
  193. package/build/types/resources/groups/index.js +1 -0
  194. package/build/types/resources/groups/index.js.map +1 -1
  195. package/build/utils/jolt/parse_stream_user_event_type.d.ts +3 -0
  196. package/build/utils/jolt/parse_stream_user_event_type.d.ts.map +1 -0
  197. package/build/utils/jolt/parse_stream_user_event_type.js +9 -0
  198. package/build/utils/jolt/parse_stream_user_event_type.js.map +1 -0
  199. package/build/utils/native_adapters/configuration.d.ts +3 -0
  200. package/build/utils/native_adapters/configuration.d.ts.map +1 -1
  201. package/build/utils/native_adapters/configuration.js +3 -0
  202. package/build/utils/native_adapters/configuration.js.map +1 -1
  203. package/build/utils/native_adapters/index.d.ts +1 -0
  204. package/build/utils/native_adapters/index.d.ts.map +1 -1
  205. package/build/utils/native_adapters/index.js +1 -0
  206. package/build/utils/native_adapters/index.js.map +1 -1
  207. package/build/utils/native_adapters/linking.d.ts.map +1 -1
  208. package/build/utils/native_adapters/linking.js +48 -2
  209. package/build/utils/native_adapters/linking.js.map +1 -1
  210. package/build/utils/native_adapters/updates.d.ts +11 -0
  211. package/build/utils/native_adapters/updates.d.ts.map +1 -0
  212. package/build/utils/native_adapters/updates.js +8 -0
  213. package/build/utils/native_adapters/updates.js.map +1 -0
  214. package/build/utils/product_analytics_token.d.ts +12 -0
  215. package/build/utils/product_analytics_token.d.ts.map +1 -0
  216. package/build/utils/product_analytics_token.js +84 -0
  217. package/build/utils/product_analytics_token.js.map +1 -0
  218. package/build/utils/request/conversation.d.ts +3 -1
  219. package/build/utils/request/conversation.d.ts.map +1 -1
  220. package/build/utils/request/conversation.js +4 -0
  221. package/build/utils/request/conversation.js.map +1 -1
  222. package/build/utils/throttled_refresh.d.ts +7 -0
  223. package/build/utils/throttled_refresh.d.ts.map +1 -0
  224. package/build/utils/throttled_refresh.js +42 -0
  225. package/build/utils/throttled_refresh.js.map +1 -0
  226. package/build/utils/toast_store.d.ts +21 -0
  227. package/build/utils/toast_store.d.ts.map +1 -0
  228. package/build/utils/toast_store.js +27 -0
  229. package/build/utils/toast_store.js.map +1 -0
  230. package/build/vendor/font_awesome_pro_solid_icons.d.ts +1 -0
  231. package/build/vendor/font_awesome_pro_solid_icons.d.ts.map +1 -1
  232. package/build/vendor/font_awesome_pro_solid_icons.js +5 -0
  233. package/build/vendor/font_awesome_pro_solid_icons.js.map +1 -1
  234. package/package.json +3 -3
  235. package/src/__tests__/hooks/use_group_chat_conversation_payload.test.tsx +31 -0
  236. package/src/__tests__/screens/conversation_filters/components/conversation_filters.test.tsx +6 -0
  237. package/src/components/conversations/__tests__/app_update_banner.test.tsx +27 -0
  238. package/src/components/conversations/__tests__/conversation_actions.test.tsx +77 -2
  239. package/src/components/conversations/__tests__/conversation_preview.test.tsx +29 -0
  240. package/src/components/conversations/__tests__/conversations.test.tsx +26 -0
  241. package/src/components/conversations/__tests__/conversations_blank_state.test.tsx +17 -0
  242. package/src/components/conversations/app_update_banner.tsx +36 -0
  243. package/src/components/conversations/conversation_actions.tsx +73 -4
  244. package/src/components/conversations/conversation_preview.tsx +12 -1
  245. package/src/components/conversations/conversations.tsx +9 -0
  246. package/src/components/conversations/conversations_blank_state.tsx +18 -0
  247. package/src/components/conversations/hidden_indicator.tsx +30 -0
  248. package/src/components/conversations/hidden_results_footer.tsx +25 -0
  249. package/src/components/display/__tests__/toast.test.tsx +55 -0
  250. package/src/components/display/toast.tsx +115 -0
  251. package/src/components/group_conversation_list.tsx +4 -1
  252. package/src/components/primitive/banner_primitive.tsx +5 -1
  253. package/src/contexts/api_provider.tsx +2 -0
  254. package/src/contexts/chat_context.tsx +2 -58
  255. package/src/contexts/conversations_context.tsx +8 -1
  256. package/src/contexts/session_context.tsx +3 -0
  257. package/src/hooks/__tests__/jolt_refresh_throttling.test.tsx +229 -0
  258. package/src/hooks/__tests__/use_conversations_jolt_events.test.tsx +1 -0
  259. package/src/hooks/__tests__/use_conversations_mark_read.test.tsx +38 -12
  260. package/src/hooks/__tests__/use_hide_conversation.test.tsx +189 -0
  261. package/src/hooks/__tests__/use_mark_latest_message_read.test.tsx +23 -2
  262. package/src/hooks/__tests__/use_product_analytics.test.tsx +304 -0
  263. package/src/hooks/groups/use_group_chat_conversation_payload.ts +30 -12
  264. package/src/hooks/groups/use_group_members_for_new_conversation.ts +49 -18
  265. package/src/hooks/groups/use_groups_conversation_create.ts +10 -14
  266. package/src/hooks/groups/use_groups_proxy.ts +6 -0
  267. package/src/hooks/use_api.ts +2 -1
  268. package/src/hooks/use_clear_conversation_filters.ts +1 -0
  269. package/src/hooks/use_conversation.ts +1 -0
  270. package/src/hooks/use_conversation_jolt_events.ts +2 -1
  271. package/src/hooks/use_conversations_actions.ts +7 -4
  272. package/src/hooks/use_conversations_cache.ts +1 -23
  273. package/src/hooks/use_conversations_jolt_events.ts +24 -10
  274. package/src/hooks/use_features.ts +2 -0
  275. package/src/hooks/use_groups_groups.ts +21 -16
  276. package/src/hooks/use_hidden_conversations_count.ts +14 -0
  277. package/src/hooks/use_hide_conversation.ts +128 -0
  278. package/src/hooks/use_hide_conversations_enabled.ts +7 -0
  279. package/src/hooks/use_mark_latest_message_read.ts +6 -5
  280. package/src/hooks/use_new_conversation_from_filter.ts +13 -5
  281. package/src/hooks/use_product_analytics.ts +74 -41
  282. package/src/navigation/index.tsx +8 -0
  283. package/src/screens/__tests__/conversation_actions_screen.test.tsx +79 -0
  284. package/src/screens/__tests__/conversation_details_screen.test.tsx +49 -1
  285. package/src/screens/conversation_actions_screen.tsx +53 -0
  286. package/src/screens/conversation_details_screen.tsx +19 -0
  287. package/src/screens/conversation_filters/__tests__/conversation_filters.test.tsx +42 -0
  288. package/src/screens/conversation_filters/components/conversation_filters.tsx +22 -3
  289. package/src/screens/conversation_filters/components/rows.tsx +44 -10
  290. package/src/screens/conversation_filters/context/conversation_filter_context.tsx +4 -0
  291. package/src/screens/conversation_filters/filter_types.ts +1 -0
  292. package/src/screens/conversation_filters/screen_props.ts +1 -0
  293. package/src/screens/conversation_new/components/groups_form.tsx +11 -9
  294. package/src/screens/conversations/__tests__/conversations_screen.test.tsx +3 -3
  295. package/src/screens/conversations/components/__tests__/filter_dropdown_list_header_component.test.tsx +42 -0
  296. package/src/screens/conversations/components/__tests__/list_header_component.test.tsx +1 -0
  297. package/src/screens/conversations/components/filter_dropdown_list_header_component.tsx +21 -5
  298. package/src/screens/conversations/components/list_header_component.tsx +14 -4
  299. package/src/screens/conversations/components/search_list_header_component.tsx +14 -4
  300. package/src/screens/conversations/conversations_screen.tsx +12 -1
  301. package/src/screens/get_help_screen.tsx +4 -18
  302. package/src/screens/index.ts +1 -0
  303. package/src/types/jolt_events/index.ts +2 -0
  304. package/src/types/jolt_events/person_events.ts +16 -0
  305. package/src/types/resources/conversation_membership.ts +1 -0
  306. package/src/types/resources/groups/groups_group_resource.ts +1 -1
  307. package/src/types/resources/groups/groups_membership_resource.ts +10 -0
  308. package/src/types/resources/groups/index.ts +1 -0
  309. package/src/utils/__tests__/throttled_refresh.test.ts +101 -0
  310. package/src/utils/jolt/__tests__/parse_stream_user_event_type.test.ts +27 -0
  311. package/src/utils/jolt/parse_stream_user_event_type.ts +16 -0
  312. package/src/utils/native_adapters/__tests__/linking.test.ts +60 -4
  313. package/src/utils/native_adapters/configuration.ts +5 -0
  314. package/src/utils/native_adapters/index.ts +1 -0
  315. package/src/utils/native_adapters/linking.ts +50 -2
  316. package/src/utils/native_adapters/updates.ts +16 -0
  317. package/src/utils/product_analytics_token.ts +120 -0
  318. package/src/utils/request/conversation.ts +6 -0
  319. package/src/utils/throttled_refresh.ts +62 -0
  320. package/src/utils/toast_store.ts +45 -0
  321. package/src/vendor/font_awesome_pro_solid_icons.ts +12 -0
@@ -1,4 +1,5 @@
1
- import { Linking } from 'react-native'
1
+ import { Alert, Linking } from 'react-native'
2
+ import { Clipboard, Log } from './configuration'
2
3
 
3
4
  export type LinkingOpenURLOptions = {
4
5
  forceOpenInBrowser?: boolean
@@ -9,12 +10,59 @@ type LinkingMethods = {
9
10
  canOpenURL: Linking['canOpenURL']
10
11
  }
11
12
 
13
+ const CONTACT_SCHEME = /^(mailto|tel):/i
14
+
12
15
  export class LinkingAdapter {
13
16
  openURL: LinkingMethods['openURL']
14
17
  canOpenURL: LinkingMethods['canOpenURL']
15
18
 
16
19
  constructor(methods: LinkingMethods) {
17
- this.openURL = methods.openURL.bind(Linking)
20
+ const openURL = methods.openURL.bind(Linking)
21
+
22
+ this.openURL = async (...args) => {
23
+ try {
24
+ await openURL(...args)
25
+ } catch (error) {
26
+ handleOpenFailure(args[0], error)
27
+ }
28
+ }
18
29
  this.canOpenURL = methods.canOpenURL.bind(Linking)
19
30
  }
20
31
  }
32
+
33
+ /**
34
+ * mailto: and tel: links fail for ordinary reasons (no mail app, no phone),
35
+ * so the user gets an alert offering to copy the address. Any other failure
36
+ * is reported through the Log adapter so it stays visible as a handled error.
37
+ */
38
+ function handleOpenFailure(url: string, error: unknown) {
39
+ if (CONTACT_SCHEME.test(url)) {
40
+ alertUnableToOpen(url)
41
+ return
42
+ }
43
+
44
+ Log.reportError(toError(error, url), { extra: { url } })
45
+ }
46
+
47
+ function alertUnableToOpen(url: string) {
48
+ const address = readableAddress(url)
49
+
50
+ Alert.alert('Oops', `Unable to open: ${address}`, [
51
+ { text: 'Copy to clipboard', onPress: () => Clipboard.setStringAsync(address) },
52
+ { text: 'OK' },
53
+ ])
54
+ }
55
+
56
+ function readableAddress(url: string) {
57
+ const address = url.replace(CONTACT_SCHEME, '')
58
+
59
+ try {
60
+ return decodeURIComponent(address)
61
+ } catch {
62
+ return address
63
+ }
64
+ }
65
+
66
+ function toError(error: unknown, url: string) {
67
+ return error instanceof Error ? error : new Error(`Unable to open URL: ${url}`)
68
+ }
@@ -0,0 +1,16 @@
1
+ import { noop } from 'lodash'
2
+
3
+ interface Updates {
4
+ useDownloadedUpdateId: () => string | undefined
5
+ restart: () => void
6
+ }
7
+
8
+ export class UpdatesAdapter {
9
+ useDownloadedUpdateId: () => string | undefined
10
+ restart: () => void
11
+
12
+ constructor(methods?: Updates) {
13
+ this.useDownloadedUpdateId = methods?.useDownloadedUpdateId ?? (() => undefined)
14
+ this.restart = methods?.restart ?? noop
15
+ }
16
+ }
@@ -0,0 +1,120 @@
1
+ import { QueryClient } from '@tanstack/react-query'
2
+ import { currentPersonQueryKey } from '../hooks/use_current_person'
3
+ import { ApiResource, CurrentPersonResource } from '../types'
4
+ import { ProductAnalyticsConfig } from '../types/product_analytics'
5
+ import { Client } from './client'
6
+ import { Storage } from './native_adapters'
7
+ import { Session } from './session'
8
+ import { ONE_HOUR, toMs } from './time'
9
+ import { Uri } from './uri'
10
+
11
+ interface ProductAnalyticsTokenResponse {
12
+ type: 'ProductAnalyticsToken'
13
+ id: string
14
+ url: string
15
+ metadata: Record<string, unknown>
16
+ }
17
+
18
+ export interface StoredProductAnalyticsConfig extends ProductAnalyticsConfig {
19
+ expiresAt: number
20
+ personId: string
21
+ }
22
+
23
+ export const TOKEN_EXPIRY_TIME = toMs(7 * 24, 'hours')
24
+ const EXPIRY_MARGIN = ONE_HOUR
25
+
26
+ // One slot per environment, tagged with the person it belongs to. Keying on
27
+ // session.id would miss on every access-token refresh and leave orphaned entries.
28
+ export const productAnalyticsStorageKey = (session: Session) =>
29
+ `product-analytics-token:${session.env}`
30
+
31
+ export const productAnalyticsQueryKey = (session: Session) => [
32
+ 'product-analytics-token',
33
+ session.env,
34
+ session.id,
35
+ ]
36
+
37
+ const renewalTime = (config: StoredProductAnalyticsConfig) => config.expiresAt - EXPIRY_MARGIN
38
+
39
+ const isStoredConfig = (value: unknown): value is StoredProductAnalyticsConfig =>
40
+ typeof value === 'object' &&
41
+ value !== null &&
42
+ typeof (value as StoredProductAnalyticsConfig).token === 'string' &&
43
+ typeof (value as StoredProductAnalyticsConfig).endpoint === 'string' &&
44
+ typeof (value as StoredProductAnalyticsConfig).expiresAt === 'number' &&
45
+ typeof (value as StoredProductAnalyticsConfig).personId === 'string'
46
+
47
+ async function readStoredConfig(key: string): Promise<StoredProductAnalyticsConfig | undefined> {
48
+ try {
49
+ const raw = await Storage.getItem(key)
50
+ if (!raw) return undefined
51
+
52
+ const parsed: unknown = JSON.parse(raw)
53
+ return isStoredConfig(parsed) ? parsed : undefined
54
+ } catch {
55
+ return undefined
56
+ }
57
+ }
58
+
59
+ function writeStoredConfig(key: string, config: StoredProductAnalyticsConfig): Promise<void> {
60
+ return Storage.setItem(key, JSON.stringify(config)).catch(() => {})
61
+ }
62
+
63
+ function requestConfig(session: Session, personId: string): Promise<StoredProductAnalyticsConfig> {
64
+ const uri = new Uri({ session })
65
+ const client = new Client({
66
+ root: uri.api('/chat/v2'),
67
+ defaultHeaders: uri.headers,
68
+ version: '2018-11-01',
69
+ })
70
+
71
+ return client
72
+ .post<ApiResource<ProductAnalyticsTokenResponse>>({
73
+ url: '/me/product_analytics_authorize',
74
+ data: { data: { type: 'ProductAnalyticsToken', attributes: {} } },
75
+ })
76
+ .then(res => ({
77
+ token: res.data.id,
78
+ endpoint: res.data.url,
79
+ metadata: res.data.metadata,
80
+ expiresAt: Date.now() + TOKEN_EXPIRY_TIME,
81
+ personId,
82
+ }))
83
+ }
84
+
85
+ // The chat screens that publish events already load /me, and the package's query
86
+ // client is cleared whenever the access token changes, so this is normally a cache hit.
87
+ async function currentPersonId(queryClient: QueryClient): Promise<string> {
88
+ const { data } = await queryClient.ensureQueryData<ApiResource<CurrentPersonResource>>({
89
+ queryKey: currentPersonQueryKey,
90
+ })
91
+ return String(data.id)
92
+ }
93
+
94
+ async function loadConfig(
95
+ queryClient: QueryClient,
96
+ session: Session
97
+ ): Promise<StoredProductAnalyticsConfig> {
98
+ const personId = await currentPersonId(queryClient)
99
+ const key = productAnalyticsStorageKey(session)
100
+ const stored = await readStoredConfig(key)
101
+ if (stored && stored.personId === personId && renewalTime(stored) > Date.now()) return stored
102
+
103
+ const config = await requestConfig(session, personId)
104
+ await writeStoredConfig(key, config)
105
+ return config
106
+ }
107
+
108
+ export function fetchProductAnalyticsConfig(
109
+ queryClient: QueryClient,
110
+ session: Session
111
+ ): Promise<StoredProductAnalyticsConfig> {
112
+ return queryClient.fetchQuery({
113
+ queryKey: productAnalyticsQueryKey(session),
114
+ queryFn: () => loadConfig(queryClient, session),
115
+ staleTime: ({ state }) =>
116
+ state.data ? Math.max(0, renewalTime(state.data) - state.dataUpdatedAt) : 0,
117
+ gcTime: TOKEN_EXPIRY_TIME,
118
+ retry: false,
119
+ })
120
+ }
@@ -7,15 +7,19 @@ export interface ConversationRequestArgs {
7
7
  group_source_app_name?: string
8
8
  show_direct_messages?: boolean
9
9
  show_archived?: boolean
10
+ show_hidden?: boolean
10
11
  show_unread?: boolean
11
12
  }
12
13
 
14
+ export const HIDDEN_CONVERSATIONS_FILTER = 'mine_or_not_empty,hidden'
15
+
13
16
  export const getConversationsRequestArgs = ({
14
17
  gids,
15
18
  chat_group_graph_id,
16
19
  group_source_app_name,
17
20
  show_direct_messages,
18
21
  show_archived,
22
+ show_hidden,
19
23
  show_unread,
20
24
  }: Partial<ConversationRequestArgs> = {}): GetRequest => {
21
25
  let filter: string
@@ -23,6 +27,8 @@ export const getConversationsRequestArgs = ({
23
27
  filter = 'mine_or_not_empty,group'
24
28
  } else if (show_archived) {
25
29
  filter = 'mine_or_not_empty,archived'
30
+ } else if (show_hidden) {
31
+ filter = HIDDEN_CONVERSATIONS_FILTER
26
32
  } else if (show_unread) {
27
33
  filter = 'mine_or_not_empty,unread'
28
34
  } else if (show_direct_messages) {
@@ -0,0 +1,62 @@
1
+ import { hashKey, QueryClient, QueryKey } from '@tanstack/react-query'
2
+ import { DebouncedFuncLeading, throttle } from 'lodash'
3
+
4
+ export const REFRESH_THROTTLE_MS = 3000
5
+
6
+ type Refresh = () => unknown
7
+
8
+ interface ThrottledRefresh {
9
+ run: DebouncedFuncLeading<(refresh: Refresh) => void>
10
+ lastEvent?: object
11
+ }
12
+
13
+ const refreshesByClient = new WeakMap<QueryClient, Map<string, ThrottledRefresh>>()
14
+
15
+ const refreshesFor = (queryClient: QueryClient) => {
16
+ const existing = refreshesByClient.get(queryClient)
17
+ if (existing) return existing
18
+
19
+ const refreshes = new Map<string, ThrottledRefresh>()
20
+ refreshesByClient.set(queryClient, refreshes)
21
+ return refreshes
22
+ }
23
+
24
+ const throttledRefreshFor = (queryClient: QueryClient, key: QueryKey) => {
25
+ const refreshes = refreshesFor(queryClient)
26
+ const hashedKey = hashKey(key)
27
+ const existing = refreshes.get(hashedKey)
28
+ if (existing) return existing
29
+
30
+ const created: ThrottledRefresh = {
31
+ run: throttle(
32
+ (refresh: Refresh) => {
33
+ refresh()
34
+ },
35
+ REFRESH_THROTTLE_MS,
36
+ { leading: true, trailing: true }
37
+ ),
38
+ }
39
+ refreshes.set(hashedKey, created)
40
+ return created
41
+ }
42
+
43
+ export const throttledRefresh = (
44
+ queryClient: QueryClient,
45
+ key: QueryKey,
46
+ event: object,
47
+ refresh: Refresh
48
+ ) => {
49
+ const throttled = throttledRefreshFor(queryClient, key)
50
+ if (throttled.lastEvent === event) return
51
+
52
+ throttled.lastEvent = event
53
+ throttled.run(refresh)
54
+ }
55
+
56
+ export const cancelThrottledRefreshes = (queryClient: QueryClient) => {
57
+ const refreshes = refreshesByClient.get(queryClient)
58
+ if (!refreshes) return
59
+
60
+ refreshes.forEach(({ run }) => run.cancel())
61
+ refreshesByClient.delete(queryClient)
62
+ }
@@ -0,0 +1,45 @@
1
+ export interface ToastAction {
2
+ label: string
3
+ onPress: () => void
4
+ }
5
+
6
+ export interface ToastOptions {
7
+ title: string
8
+ subtitle?: string
9
+ action?: ToastAction
10
+ }
11
+
12
+ export interface ToastState extends ToastOptions {
13
+ id: number
14
+ }
15
+
16
+ type Listener = () => void
17
+
18
+ let currentToast: ToastState | null = null
19
+ let nextId = 1
20
+ const listeners = new Set<Listener>()
21
+
22
+ const emit = () => listeners.forEach(listener => listener())
23
+
24
+ export const toastStore = {
25
+ getSnapshot: () => currentToast,
26
+ subscribe: (listener: Listener) => {
27
+ listeners.add(listener)
28
+ return () => {
29
+ listeners.delete(listener)
30
+ }
31
+ },
32
+ }
33
+
34
+ export function showToast(options: ToastOptions) {
35
+ currentToast = { ...options, id: nextId++ }
36
+ emit()
37
+ }
38
+
39
+ export function dismissToast(id?: number) {
40
+ if (!currentToast) return
41
+ if (id !== undefined && currentToast.id !== id) return
42
+
43
+ currentToast = null
44
+ emit()
45
+ }
@@ -620,3 +620,15 @@ export const faBoxArchive: IconDefinition = {
620
620
  'M0 64C0 46.3 14.3 32 32 32l448 0c17.7 0 32 14.3 32 32l0 32c0 17.7-14.3 32-32 32L32 128C14.3 128 0 113.7 0 96L0 64zM32 176l448 0 0 240c0 35.3-28.7 64-64 64L96 480c-35.3 0-64-28.7-64-64l0-240zm152 64c-13.3 0-24 10.7-24 24s10.7 24 24 24l144 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-144 0z',
621
621
  ],
622
622
  }
623
+
624
+ export const faEyeSlash: IconDefinition = {
625
+ prefix: 'fas',
626
+ iconName: 'eye-slash',
627
+ icon: [
628
+ 576,
629
+ 512,
630
+ [],
631
+ 'f070',
632
+ 'M41-24.9c-9.4-9.4-24.6-9.4-33.9 0S-2.3-.3 7 9.1l528 528c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-96.4-96.4c2.7-2.4 5.4-4.8 8-7.2 46.8-43.5 78.1-95.4 93-131.1 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1-47.1-43.7-111.8-80.6-192.6-80.6-56.8 0-105.6 18.2-146 44.2L41-24.9zM204.5 138.7c23.5-16.8 52.4-26.7 83.5-26.7 79.5 0 144 64.5 144 144 0 31.1-9.9 59.9-26.7 83.5l-34.7-34.7c12.7-21.4 17-47.7 10.1-73.7-13.7-51.2-66.4-81.6-117.6-67.9-8.6 2.3-16.7 5.7-24 10l-34.7-34.7zM325.3 395.1c-11.9 3.2-24.4 4.9-37.3 4.9-79.5 0-144-64.5-144-144 0-12.9 1.7-25.4 4.9-37.3L69.4 139.2c-32.6 36.8-55 75.8-66.9 104.5-3.3 7.9-3.3 16.7 0 24.6 14.9 35.7 46.2 87.7 93 131.1 47.1 43.7 111.8 80.6 192.6 80.6 37.3 0 71.2-7.9 101.5-20.6l-64.2-64.2z',
633
+ ],
634
+ }