@planningcenter/chat-react-native 4.2.1-qa-staging.7 → 4.2.1-qa-staging.9

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 (188) hide show
  1. package/build/components/conversation/message_form.d.ts +1 -1
  2. package/build/components/conversation/message_form.d.ts.map +1 -1
  3. package/build/components/conversation/message_form.js +167 -373
  4. package/build/components/conversation/message_form.js.map +1 -1
  5. package/build/components/conversation/message_list.d.ts +4 -2
  6. package/build/components/conversation/message_list.d.ts.map +1 -1
  7. package/build/components/conversation/message_list.js +115 -81
  8. package/build/components/conversation/message_list.js.map +1 -1
  9. package/build/components/conversation/missing_message.d.ts +2 -0
  10. package/build/components/conversation/missing_message.d.ts.map +1 -0
  11. package/build/components/conversation/missing_message.js +139 -0
  12. package/build/components/conversation/missing_message.js.map +1 -0
  13. package/build/contexts/api_provider.d.ts.map +1 -1
  14. package/build/contexts/api_provider.js +1 -2
  15. package/build/contexts/api_provider.js.map +1 -1
  16. package/build/contexts/conversation_context.d.ts +1 -3
  17. package/build/contexts/conversation_context.d.ts.map +1 -1
  18. package/build/contexts/conversation_context.js +18 -23
  19. package/build/contexts/conversation_context.js.map +1 -1
  20. package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +4 -3
  21. package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -1
  22. package/build/hooks/paginator_meta.d.ts +1 -3
  23. package/build/hooks/paginator_meta.d.ts.map +1 -1
  24. package/build/hooks/paginator_meta.js +8 -25
  25. package/build/hooks/paginator_meta.js.map +1 -1
  26. package/build/hooks/use_api.d.ts.map +1 -1
  27. package/build/hooks/use_api.js +8 -5
  28. package/build/hooks/use_api.js.map +1 -1
  29. package/build/hooks/use_conversation_messages.d.ts +10 -8
  30. package/build/hooks/use_conversation_messages.d.ts.map +1 -1
  31. package/build/hooks/use_conversation_messages.js +218 -81
  32. package/build/hooks/use_conversation_messages.js.map +1 -1
  33. package/build/hooks/use_conversation_messages_jolt_events.d.ts +1 -17
  34. package/build/hooks/use_conversation_messages_jolt_events.d.ts.map +1 -1
  35. package/build/hooks/use_conversation_messages_jolt_events.js +90 -83
  36. package/build/hooks/use_conversation_messages_jolt_events.js.map +1 -1
  37. package/build/hooks/use_features.d.ts +2 -1
  38. package/build/hooks/use_features.d.ts.map +1 -1
  39. package/build/hooks/use_features.js +2 -1
  40. package/build/hooks/use_features.js.map +1 -1
  41. package/build/hooks/use_message_create_or_update.d.ts.map +1 -1
  42. package/build/hooks/use_message_create_or_update.js +80 -91
  43. package/build/hooks/use_message_create_or_update.js.map +1 -1
  44. package/build/hooks/use_message_reaction_toggle.d.ts.map +1 -1
  45. package/build/hooks/use_message_reaction_toggle.js +40 -45
  46. package/build/hooks/use_message_reaction_toggle.js.map +1 -1
  47. package/build/hooks/use_read_receipts.d.ts +4 -3
  48. package/build/hooks/use_read_receipts.d.ts.map +1 -1
  49. package/build/hooks/use_suspense_api.d.ts +10 -6
  50. package/build/hooks/use_suspense_api.d.ts.map +1 -1
  51. package/build/hooks/use_suspense_api.js +88 -65
  52. package/build/hooks/use_suspense_api.js.map +1 -1
  53. package/build/screens/conversation_screen.d.ts +1 -1
  54. package/build/screens/conversation_screen.d.ts.map +1 -1
  55. package/build/screens/conversation_screen.js +338 -463
  56. package/build/screens/conversation_screen.js.map +1 -1
  57. package/build/screens/message_actions_screen.d.ts.map +1 -1
  58. package/build/screens/message_actions_screen.js +26 -21
  59. package/build/screens/message_actions_screen.js.map +1 -1
  60. package/build/screens/message_report_screen.d.ts.map +1 -1
  61. package/build/screens/message_report_screen.js +44 -17
  62. package/build/screens/message_report_screen.js.map +1 -1
  63. package/build/screens/notification_settings/hooks/groups.d.ts +4 -3
  64. package/build/screens/notification_settings/hooks/groups.d.ts.map +1 -1
  65. package/build/screens/reactions_screen.d.ts.map +1 -1
  66. package/build/screens/reactions_screen.js +88 -70
  67. package/build/screens/reactions_screen.js.map +1 -1
  68. package/build/types/api_primitives.d.ts +0 -1
  69. package/build/types/api_primitives.d.ts.map +1 -1
  70. package/build/types/api_primitives.js.map +1 -1
  71. package/build/utils/cache/messages_cache.d.ts +0 -1
  72. package/build/utils/cache/messages_cache.d.ts.map +1 -1
  73. package/build/utils/cache/messages_cache.js +0 -3
  74. package/build/utils/cache/messages_cache.js.map +1 -1
  75. package/build/utils/cache/messages_window.d.ts +11 -0
  76. package/build/utils/cache/messages_window.d.ts.map +1 -0
  77. package/build/utils/cache/messages_window.js +51 -0
  78. package/build/utils/cache/messages_window.js.map +1 -0
  79. package/build/utils/cache/optimistically_update_message.d.ts +1 -2
  80. package/build/utils/cache/optimistically_update_message.d.ts.map +1 -1
  81. package/build/utils/cache/optimistically_update_message.js +4 -4
  82. package/build/utils/cache/optimistically_update_message.js.map +1 -1
  83. package/build/utils/generate_placeholder_ulid.d.ts +6 -0
  84. package/build/utils/generate_placeholder_ulid.d.ts.map +1 -1
  85. package/build/utils/generate_placeholder_ulid.js +2 -2
  86. package/build/utils/generate_placeholder_ulid.js.map +1 -1
  87. package/build/utils/request/get_messages.d.ts +6 -18
  88. package/build/utils/request/get_messages.d.ts.map +1 -1
  89. package/build/utils/request/get_messages.js +12 -10
  90. package/build/utils/request/get_messages.js.map +1 -1
  91. package/package.json +3 -3
  92. package/src/__tests__/hooks/paginator_meta.test.ts +2 -73
  93. package/src/__tests__/hooks/use_features.test.ts +10 -2
  94. package/src/__utils__/query_client.ts +3 -0
  95. package/src/components/conversation/__tests__/message_list.test.tsx +0 -42
  96. package/src/components/conversation/message_form.tsx +30 -5
  97. package/src/components/conversation/message_list.tsx +44 -14
  98. package/src/components/conversation/missing_message.tsx +66 -0
  99. package/src/contexts/api_provider.tsx +1 -2
  100. package/src/contexts/conversation_context.tsx +1 -6
  101. package/src/hooks/__tests__/use_conversation_messages.test.tsx +333 -0
  102. package/src/hooks/__tests__/use_conversation_messages_jolt_events.test.tsx +87 -0
  103. package/src/hooks/__tests__/use_mark_latest_message_read.test.tsx +33 -0
  104. package/src/hooks/__tests__/use_message_create_or_update.test.tsx +2 -7
  105. package/src/hooks/paginator_meta.ts +5 -29
  106. package/src/hooks/use_api.ts +5 -4
  107. package/src/hooks/use_conversation_messages.ts +88 -43
  108. package/src/hooks/use_conversation_messages_jolt_events.ts +53 -62
  109. package/src/hooks/use_features.ts +3 -2
  110. package/src/hooks/use_message_create_or_update.ts +8 -8
  111. package/src/hooks/use_message_reaction_toggle.ts +1 -3
  112. package/src/hooks/use_suspense_api.ts +17 -8
  113. package/src/screens/conversation_screen.tsx +63 -123
  114. package/src/screens/message_actions_screen.tsx +5 -3
  115. package/src/screens/message_report_screen.tsx +3 -2
  116. package/src/screens/reactions_screen.tsx +4 -2
  117. package/src/types/api_primitives.ts +0 -1
  118. package/src/utils/cache/__tests__/messages_cache.test.ts +3 -15
  119. package/src/utils/cache/__tests__/messages_cache_deletion.test.ts +2 -1
  120. package/src/utils/cache/__tests__/messages_cache_reply_roots.test.ts +3 -2
  121. package/src/utils/cache/__tests__/messages_window.test.ts +78 -0
  122. package/src/utils/cache/messages_cache.ts +0 -3
  123. package/src/utils/cache/messages_window.ts +55 -0
  124. package/src/utils/cache/optimistically_update_message.ts +5 -2
  125. package/src/utils/generate_placeholder_ulid.ts +2 -2
  126. package/src/utils/request/get_messages.ts +14 -12
  127. package/build/components/conversation/anchor_not_found_boundary.d.ts +0 -18
  128. package/build/components/conversation/anchor_not_found_boundary.d.ts.map +0 -1
  129. package/build/components/conversation/anchor_not_found_boundary.js +0 -20
  130. package/build/components/conversation/anchor_not_found_boundary.js.map +0 -1
  131. package/build/hooks/use_conversation_message_lookup.d.ts +0 -7
  132. package/build/hooks/use_conversation_message_lookup.d.ts.map +0 -1
  133. package/build/hooks/use_conversation_message_lookup.js +0 -52
  134. package/build/hooks/use_conversation_message_lookup.js.map +0 -1
  135. package/build/hooks/use_fetch_newer_messages.d.ts +0 -9
  136. package/build/hooks/use_fetch_newer_messages.d.ts.map +0 -1
  137. package/build/hooks/use_fetch_newer_messages.js +0 -69
  138. package/build/hooks/use_fetch_newer_messages.js.map +0 -1
  139. package/build/hooks/use_fetch_newer_on_foreground.d.ts +0 -8
  140. package/build/hooks/use_fetch_newer_on_foreground.d.ts.map +0 -1
  141. package/build/hooks/use_fetch_newer_on_foreground.js +0 -42
  142. package/build/hooks/use_fetch_newer_on_foreground.js.map +0 -1
  143. package/build/hooks/use_held_back_messages.d.ts +0 -11
  144. package/build/hooks/use_held_back_messages.d.ts.map +0 -1
  145. package/build/hooks/use_held_back_messages.js +0 -24
  146. package/build/hooks/use_held_back_messages.js.map +0 -1
  147. package/build/utils/cache/find_message_in_caches.d.ts +0 -4
  148. package/build/utils/cache/find_message_in_caches.d.ts.map +0 -1
  149. package/build/utils/cache/find_message_in_caches.js +0 -16
  150. package/build/utils/cache/find_message_in_caches.js.map +0 -1
  151. package/build/utils/cache/invalidate_refetchable_queries.d.ts +0 -3
  152. package/build/utils/cache/invalidate_refetchable_queries.d.ts.map +0 -1
  153. package/build/utils/cache/invalidate_refetchable_queries.js +0 -8
  154. package/build/utils/cache/invalidate_refetchable_queries.js.map +0 -1
  155. package/build/utils/cache/prepend_newer_page.d.ts +0 -7
  156. package/build/utils/cache/prepend_newer_page.d.ts.map +0 -1
  157. package/build/utils/cache/prepend_newer_page.js +0 -15
  158. package/build/utils/cache/prepend_newer_page.js.map +0 -1
  159. package/build/utils/gated_message_cache.d.ts +0 -7
  160. package/build/utils/gated_message_cache.d.ts.map +0 -1
  161. package/build/utils/gated_message_cache.js +0 -13
  162. package/build/utils/gated_message_cache.js.map +0 -1
  163. package/build/utils/ulid.d.ts +0 -3
  164. package/build/utils/ulid.d.ts.map +0 -1
  165. package/build/utils/ulid.js +0 -7
  166. package/build/utils/ulid.js.map +0 -1
  167. package/src/__tests__/hooks/use_conversation_messages.test.ts +0 -22
  168. package/src/__tests__/hooks/use_conversation_messages_jolt_events.test.ts +0 -33
  169. package/src/__tests__/utils/gated_message_cache.test.ts +0 -26
  170. package/src/__tests__/utils/request/get_messages.test.ts +0 -24
  171. package/src/__tests__/utils/ulid.test.ts +0 -15
  172. package/src/components/conversation/__tests__/anchor_not_found_boundary.test.tsx +0 -51
  173. package/src/components/conversation/anchor_not_found_boundary.tsx +0 -21
  174. package/src/hooks/__tests__/use_fetch_newer_messages.test.tsx +0 -95
  175. package/src/hooks/__tests__/use_held_back_messages.test.tsx +0 -60
  176. package/src/hooks/__tests__/use_message_reaction_toggle.test.tsx +0 -73
  177. package/src/hooks/use_conversation_message_lookup.ts +0 -29
  178. package/src/hooks/use_fetch_newer_messages.ts +0 -52
  179. package/src/hooks/use_fetch_newer_on_foreground.ts +0 -25
  180. package/src/hooks/use_held_back_messages.ts +0 -33
  181. package/src/utils/cache/__tests__/find_message_in_caches.test.ts +0 -37
  182. package/src/utils/cache/__tests__/invalidate_refetchable_queries.test.ts +0 -23
  183. package/src/utils/cache/__tests__/prepend_newer_page.test.ts +0 -34
  184. package/src/utils/cache/find_message_in_caches.ts +0 -20
  185. package/src/utils/cache/invalidate_refetchable_queries.ts +0 -9
  186. package/src/utils/cache/prepend_newer_page.ts +0 -19
  187. package/src/utils/gated_message_cache.ts +0 -19
  188. package/src/utils/ulid.ts +0 -11
@@ -13,7 +13,7 @@ interface MessagesFormRootProps extends ViewProps {
13
13
  replyRootId?: string | null;
14
14
  replyRootAuthorFirstName?: string | null;
15
15
  onFlaggedInMessageForm?: (id: string) => void;
16
- onBeforeSubmit?: () => void;
16
+ onBeforeSubmit?: () => void | Promise<void>;
17
17
  }
18
18
  declare function MessageFormRoot({ conversation, currentlyEditingMessage, children, replyRootId, replyRootAuthorFirstName, onFlaggedInMessageForm, onBeforeSubmit, }: MessagesFormRootProps): import("react/jsx-runtime").JSX.Element;
19
19
  declare function MessageFormInput(): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"message_form.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_form.tsx"],"names":[],"mappings":"AAEA,OAAO,EAQL,SAAS,EAEV,MAAM,cAAc,CAAA;AAiBrB,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AA6BnE,eAAO,MAAM,WAAW;;;;;;CAOvB,CAAA;AAED,UAAU,qBAAsB,SAAQ,SAAS;IAC/C,YAAY,EAAE,oBAAoB,CAAA;IAClC,uBAAuB,CAAC,EAAE,eAAe,GAAG,IAAI,CAAA;IAChD,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxC,sBAAsB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7C,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;CAC5B;AAmCD,iBAAS,eAAe,CAAC,EACvB,YAAY,EACZ,uBAAuB,EACvB,QAAQ,EACR,WAAW,EACX,wBAAwB,EACxB,sBAAsB,EACtB,cAAc,GACf,EAAE,qBAAqB,2CA8KvB;AAyID,iBAAS,gBAAgB,4CAyDxB;AAcD,iBAAS,oBAAoB,4CAgD5B;AAED,iBAAS,2BAA2B,mDAuHnC;AAED,iBAAS,mBAAmB,mDAkC3B"}
1
+ {"version":3,"file":"message_form.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_form.tsx"],"names":[],"mappings":"AAEA,OAAO,EAQL,SAAS,EAEV,MAAM,cAAc,CAAA;AAiBrB,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AA8BnE,eAAO,MAAM,WAAW;;;;;;CAOvB,CAAA;AAED,UAAU,qBAAsB,SAAQ,SAAS;IAC/C,YAAY,EAAE,oBAAoB,CAAA;IAClC,uBAAuB,CAAC,EAAE,eAAe,GAAG,IAAI,CAAA;IAChD,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxC,sBAAsB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7C,cAAc,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5C;AAmCD,iBAAS,eAAe,CAAC,EACvB,YAAY,EACZ,uBAAuB,EACvB,QAAQ,EACR,WAAW,EACX,wBAAwB,EACxB,sBAAsB,EACtB,cAAc,GACf,EAAE,qBAAqB,2CAsMvB;AAyID,iBAAS,gBAAgB,4CAyDxB;AAcD,iBAAS,oBAAoB,4CAgD5B;AAED,iBAAS,2BAA2B,mDAuHnC;AAED,iBAAS,mBAAmB,mDAkC3B"}
@@ -1,6 +1,6 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import { useNavigation, useTheme as useNavigationTheme, useRoute } from '@react-navigation/native';
3
- import React, { useCallback, useContext, useEffect, useState } from 'react';
3
+ import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';
4
4
  import { Linking, Platform, Pressable, ScrollView, StyleSheet, TextInput, View, Keyboard } from 'react-native';
5
5
  import LinearGradient from 'react-native-linear-gradient';
6
6
  import { Heading, Icon, IconButton, Text, TextButton } from '../../components';
@@ -11,7 +11,7 @@ import { useBroadcastTypingStatus } from '../../hooks/use_broadcast_typing_statu
11
11
  import { useChatConfiguration } from '../../hooks/use_chat_configuration';
12
12
  import { useMessageCreateOrUpdate } from '../../hooks/use_message_create_or_update';
13
13
  import { useMessageDraft } from '../../hooks/use_message_draft';
14
- import { MAX_FONT_SIZE_MULTIPLIER_LANDMARK, platformFontWeightMedium, platformPressedOpacityStyle } from '../../utils';
14
+ import { Log, MAX_FONT_SIZE_MULTIPLIER_LANDMARK, platformFontWeightMedium, platformPressedOpacityStyle } from '../../utils';
15
15
  import { pickAttachmentPreviewKind } from '../../utils/attachment_kind';
16
16
  import { canSubmitMessage } from '../../utils/can_submit_message';
17
17
  import { isInputEditable } from '../../utils/is_input_editable';
@@ -48,17 +48,15 @@ const MessageFormContext = React.createContext({
48
48
  const GIPHY_MAX_LENGTH = 50;
49
49
  const MAX_MESSAGE_LENGTH = 5000;
50
50
  const PLACEHOLDER_FONT_SCALE_THRESHOLD = 1.7;
51
- function MessageFormRoot(t0) {
52
- const $ = _c(89);
53
- const {
54
- conversation,
55
- currentlyEditingMessage,
56
- children,
57
- replyRootId,
58
- replyRootAuthorFirstName,
59
- onFlaggedInMessageForm,
60
- onBeforeSubmit
61
- } = t0;
51
+ function MessageFormRoot({
52
+ conversation,
53
+ currentlyEditingMessage,
54
+ children,
55
+ replyRootId,
56
+ replyRootAuthorFirstName,
57
+ onFlaggedInMessageForm,
58
+ onBeforeSubmit
59
+ }) {
62
60
  const {
63
61
  giphyApiKey
64
62
  } = useContext(ChatContext);
@@ -69,297 +67,162 @@ function MessageFormRoot(t0) {
69
67
  saveDraft,
70
68
  clearDraft
71
69
  } = useMessageDraft();
72
- let t1;
73
- if ($[0] !== currentlyEditingMessage || $[1] !== draft?.text) {
74
- t1 = () => currentlyEditingMessage ? "" : draft?.text || "";
75
- $[0] = currentlyEditingMessage;
76
- $[1] = draft?.text;
77
- $[2] = t1;
78
- } else {
79
- t1 = $[2];
80
- }
81
- const [text, setText] = React.useState(t1);
70
+ const [text, setText] = React.useState(() => {
71
+ // Initialize from draft only when not editing a message
72
+ return currentlyEditingMessage ? '' : draft?.text || '';
73
+ });
82
74
  const [usingGiphy, setUsingGiphy] = useState(false);
83
75
  const navigation = useNavigation();
84
76
  const route = useRoute();
85
- const t2 = currentlyEditingMessage || undefined;
86
- let t3;
87
- if ($[3] !== conversation.id || $[4] !== replyRootId || $[5] !== t2) {
88
- t3 = {
89
- conversationId: conversation.id,
90
- message: t2,
91
- replyRootId
92
- };
93
- $[3] = conversation.id;
94
- $[4] = replyRootId;
95
- $[5] = t2;
96
- $[6] = t3;
97
- } else {
98
- t3 = $[6];
99
- }
100
77
  const {
101
78
  status,
102
79
  isPending,
103
80
  reset: resetMutation,
104
81
  mutateAsync
105
- } = useMessageCreateOrUpdate(t3);
106
- const t4 = currentlyEditingMessage ? undefined : draft?.attachments;
107
- let t5;
108
- if ($[7] !== conversation.id || $[8] !== onFlaggedInMessageForm || $[9] !== t4) {
109
- t5 = {
110
- conversationId: conversation.id,
111
- draftAttachments: t4,
112
- onFlaggedInMessageForm
113
- };
114
- $[7] = conversation.id;
115
- $[8] = onFlaggedInMessageForm;
116
- $[9] = t4;
117
- $[10] = t5;
118
- } else {
119
- t5 = $[10];
120
- }
121
- const attachmentUploader = useAttachmentUploader(t5);
82
+ } = useMessageCreateOrUpdate({
83
+ conversationId: conversation.id,
84
+ message: currentlyEditingMessage || undefined,
85
+ replyRootId
86
+ });
87
+ const attachmentUploader = useAttachmentUploader({
88
+ conversationId: conversation.id,
89
+ draftAttachments: currentlyEditingMessage ? undefined : draft?.attachments,
90
+ onFlaggedInMessageForm
91
+ });
122
92
  const resetAttachmentUploader = attachmentUploader.reset;
123
- let t6;
124
- if ($[11] !== clearDraft || $[12] !== currentlyEditingMessage || $[13] !== navigation || $[14] !== resetAttachmentUploader || $[15] !== resetMutation) {
125
- t6 = () => {
126
- resetAttachmentUploader();
127
- resetMutation();
128
- setText("");
129
- setUsingGiphy(false);
130
- if (!currentlyEditingMessage) {
131
- clearDraft();
132
- }
93
+ const reset = useCallback(() => {
94
+ resetAttachmentUploader();
95
+ resetMutation();
96
+ setText('');
97
+ setUsingGiphy(false);
98
+ if (!currentlyEditingMessage) {
99
+ clearDraft();
100
+ }
101
+ navigation.setParams({
102
+ editing_message_id: null
103
+ });
104
+ }, [resetAttachmentUploader, resetMutation, navigation, currentlyEditingMessage, clearDraft]);
105
+ useEffect(() => {
106
+ if (canGiphy && !usingGiphy && text.startsWith('/giphy ')) {
107
+ setUsingGiphy(true);
108
+ setText('');
109
+ }
110
+ }, [canGiphy, text, usingGiphy]);
111
+ useEffect(() => {
112
+ switch (status) {
113
+ case 'success':
114
+ reset();
115
+ break;
116
+ }
117
+ }, [reset, status]);
118
+ useEffect(() => {
119
+ if (route.params.clear_input) {
120
+ reset();
133
121
  navigation.setParams({
134
- editing_message_id: null
122
+ ...route.params,
123
+ clear_input: false
135
124
  });
136
- };
137
- $[11] = clearDraft;
138
- $[12] = currentlyEditingMessage;
139
- $[13] = navigation;
140
- $[14] = resetAttachmentUploader;
141
- $[15] = resetMutation;
142
- $[16] = t6;
143
- } else {
144
- t6 = $[16];
145
- }
146
- const reset = t6;
147
- let t7;
148
- let t8;
149
- if ($[17] !== canGiphy || $[18] !== text || $[19] !== usingGiphy) {
150
- t7 = () => {
151
- if (canGiphy && !usingGiphy && text.startsWith("/giphy ")) {
152
- setUsingGiphy(true);
153
- setText("");
154
- }
155
- };
156
- t8 = [canGiphy, text, usingGiphy];
157
- $[17] = canGiphy;
158
- $[18] = text;
159
- $[19] = usingGiphy;
160
- $[20] = t7;
161
- $[21] = t8;
162
- } else {
163
- t7 = $[20];
164
- t8 = $[21];
165
- }
166
- useEffect(t7, t8);
167
- let t10;
168
- let t9;
169
- if ($[22] !== reset || $[23] !== status) {
170
- t9 = () => {
171
- switch (status) {
172
- case "success":
173
- {
174
- reset();
175
- }
176
- }
177
- };
178
- t10 = [reset, status];
179
- $[22] = reset;
180
- $[23] = status;
181
- $[24] = t10;
182
- $[25] = t9;
183
- } else {
184
- t10 = $[24];
185
- t9 = $[25];
186
- }
187
- useEffect(t9, t10);
188
- let t11;
189
- let t12;
190
- if ($[26] !== navigation || $[27] !== reset || $[28] !== route.params) {
191
- t11 = () => {
192
- if (route.params.clear_input) {
193
- reset();
194
- navigation.setParams({
195
- ...route.params,
196
- clear_input: false
197
- });
198
- }
199
- };
200
- t12 = [reset, navigation, route.params];
201
- $[26] = navigation;
202
- $[27] = reset;
203
- $[28] = route.params;
204
- $[29] = t11;
205
- $[30] = t12;
206
- } else {
207
- t11 = $[29];
208
- t12 = $[30];
209
- }
210
- useEffect(t11, t12);
211
- let t13;
212
- let t14;
213
- if ($[31] !== attachmentUploader.attachments || $[32] !== currentlyEditingMessage || $[33] !== saveDraft || $[34] !== text) {
214
- t13 = () => {
215
- if (currentlyEditingMessage) {
216
- return;
217
- }
218
- const timeoutId = setTimeout(() => {
219
- saveDraft(text, attachmentUploader.attachments);
220
- }, 500);
221
- return () => clearTimeout(timeoutId);
222
- };
223
- t14 = [text, attachmentUploader.attachments, saveDraft, currentlyEditingMessage];
224
- $[31] = attachmentUploader.attachments;
225
- $[32] = currentlyEditingMessage;
226
- $[33] = saveDraft;
227
- $[34] = text;
228
- $[35] = t13;
229
- $[36] = t14;
230
- } else {
231
- t13 = $[35];
232
- t14 = $[36];
233
- }
234
- useEffect(t13, t14);
235
- const t15 = conversation.disabled ?? false;
236
- const t16 = !!attachmentUploader?.pendingUploads;
237
- const t17 = !!attachmentUploader?.flaggedAttachmentCount;
238
- let t18;
239
- if ($[37] !== attachmentUploader.attachmentIds?.length || $[38] !== isPending || $[39] !== t15 || $[40] !== t16 || $[41] !== t17 || $[42] !== text) {
240
- t18 = canSubmitMessage({
241
- isPending,
242
- conversationDisabled: t15,
243
- pendingUploads: t16,
244
- hasFlaggedAttachments: t17,
245
- hasText: hasMessageText(text),
246
- hasSendableAttachments: !!attachmentUploader?.attachmentIds?.length
247
- });
248
- $[37] = attachmentUploader.attachmentIds?.length;
249
- $[38] = isPending;
250
- $[39] = t15;
251
- $[40] = t16;
252
- $[41] = t17;
253
- $[42] = text;
254
- $[43] = t18;
255
- } else {
256
- t18 = $[43];
257
- }
258
- const canSubmit = t18;
125
+ }
126
+ }, [reset, navigation, route.params]);
127
+
128
+ // Save draft when text or attachments change (debounced)
129
+ useEffect(() => {
130
+ // Don't save drafts when editing a message
131
+ if (currentlyEditingMessage) return;
132
+ const timeoutId = setTimeout(() => {
133
+ saveDraft(text, attachmentUploader.attachments);
134
+ }, 500);
135
+ return () => clearTimeout(timeoutId);
136
+ }, [text, attachmentUploader.attachments, saveDraft, currentlyEditingMessage]);
137
+ const canSubmit = canSubmitMessage({
138
+ isPending,
139
+ conversationDisabled: conversation.disabled ?? false,
140
+ pendingUploads: !!attachmentUploader?.pendingUploads,
141
+ hasFlaggedAttachments: !!attachmentUploader?.flaggedAttachmentCount,
142
+ hasText: hasMessageText(text),
143
+ hasSendableAttachments: !!attachmentUploader?.attachmentIds?.length
144
+ });
259
145
  const disabled = !canSubmit;
260
- const t19 = conversation.disabled ?? false;
261
- let t20;
262
- if ($[44] !== isPending || $[45] !== t19) {
263
- t20 = isInputEditable({
264
- isPending,
265
- conversationDisabled: t19
266
- });
267
- $[44] = isPending;
268
- $[45] = t19;
269
- $[46] = t20;
270
- } else {
271
- t20 = $[46];
272
- }
273
- const inputEditable = t20;
274
- let t21;
275
- if ($[47] !== conversation.id || $[48] !== navigation || $[49] !== text) {
276
- t21 = () => {
277
- if (!Keyboard.isVisible() || Platform.OS === "ios") {
278
- navigation.navigate("SendGiphy", {
146
+ const inputEditable = isInputEditable({
147
+ isPending,
148
+ conversationDisabled: conversation.disabled ?? false
149
+ });
150
+
151
+ /*
152
+ Opening a FormSheet on Android while the keyboard is visible breaks the FormSheet's height & position.
153
+ This is a workaround to ensure we don't open the FormSheet while the keyboard is visible.
154
+ */
155
+ const navigateToSendGiphyAfterKeyboardHides = useCallback(() => {
156
+ if (!Keyboard.isVisible() || Platform.OS === 'ios') {
157
+ navigation.navigate('SendGiphy', {
158
+ conversation_id: conversation.id,
159
+ search_term: text
160
+ });
161
+ } else {
162
+ const keyboardListener = Keyboard.addListener('keyboardDidHide', () => {
163
+ navigation.navigate('SendGiphy', {
279
164
  conversation_id: conversation.id,
280
165
  search_term: text
281
166
  });
282
- } else {
283
- const keyboardListener = Keyboard.addListener("keyboardDidHide", () => {
284
- navigation.navigate("SendGiphy", {
285
- conversation_id: conversation.id,
286
- search_term: text
287
- });
288
- keyboardListener?.remove();
167
+ keyboardListener?.remove();
168
+ });
169
+ }
170
+ }, [conversation.id, navigation, text]);
171
+ const catchingUp = useRef(false);
172
+
173
+ // A send from a window behind the live edge would leave a gap above it, so a failed
174
+ // catch-up stops the send and keeps what was typed.
175
+ const catchUpBeforeSend = async () => {
176
+ if (catchingUp.current) return false;
177
+ catchingUp.current = true;
178
+ try {
179
+ await onBeforeSubmit?.();
180
+ return true;
181
+ } catch (error) {
182
+ Log.error('send stopped: live window fetch failed', error);
183
+ return false;
184
+ } finally {
185
+ catchingUp.current = false;
186
+ }
187
+ };
188
+ const handleSubmit = async () => {
189
+ if (!canSubmit) return;
190
+ if (canGiphy && usingGiphy) {
191
+ if (!(await catchUpBeforeSend())) return;
192
+ TextInput.State.blurTextInput(TextInput.State.currentlyFocusedInput());
193
+ Haptic.impactLight();
194
+ navigateToSendGiphyAfterKeyboardHides();
195
+ } else {
196
+ let attachmentsForSubmit = attachmentUploader.attachments.filter(a => a.status === 'success' && a.id).map(attachment => ({
197
+ type: 'MessageAttachment',
198
+ id: attachment.id,
199
+ file: attachment.file
200
+ }));
201
+ const messageText = stripEmptyTextCharacters(text);
202
+ if (currentlyEditingMessage) {
203
+ mutateAsync({
204
+ text: messageText
289
205
  });
290
- }
291
- };
292
- $[47] = conversation.id;
293
- $[48] = navigation;
294
- $[49] = text;
295
- $[50] = t21;
296
- } else {
297
- t21 = $[50];
298
- }
299
- const navigateToSendGiphyAfterKeyboardHides = t21;
300
- let t22;
301
- if ($[51] !== attachmentUploader.attachments || $[52] !== canGiphy || $[53] !== canSubmit || $[54] !== currentlyEditingMessage || $[55] !== mutateAsync || $[56] !== navigateToSendGiphyAfterKeyboardHides || $[57] !== onBeforeSubmit || $[58] !== reset || $[59] !== text || $[60] !== usingGiphy) {
302
- t22 = () => {
303
- if (!canSubmit) {
304
- return;
305
- }
306
- if (canGiphy && usingGiphy) {
307
- TextInput.State.blurTextInput(TextInput.State.currentlyFocusedInput());
308
- Haptic.impactLight();
309
- navigateToSendGiphyAfterKeyboardHides();
206
+ reset();
310
207
  } else {
311
- const attachmentsForSubmit = attachmentUploader.attachments.filter(_temp).map(_temp2);
312
- const messageText = stripEmptyTextCharacters(text);
313
- if (currentlyEditingMessage) {
314
- mutateAsync({
315
- text: messageText
316
- });
317
- reset();
318
- } else {
319
- onBeforeSubmit?.();
320
- mutateAsync({
321
- text: messageText,
322
- attachments: attachmentsForSubmit
323
- });
324
- reset();
325
- }
326
- }
327
- };
328
- $[51] = attachmentUploader.attachments;
329
- $[52] = canGiphy;
330
- $[53] = canSubmit;
331
- $[54] = currentlyEditingMessage;
332
- $[55] = mutateAsync;
333
- $[56] = navigateToSendGiphyAfterKeyboardHides;
334
- $[57] = onBeforeSubmit;
335
- $[58] = reset;
336
- $[59] = text;
337
- $[60] = usingGiphy;
338
- $[61] = t22;
339
- } else {
340
- t22 = $[61];
341
- }
342
- const handleSubmit = t22;
343
- let t23;
344
- let t24;
345
- if ($[62] !== currentlyEditingMessage) {
346
- t23 = () => {
347
- if (currentlyEditingMessage) {
348
- setText(currentlyEditingMessage.text || "");
208
+ // The live-window fetch replaces the cache, which would wipe an optimistic row
209
+ // added earlier.
210
+ if (!(await catchUpBeforeSend())) return;
211
+ reset();
212
+ mutateAsync({
213
+ text: messageText,
214
+ attachments: attachmentsForSubmit
215
+ });
349
216
  }
350
- };
351
- t24 = [currentlyEditingMessage];
352
- $[62] = currentlyEditingMessage;
353
- $[63] = t23;
354
- $[64] = t24;
355
- } else {
356
- t23 = $[63];
357
- t24 = $[64];
358
- }
359
- useEffect(t23, t24);
360
- let t25;
361
- if ($[65] !== attachmentUploader || $[66] !== canGiphy || $[67] !== currentlyEditingMessage || $[68] !== disabled || $[69] !== handleSubmit || $[70] !== inputEditable || $[71] !== replyRootAuthorFirstName || $[72] !== replyRootId || $[73] !== reset || $[74] !== text || $[75] !== usingGiphy) {
362
- t25 = {
217
+ }
218
+ };
219
+ useEffect(() => {
220
+ if (currentlyEditingMessage) {
221
+ setText(currentlyEditingMessage.text || '');
222
+ }
223
+ }, [currentlyEditingMessage]);
224
+ return /*#__PURE__*/_jsx(MessageFormContext.Provider, {
225
+ value: {
363
226
  text,
364
227
  setText,
365
228
  onSubmit: handleSubmit,
@@ -373,84 +236,15 @@ function MessageFormRoot(t0) {
373
236
  reset,
374
237
  replyRootId,
375
238
  replyRootAuthorFirstName
376
- };
377
- $[65] = attachmentUploader;
378
- $[66] = canGiphy;
379
- $[67] = currentlyEditingMessage;
380
- $[68] = disabled;
381
- $[69] = handleSubmit;
382
- $[70] = inputEditable;
383
- $[71] = replyRootAuthorFirstName;
384
- $[72] = replyRootId;
385
- $[73] = reset;
386
- $[74] = text;
387
- $[75] = usingGiphy;
388
- $[76] = t25;
389
- } else {
390
- t25 = $[76];
391
- }
392
- let t26;
393
- let t27;
394
- let t28;
395
- if ($[77] === Symbol.for("react.memo_cache_sentinel")) {
396
- t26 = /*#__PURE__*/_jsx(EditingIndicator, {});
397
- t27 = /*#__PURE__*/_jsx(ReplyIndicator, {});
398
- t28 = /*#__PURE__*/_jsx(FlaggedContentBanner, {});
399
- $[77] = t26;
400
- $[78] = t27;
401
- $[79] = t28;
402
- } else {
403
- t26 = $[77];
404
- t27 = $[78];
405
- t28 = $[79];
406
- }
407
- let t29;
408
- if ($[80] !== children || $[81] !== styles.textInputContainer) {
409
- t29 = /*#__PURE__*/_jsx(View, {
410
- style: styles.textInputContainer,
411
- children: children
412
- });
413
- $[80] = children;
414
- $[81] = styles.textInputContainer;
415
- $[82] = t29;
416
- } else {
417
- t29 = $[82];
418
- }
419
- let t30;
420
- if ($[83] !== styles.container || $[84] !== t29) {
421
- t30 = /*#__PURE__*/_jsxs(View, {
239
+ },
240
+ children: /*#__PURE__*/_jsxs(View, {
422
241
  style: styles.container,
423
- children: [t26, t27, t28, t29]
424
- });
425
- $[83] = styles.container;
426
- $[84] = t29;
427
- $[85] = t30;
428
- } else {
429
- t30 = $[85];
430
- }
431
- let t31;
432
- if ($[86] !== t25 || $[87] !== t30) {
433
- t31 = /*#__PURE__*/_jsx(MessageFormContext.Provider, {
434
- value: t25,
435
- children: t30
436
- });
437
- $[86] = t25;
438
- $[87] = t30;
439
- $[88] = t31;
440
- } else {
441
- t31 = $[88];
442
- }
443
- return t31;
444
- }
445
- function _temp2(attachment) {
446
- return {
447
- type: "MessageAttachment",
448
- id: attachment.id,
449
- file: attachment.file
450
- };
451
- }
452
- function _temp(a) {
453
- return a.status === "success" && a.id;
242
+ children: [/*#__PURE__*/_jsx(EditingIndicator, {}), /*#__PURE__*/_jsx(ReplyIndicator, {}), /*#__PURE__*/_jsx(FlaggedContentBanner, {}), /*#__PURE__*/_jsx(View, {
243
+ style: styles.textInputContainer,
244
+ children: children
245
+ })]
246
+ })
247
+ });
454
248
  }
455
249
  function MessageFormAttachments() {
456
250
  const $ = _c(10);
@@ -553,7 +347,7 @@ function FlaggedContentBanner() {
553
347
  if ($[0] !== attachmentUploader?.attachments) {
554
348
  t1 = Symbol.for("react.early_return_sentinel");
555
349
  bb0: {
556
- const flaggedAttachments = attachmentUploader?.attachments.filter(_temp3) ?? [];
350
+ const flaggedAttachments = attachmentUploader?.attachments.filter(_temp) ?? [];
557
351
  const flaggedCount = flaggedAttachments.length;
558
352
  if (flaggedCount === 0) {
559
353
  t1 = null;
@@ -660,7 +454,7 @@ function FlaggedContentBanner() {
660
454
  }
661
455
  return t8;
662
456
  }
663
- function _temp3(a) {
457
+ function _temp(a) {
664
458
  return a.flagged;
665
459
  }
666
460
  function BannerMessage(t0) {
@@ -674,7 +468,7 @@ function BannerMessage(t0) {
674
468
  if ($[0] !== styles.flaggedBannerLink) {
675
469
  t1 = /*#__PURE__*/_jsx(Text, {
676
470
  style: styles.flaggedBannerLink,
677
- onPress: _temp4,
471
+ onPress: _temp2,
678
472
  accessibilityRole: "link",
679
473
  children: "content guidelines"
680
474
  });
@@ -703,7 +497,7 @@ function BannerMessage(t0) {
703
497
  }
704
498
  return t2;
705
499
  }
706
- function _temp4() {
500
+ function _temp2() {
707
501
  return Linking.openURL("https://www.planningcenter.com/terms#:~:text=4.%20Acceptable%20Use%20of%20Planning%20Center");
708
502
  }
709
503
  function MessageFormInput() {
@@ -1047,7 +841,7 @@ function MessageFormAttachmentPicker() {
1047
841
  if (result.canceled) {
1048
842
  return;
1049
843
  }
1050
- const filteredAssets = result.assets.filter(_temp5).map(_temp6);
844
+ const filteredAssets = result.assets.filter(_temp3).map(_temp4);
1051
845
  attachmentUploader?.handleFilesAttached(filteredAssets);
1052
846
  };
1053
847
  $[0] = attachmentUploader;
@@ -1062,7 +856,7 @@ function MessageFormAttachmentPicker() {
1062
856
  if (result_0.canceled) {
1063
857
  return;
1064
858
  }
1065
- const filteredAssets_0 = result_0.assets.filter(_temp7).map(_temp8);
859
+ const filteredAssets_0 = result_0.assets.filter(_temp5).map(_temp6);
1066
860
  attachmentUploader?.handleFilesAttached(filteredAssets_0);
1067
861
  };
1068
862
  $[2] = attachmentUploader;
@@ -1202,7 +996,7 @@ function MessageFormAttachmentPicker() {
1202
996
  }
1203
997
  return t8;
1204
998
  }
1205
- function _temp8(asset_2) {
999
+ function _temp6(asset_2) {
1206
1000
  return {
1207
1001
  uri: asset_2.uri,
1208
1002
  name: asset_2.name,
@@ -1210,10 +1004,10 @@ function _temp8(asset_2) {
1210
1004
  size: asset_2.size
1211
1005
  };
1212
1006
  }
1213
- function _temp7(asset_1) {
1007
+ function _temp5(asset_1) {
1214
1008
  return asset_1.size != null && asset_1.uri;
1215
1009
  }
1216
- function _temp6(asset_0) {
1010
+ function _temp4(asset_0) {
1217
1011
  return {
1218
1012
  uri: asset_0.uri,
1219
1013
  name: asset_0.fileName || asset_0.uri.split("/").pop() || "attachment",
@@ -1223,7 +1017,7 @@ function _temp6(asset_0) {
1223
1017
  width: asset_0.width
1224
1018
  };
1225
1019
  }
1226
- function _temp5(asset) {
1020
+ function _temp3(asset) {
1227
1021
  return asset.fileSize && asset.mimeType && asset.uri;
1228
1022
  }
1229
1023
  function MessageFormCommands() {