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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) 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_message_create_or_update.d.ts.map +1 -1
  38. package/build/hooks/use_message_create_or_update.js +80 -91
  39. package/build/hooks/use_message_create_or_update.js.map +1 -1
  40. package/build/hooks/use_message_reaction_toggle.d.ts.map +1 -1
  41. package/build/hooks/use_message_reaction_toggle.js +40 -45
  42. package/build/hooks/use_message_reaction_toggle.js.map +1 -1
  43. package/build/hooks/use_read_receipts.d.ts +4 -3
  44. package/build/hooks/use_read_receipts.d.ts.map +1 -1
  45. package/build/hooks/use_suspense_api.d.ts +10 -6
  46. package/build/hooks/use_suspense_api.d.ts.map +1 -1
  47. package/build/hooks/use_suspense_api.js +88 -65
  48. package/build/hooks/use_suspense_api.js.map +1 -1
  49. package/build/screens/conversation_screen.d.ts +1 -1
  50. package/build/screens/conversation_screen.d.ts.map +1 -1
  51. package/build/screens/conversation_screen.js +338 -463
  52. package/build/screens/conversation_screen.js.map +1 -1
  53. package/build/screens/message_actions_screen.d.ts.map +1 -1
  54. package/build/screens/message_actions_screen.js +26 -21
  55. package/build/screens/message_actions_screen.js.map +1 -1
  56. package/build/screens/message_report_screen.d.ts.map +1 -1
  57. package/build/screens/message_report_screen.js +44 -17
  58. package/build/screens/message_report_screen.js.map +1 -1
  59. package/build/screens/notification_settings/hooks/groups.d.ts +4 -3
  60. package/build/screens/notification_settings/hooks/groups.d.ts.map +1 -1
  61. package/build/screens/reactions_screen.d.ts.map +1 -1
  62. package/build/screens/reactions_screen.js +88 -70
  63. package/build/screens/reactions_screen.js.map +1 -1
  64. package/build/types/api_primitives.d.ts +0 -1
  65. package/build/types/api_primitives.d.ts.map +1 -1
  66. package/build/types/api_primitives.js.map +1 -1
  67. package/build/utils/cache/messages_cache.d.ts +0 -1
  68. package/build/utils/cache/messages_cache.d.ts.map +1 -1
  69. package/build/utils/cache/messages_cache.js +0 -3
  70. package/build/utils/cache/messages_cache.js.map +1 -1
  71. package/build/utils/cache/messages_window.d.ts +11 -0
  72. package/build/utils/cache/messages_window.d.ts.map +1 -0
  73. package/build/utils/cache/messages_window.js +51 -0
  74. package/build/utils/cache/messages_window.js.map +1 -0
  75. package/build/utils/cache/optimistically_update_message.d.ts +1 -2
  76. package/build/utils/cache/optimistically_update_message.d.ts.map +1 -1
  77. package/build/utils/cache/optimistically_update_message.js +4 -4
  78. package/build/utils/cache/optimistically_update_message.js.map +1 -1
  79. package/build/utils/generate_placeholder_ulid.d.ts +6 -0
  80. package/build/utils/generate_placeholder_ulid.d.ts.map +1 -1
  81. package/build/utils/generate_placeholder_ulid.js +2 -2
  82. package/build/utils/generate_placeholder_ulid.js.map +1 -1
  83. package/build/utils/request/get_messages.d.ts +6 -18
  84. package/build/utils/request/get_messages.d.ts.map +1 -1
  85. package/build/utils/request/get_messages.js +12 -10
  86. package/build/utils/request/get_messages.js.map +1 -1
  87. package/package.json +3 -3
  88. package/src/__tests__/hooks/paginator_meta.test.ts +2 -73
  89. package/src/components/conversation/__tests__/message_list.test.tsx +0 -42
  90. package/src/components/conversation/message_form.tsx +30 -5
  91. package/src/components/conversation/message_list.tsx +44 -14
  92. package/src/components/conversation/missing_message.tsx +66 -0
  93. package/src/contexts/api_provider.tsx +1 -2
  94. package/src/contexts/conversation_context.tsx +1 -6
  95. package/src/hooks/__tests__/use_conversation_messages.test.tsx +333 -0
  96. package/src/hooks/__tests__/use_conversation_messages_jolt_events.test.tsx +87 -0
  97. package/src/hooks/__tests__/use_mark_latest_message_read.test.tsx +33 -0
  98. package/src/hooks/paginator_meta.ts +5 -29
  99. package/src/hooks/use_api.ts +5 -4
  100. package/src/hooks/use_conversation_messages.ts +88 -43
  101. package/src/hooks/use_conversation_messages_jolt_events.ts +53 -62
  102. package/src/hooks/use_message_create_or_update.ts +8 -8
  103. package/src/hooks/use_message_reaction_toggle.ts +1 -3
  104. package/src/hooks/use_suspense_api.ts +17 -8
  105. package/src/screens/conversation_screen.tsx +63 -123
  106. package/src/screens/message_actions_screen.tsx +5 -3
  107. package/src/screens/message_report_screen.tsx +3 -2
  108. package/src/screens/reactions_screen.tsx +4 -2
  109. package/src/types/api_primitives.ts +0 -1
  110. package/src/utils/cache/__tests__/messages_cache.test.ts +1 -14
  111. package/src/utils/cache/__tests__/messages_window.test.ts +78 -0
  112. package/src/utils/cache/messages_cache.ts +0 -3
  113. package/src/utils/cache/messages_window.ts +55 -0
  114. package/src/utils/cache/optimistically_update_message.ts +5 -2
  115. package/src/utils/generate_placeholder_ulid.ts +2 -2
  116. package/src/utils/request/get_messages.ts +14 -12
  117. package/build/components/conversation/anchor_not_found_boundary.d.ts +0 -18
  118. package/build/components/conversation/anchor_not_found_boundary.d.ts.map +0 -1
  119. package/build/components/conversation/anchor_not_found_boundary.js +0 -20
  120. package/build/components/conversation/anchor_not_found_boundary.js.map +0 -1
  121. package/build/hooks/use_conversation_message_lookup.d.ts +0 -7
  122. package/build/hooks/use_conversation_message_lookup.d.ts.map +0 -1
  123. package/build/hooks/use_conversation_message_lookup.js +0 -52
  124. package/build/hooks/use_conversation_message_lookup.js.map +0 -1
  125. package/build/hooks/use_fetch_newer_messages.d.ts +0 -9
  126. package/build/hooks/use_fetch_newer_messages.d.ts.map +0 -1
  127. package/build/hooks/use_fetch_newer_messages.js +0 -69
  128. package/build/hooks/use_fetch_newer_messages.js.map +0 -1
  129. package/build/hooks/use_fetch_newer_on_foreground.d.ts +0 -8
  130. package/build/hooks/use_fetch_newer_on_foreground.d.ts.map +0 -1
  131. package/build/hooks/use_fetch_newer_on_foreground.js +0 -42
  132. package/build/hooks/use_fetch_newer_on_foreground.js.map +0 -1
  133. package/build/hooks/use_held_back_messages.d.ts +0 -11
  134. package/build/hooks/use_held_back_messages.d.ts.map +0 -1
  135. package/build/hooks/use_held_back_messages.js +0 -24
  136. package/build/hooks/use_held_back_messages.js.map +0 -1
  137. package/build/utils/cache/find_message_in_caches.d.ts +0 -4
  138. package/build/utils/cache/find_message_in_caches.d.ts.map +0 -1
  139. package/build/utils/cache/find_message_in_caches.js +0 -16
  140. package/build/utils/cache/find_message_in_caches.js.map +0 -1
  141. package/build/utils/cache/invalidate_refetchable_queries.d.ts +0 -3
  142. package/build/utils/cache/invalidate_refetchable_queries.d.ts.map +0 -1
  143. package/build/utils/cache/invalidate_refetchable_queries.js +0 -8
  144. package/build/utils/cache/invalidate_refetchable_queries.js.map +0 -1
  145. package/build/utils/cache/prepend_newer_page.d.ts +0 -7
  146. package/build/utils/cache/prepend_newer_page.d.ts.map +0 -1
  147. package/build/utils/cache/prepend_newer_page.js +0 -15
  148. package/build/utils/cache/prepend_newer_page.js.map +0 -1
  149. package/build/utils/gated_message_cache.d.ts +0 -7
  150. package/build/utils/gated_message_cache.d.ts.map +0 -1
  151. package/build/utils/gated_message_cache.js +0 -13
  152. package/build/utils/gated_message_cache.js.map +0 -1
  153. package/build/utils/ulid.d.ts +0 -3
  154. package/build/utils/ulid.d.ts.map +0 -1
  155. package/build/utils/ulid.js +0 -7
  156. package/build/utils/ulid.js.map +0 -1
  157. package/src/__tests__/hooks/use_conversation_messages.test.ts +0 -22
  158. package/src/__tests__/hooks/use_conversation_messages_jolt_events.test.ts +0 -33
  159. package/src/__tests__/utils/gated_message_cache.test.ts +0 -26
  160. package/src/__tests__/utils/request/get_messages.test.ts +0 -24
  161. package/src/__tests__/utils/ulid.test.ts +0 -15
  162. package/src/components/conversation/__tests__/anchor_not_found_boundary.test.tsx +0 -51
  163. package/src/components/conversation/anchor_not_found_boundary.tsx +0 -21
  164. package/src/hooks/__tests__/use_fetch_newer_messages.test.tsx +0 -95
  165. package/src/hooks/__tests__/use_held_back_messages.test.tsx +0 -60
  166. package/src/hooks/__tests__/use_message_reaction_toggle.test.tsx +0 -73
  167. package/src/hooks/use_conversation_message_lookup.ts +0 -29
  168. package/src/hooks/use_fetch_newer_messages.ts +0 -52
  169. package/src/hooks/use_fetch_newer_on_foreground.ts +0 -25
  170. package/src/hooks/use_held_back_messages.ts +0 -33
  171. package/src/utils/cache/__tests__/find_message_in_caches.test.ts +0 -37
  172. package/src/utils/cache/__tests__/invalidate_refetchable_queries.test.ts +0 -23
  173. package/src/utils/cache/__tests__/prepend_newer_page.test.ts +0 -34
  174. package/src/utils/cache/find_message_in_caches.ts +0 -20
  175. package/src/utils/cache/invalidate_refetchable_queries.ts +0 -9
  176. package/src/utils/cache/prepend_newer_page.ts +0 -19
  177. package/src/utils/gated_message_cache.ts +0 -19
  178. package/src/utils/ulid.ts +0 -11
@@ -0,0 +1,11 @@
1
+ import { InfiniteData } from '@tanstack/react-query';
2
+ import { ApiCollection, MessageResource } from '../../types';
3
+ import { RequestData } from '../client';
4
+ export type MessagesWindow = InfiniteData<ApiCollection<MessageResource>, Partial<RequestData> | undefined>;
5
+ export declare const livePageParam: Partial<RequestData>;
6
+ export declare const anchoredPageParam: (anchor: string) => Partial<RequestData>;
7
+ export declare function isBehindLiveEdge(data: MessagesWindow | undefined): boolean;
8
+ export declare function newerPageParam(firstPage: ApiCollection<MessageResource>): Partial<RequestData> | undefined;
9
+ export declare function newestFirst<Page extends ApiCollection<MessageResource>>(page: Page, pageParam: Partial<RequestData> | undefined): Page;
10
+ export declare function markLiveIfCaughtUp(data: MessagesWindow | undefined): MessagesWindow | undefined;
11
+ //# sourceMappingURL=messages_window.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages_window.d.ts","sourceRoot":"","sources":["../../../src/utils/cache/messages_window.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,MAAM,cAAc,GAAG,YAAY,CACvC,aAAa,CAAC,eAAe,CAAC,EAC9B,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS,CACjC,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,WAAW,CAAM,CAAA;AAErD,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,KAAG,OAAO,CAAC,WAAW,CAEpE,CAAA;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAE1E;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,aAAa,CAAC,eAAe,CAAC,GACxC,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS,CAMlC;AAKD,wBAAgB,WAAW,CAAC,IAAI,SAAS,aAAa,CAAC,eAAe,CAAC,EACrE,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS,GAC1C,IAAI,CAUN;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,GAAG,cAAc,GAAG,SAAS,CAO/F"}
@@ -0,0 +1,51 @@
1
+ export const livePageParam = {};
2
+ export const anchoredPageParam = anchor => ({
3
+ where: {
4
+ id_around: anchor
5
+ }
6
+ });
7
+ export function isBehindLiveEdge(data) {
8
+ return !!data?.pages[0]?.meta?.prev;
9
+ }
10
+ export function newerPageParam(firstPage) {
11
+ const newestId = firstPage.meta?.prev?.idGt;
12
+ if (!newestId) return undefined;
13
+
14
+ // Without asc the server hands back the newest page instead, leaving a gap.
15
+ return {
16
+ where: {
17
+ id_gt: newestId
18
+ },
19
+ order: 'asc'
20
+ };
21
+ }
22
+
23
+ // The server returns newer pages oldest first, linking only to the next newer page.
24
+ // Storing them newest first with an older link lets a refetch replay the window
25
+ // forward from its top page like any other.
26
+ export function newestFirst(page, pageParam) {
27
+ if (pageParam?.order !== 'asc') return page;
28
+ const data = [...page.data].reverse();
29
+ const oldest = data[data.length - 1];
30
+ return {
31
+ ...page,
32
+ data,
33
+ meta: {
34
+ ...page.meta,
35
+ prev: page.meta?.next,
36
+ next: oldest && {
37
+ idLt: oldest.id
38
+ }
39
+ }
40
+ };
41
+ }
42
+ export function markLiveIfCaughtUp(data) {
43
+ if (!data) return data;
44
+ const topIsLive = !data.pageParams[0]?.where;
45
+ if (topIsLive || isBehindLiveEdge(data)) return data;
46
+ return {
47
+ ...data,
48
+ pageParams: [livePageParam, ...data.pageParams.slice(1)]
49
+ };
50
+ }
51
+ //# sourceMappingURL=messages_window.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages_window.js","names":["livePageParam","anchoredPageParam","anchor","where","id_around","isBehindLiveEdge","data","pages","meta","prev","newerPageParam","firstPage","newestId","idGt","undefined","id_gt","order","newestFirst","page","pageParam","reverse","oldest","length","next","idLt","id","markLiveIfCaughtUp","topIsLive","pageParams","slice"],"sources":["../../../src/utils/cache/messages_window.ts"],"sourcesContent":["import { InfiniteData } from '@tanstack/react-query'\nimport { ApiCollection, MessageResource } from '../../types'\nimport { RequestData } from '../client'\n\nexport type MessagesWindow = InfiniteData<\n ApiCollection<MessageResource>,\n Partial<RequestData> | undefined\n>\n\nexport const livePageParam: Partial<RequestData> = {}\n\nexport const anchoredPageParam = (anchor: string): Partial<RequestData> => ({\n where: { id_around: anchor },\n})\n\nexport function isBehindLiveEdge(data: MessagesWindow | undefined): boolean {\n return !!data?.pages[0]?.meta?.prev\n}\n\nexport function newerPageParam(\n firstPage: ApiCollection<MessageResource>\n): Partial<RequestData> | undefined {\n const newestId = firstPage.meta?.prev?.idGt\n if (!newestId) return undefined\n\n // Without asc the server hands back the newest page instead, leaving a gap.\n return { where: { id_gt: newestId }, order: 'asc' }\n}\n\n// The server returns newer pages oldest first, linking only to the next newer page.\n// Storing them newest first with an older link lets a refetch replay the window\n// forward from its top page like any other.\nexport function newestFirst<Page extends ApiCollection<MessageResource>>(\n page: Page,\n pageParam: Partial<RequestData> | undefined\n): Page {\n if (pageParam?.order !== 'asc') return page\n\n const data = [...page.data].reverse()\n const oldest = data[data.length - 1]\n return {\n ...page,\n data,\n meta: { ...page.meta, prev: page.meta?.next, next: oldest && { idLt: oldest.id } },\n }\n}\n\nexport function markLiveIfCaughtUp(data: MessagesWindow | undefined): MessagesWindow | undefined {\n if (!data) return data\n\n const topIsLive = !data.pageParams[0]?.where\n if (topIsLive || isBehindLiveEdge(data)) return data\n\n return { ...data, pageParams: [livePageParam, ...data.pageParams.slice(1)] }\n}\n"],"mappings":"AASA,OAAO,MAAMA,aAAmC,GAAG,CAAC,CAAC;AAErD,OAAO,MAAMC,iBAAiB,GAAIC,MAAc,KAA4B;EAC1EC,KAAK,EAAE;IAAEC,SAAS,EAAEF;EAAO;AAC7B,CAAC,CAAC;AAEF,OAAO,SAASG,gBAAgBA,CAACC,IAAgC,EAAW;EAC1E,OAAO,CAAC,CAACA,IAAI,EAAEC,KAAK,CAAC,CAAC,CAAC,EAAEC,IAAI,EAAEC,IAAI;AACrC;AAEA,OAAO,SAASC,cAAcA,CAC5BC,SAAyC,EACP;EAClC,MAAMC,QAAQ,GAAGD,SAAS,CAACH,IAAI,EAAEC,IAAI,EAAEI,IAAI;EAC3C,IAAI,CAACD,QAAQ,EAAE,OAAOE,SAAS;;EAE/B;EACA,OAAO;IAAEX,KAAK,EAAE;MAAEY,KAAK,EAAEH;IAAS,CAAC;IAAEI,KAAK,EAAE;EAAM,CAAC;AACrD;;AAEA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CACzBC,IAAU,EACVC,SAA2C,EACrC;EACN,IAAIA,SAAS,EAAEH,KAAK,KAAK,KAAK,EAAE,OAAOE,IAAI;EAE3C,MAAMZ,IAAI,GAAG,CAAC,GAAGY,IAAI,CAACZ,IAAI,CAAC,CAACc,OAAO,CAAC,CAAC;EACrC,MAAMC,MAAM,GAAGf,IAAI,CAACA,IAAI,CAACgB,MAAM,GAAG,CAAC,CAAC;EACpC,OAAO;IACL,GAAGJ,IAAI;IACPZ,IAAI;IACJE,IAAI,EAAE;MAAE,GAAGU,IAAI,CAACV,IAAI;MAAEC,IAAI,EAAES,IAAI,CAACV,IAAI,EAAEe,IAAI;MAAEA,IAAI,EAAEF,MAAM,IAAI;QAAEG,IAAI,EAAEH,MAAM,CAACI;MAAG;IAAE;EACnF,CAAC;AACH;AAEA,OAAO,SAASC,kBAAkBA,CAACpB,IAAgC,EAA8B;EAC/F,IAAI,CAACA,IAAI,EAAE,OAAOA,IAAI;EAEtB,MAAMqB,SAAS,GAAG,CAACrB,IAAI,CAACsB,UAAU,CAAC,CAAC,CAAC,EAAEzB,KAAK;EAC5C,IAAIwB,SAAS,IAAItB,gBAAgB,CAACC,IAAI,CAAC,EAAE,OAAOA,IAAI;EAEpD,OAAO;IAAE,GAAGA,IAAI;IAAEsB,UAAU,EAAE,CAAC5B,aAAa,EAAE,GAAGM,IAAI,CAACsB,UAAU,CAACC,KAAK,CAAC,CAAC,CAAC;EAAE,CAAC;AAC9E","ignoreList":[]}
@@ -1,9 +1,8 @@
1
1
  import { MessageResource } from '../../types';
2
- export declare function optimisticallyUpdateMessage({ conversationId, message, text, replyRootId, queryKey, }: {
2
+ export declare function optimisticallyUpdateMessage({ conversationId, message, text, replyRootId, }: {
3
3
  conversationId: number;
4
4
  message: MessageResource;
5
5
  text: string;
6
6
  replyRootId?: string | null;
7
- queryKey?: unknown[];
8
7
  }): MessageResource;
9
8
  //# sourceMappingURL=optimistically_update_message.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"optimistically_update_message.d.ts","sourceRoot":"","sources":["../../../src/utils/cache/optimistically_update_message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,eAAe,EAAE,MAAM,aAAa,CAAA;AAI5D,wBAAgB,2BAA2B,CAAC,EAC1C,cAAc,EACd,OAAO,EACP,IAAI,EACJ,WAAW,EACX,QAA+F,GAChG,EAAE;IACD,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,eAAe,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;CACrB,mBAqBA"}
1
+ {"version":3,"file":"optimistically_update_message.d.ts","sourceRoot":"","sources":["../../../src/utils/cache/optimistically_update_message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,eAAe,EAAE,MAAM,aAAa,CAAA;AAI5D,wBAAgB,2BAA2B,CAAC,EAC1C,cAAc,EACd,OAAO,EACP,IAAI,EACJ,WAAW,GACZ,EAAE;IACD,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,eAAe,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B,mBA0BA"}
@@ -5,12 +5,12 @@ export function optimisticallyUpdateMessage({
5
5
  conversationId,
6
6
  message,
7
7
  text,
8
- replyRootId,
9
- queryKey = getMessagesQueryKey({
8
+ replyRootId
9
+ }) {
10
+ const queryKey = getMessagesQueryKey({
10
11
  conversation_id: conversationId,
11
12
  reply_root_id: replyRootId
12
- })
13
- }) {
13
+ });
14
14
  let optimisticMessage = message;
15
15
  chatQueryClient.setQueryData(queryKey, data => updateOrCreateRecordInPagesData({
16
16
  data,
@@ -1 +1 @@
1
- {"version":3,"file":"optimistically_update_message.js","names":["chatQueryClient","getMessagesQueryKey","updateOrCreateRecordInPagesData","optimisticallyUpdateMessage","conversationId","message","text","replyRootId","queryKey","conversation_id","reply_root_id","optimisticMessage","setQueryData","data","record","processRecord","next","prev","pending"],"sources":["../../../src/utils/cache/optimistically_update_message.ts"],"sourcesContent":["import { InfiniteData } from '@tanstack/react-query'\nimport { chatQueryClient } from '../../contexts/api_provider'\nimport { ApiCollection, MessageResource } from '../../types'\nimport { getMessagesQueryKey } from '../../utils/request/get_messages'\nimport { updateOrCreateRecordInPagesData } from './page_mutations'\n\nexport function optimisticallyUpdateMessage({\n conversationId,\n message,\n text,\n replyRootId,\n queryKey = getMessagesQueryKey({ conversation_id: conversationId, reply_root_id: replyRootId }),\n}: {\n conversationId: number\n message: MessageResource\n text: string\n replyRootId?: string | null\n queryKey?: unknown[]\n}) {\n type QueryData = InfiniteData<ApiCollection<MessageResource>>\n\n let optimisticMessage = message\n\n chatQueryClient.setQueryData<QueryData>(queryKey, data =>\n updateOrCreateRecordInPagesData({\n data,\n record: message,\n processRecord: (next, prev) => {\n optimisticMessage = {\n ...(prev || next),\n text,\n pending: true,\n }\n return optimisticMessage\n },\n })\n )\n\n return optimisticMessage\n}\n"],"mappings":"AACA,SAASA,eAAe,QAAQ,6BAA6B;AAE7D,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,SAASC,+BAA+B,QAAQ,kBAAkB;AAElE,OAAO,SAASC,2BAA2BA,CAAC;EAC1CC,cAAc;EACdC,OAAO;EACPC,IAAI;EACJC,WAAW;EACXC,QAAQ,GAAGP,mBAAmB,CAAC;IAAEQ,eAAe,EAAEL,cAAc;IAAEM,aAAa,EAAEH;EAAY,CAAC;AAOhG,CAAC,EAAE;EAGD,IAAII,iBAAiB,GAAGN,OAAO;EAE/BL,eAAe,CAACY,YAAY,CAAYJ,QAAQ,EAAEK,IAAI,IACpDX,+BAA+B,CAAC;IAC9BW,IAAI;IACJC,MAAM,EAAET,OAAO;IACfU,aAAa,EAAEA,CAACC,IAAI,EAAEC,IAAI,KAAK;MAC7BN,iBAAiB,GAAG;QAClB,IAAIM,IAAI,IAAID,IAAI,CAAC;QACjBV,IAAI;QACJY,OAAO,EAAE;MACX,CAAC;MACD,OAAOP,iBAAiB;IAC1B;EACF,CAAC,CACH,CAAC;EAED,OAAOA,iBAAiB;AAC1B","ignoreList":[]}
1
+ {"version":3,"file":"optimistically_update_message.js","names":["chatQueryClient","getMessagesQueryKey","updateOrCreateRecordInPagesData","optimisticallyUpdateMessage","conversationId","message","text","replyRootId","queryKey","conversation_id","reply_root_id","optimisticMessage","setQueryData","data","record","processRecord","next","prev","pending"],"sources":["../../../src/utils/cache/optimistically_update_message.ts"],"sourcesContent":["import { InfiniteData } from '@tanstack/react-query'\nimport { chatQueryClient } from '../../contexts/api_provider'\nimport { ApiCollection, MessageResource } from '../../types'\nimport { getMessagesQueryKey } from '../../utils/request/get_messages'\nimport { updateOrCreateRecordInPagesData } from './page_mutations'\n\nexport function optimisticallyUpdateMessage({\n conversationId,\n message,\n text,\n replyRootId,\n}: {\n conversationId: number\n message: MessageResource\n text: string\n replyRootId?: string | null\n}) {\n type QueryData = InfiniteData<ApiCollection<MessageResource>>\n\n const queryKey = getMessagesQueryKey({\n conversation_id: conversationId,\n reply_root_id: replyRootId,\n })\n\n let optimisticMessage = message\n\n chatQueryClient.setQueryData<QueryData>(queryKey, data =>\n updateOrCreateRecordInPagesData({\n data,\n record: message,\n processRecord: (next, prev) => {\n optimisticMessage = {\n ...(prev || next),\n text,\n pending: true,\n }\n return optimisticMessage\n },\n })\n )\n\n return optimisticMessage\n}\n"],"mappings":"AACA,SAASA,eAAe,QAAQ,6BAA6B;AAE7D,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,SAASC,+BAA+B,QAAQ,kBAAkB;AAElE,OAAO,SAASC,2BAA2BA,CAAC;EAC1CC,cAAc;EACdC,OAAO;EACPC,IAAI;EACJC;AAMF,CAAC,EAAE;EAGD,MAAMC,QAAQ,GAAGP,mBAAmB,CAAC;IACnCQ,eAAe,EAAEL,cAAc;IAC/BM,aAAa,EAAEH;EACjB,CAAC,CAAC;EAEF,IAAII,iBAAiB,GAAGN,OAAO;EAE/BL,eAAe,CAACY,YAAY,CAAYJ,QAAQ,EAAEK,IAAI,IACpDX,+BAA+B,CAAC;IAC9BW,IAAI;IACJC,MAAM,EAAET,OAAO;IACfU,aAAa,EAAEA,CAACC,IAAI,EAAEC,IAAI,KAAK;MAC7BN,iBAAiB,GAAG;QAClB,IAAIM,IAAI,IAAID,IAAI,CAAC;QACjBV,IAAI;QACJY,OAAO,EAAE;MACX,CAAC;MACD,OAAOP,iBAAiB;IAC1B;EACF,CAAC,CACH,CAAC;EAED,OAAOA,iBAAiB;AAC1B","ignoreList":[]}
@@ -1,3 +1,9 @@
1
+ /**
2
+ * The actual `ulid` library depends on a secure random number generator, which looks like it
3
+ * may require a native dependency to polyfill in React Native.
4
+ * Since this is only used as a local temporary ID, I think we can get away with a simpler
5
+ * implementation that doesn't require any native dependencies.
6
+ */
1
7
  export declare function generatePlaceholderUlid({ offsetMs }?: {
2
8
  offsetMs?: number;
3
9
  }): string;
@@ -1 +1 @@
1
- {"version":3,"file":"generate_placeholder_ulid.d.ts","sourceRoot":"","sources":["../../src/utils/generate_placeholder_ulid.ts"],"names":[],"mappings":"AAkBA,wBAAgB,uBAAuB,CAAC,EAAE,QAAY,EAAE,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAa5F"}
1
+ {"version":3,"file":"generate_placeholder_ulid.d.ts","sourceRoot":"","sources":["../../src/utils/generate_placeholder_ulid.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,wBAAgB,uBAAuB,CAAC,EAAE,QAAY,EAAE,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAa5F"}
@@ -1,5 +1,3 @@
1
- import { ULID_CHARS } from './ulid';
2
-
3
1
  /**
4
2
  * The actual `ulid` library depends on a secure random number generator, which looks like it
5
3
  * may require a native dependency to polyfill in React Native.
@@ -7,6 +5,8 @@ import { ULID_CHARS } from './ulid';
7
5
  * implementation that doesn't require any native dependencies.
8
6
  */
9
7
 
8
+ const ULID_CHARS = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'; // Crockford's Base32
9
+
10
10
  function encodeBase32(value, length) {
11
11
  let result = '';
12
12
  for (let i = 0; i < length; i++) {
@@ -1 +1 @@
1
- {"version":3,"file":"generate_placeholder_ulid.js","names":["ULID_CHARS","encodeBase32","value","length","result","i","Math","floor","generatePlaceholderUlid","offsetMs","timestamp","Date","now","timeComponent","randomComponent","random"],"sources":["../../src/utils/generate_placeholder_ulid.ts"],"sourcesContent":["import { ULID_CHARS } from './ulid'\n\n/**\n * The actual `ulid` library depends on a secure random number generator, which looks like it\n * may require a native dependency to polyfill in React Native.\n * Since this is only used as a local temporary ID, I think we can get away with a simpler\n * implementation that doesn't require any native dependencies.\n */\n\nfunction encodeBase32(value: number, length: number) {\n let result = ''\n for (let i = 0; i < length; i++) {\n result = ULID_CHARS[value % 32] + result\n value = Math.floor(value / 32)\n }\n return result\n}\n\nexport function generatePlaceholderUlid({ offsetMs = 0 }: { offsetMs?: number } = {}): string {\n const timestamp = Date.now() + offsetMs // Milliseconds since epoch\n // 48 bits for timestamp (6 Base32 characters)\n const timeComponent = encodeBase32(timestamp, 10) // 48 bits = 6 bytes = 10 Base32 characters (approx, needs more precise bit shifting)\n\n // 80 bits for randomness (16 Base32 characters)\n let randomComponent = ''\n for (let i = 0; i < 16; i++) {\n // Generate 16 random Base32 chars\n randomComponent += ULID_CHARS[Math.floor(Math.random() * 32)]\n }\n\n return timeComponent + randomComponent\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,QAAQ;;AAEnC;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASC,YAAYA,CAACC,KAAa,EAAEC,MAAc,EAAE;EACnD,IAAIC,MAAM,GAAG,EAAE;EACf,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,MAAM,EAAEE,CAAC,EAAE,EAAE;IAC/BD,MAAM,GAAGJ,UAAU,CAACE,KAAK,GAAG,EAAE,CAAC,GAAGE,MAAM;IACxCF,KAAK,GAAGI,IAAI,CAACC,KAAK,CAACL,KAAK,GAAG,EAAE,CAAC;EAChC;EACA,OAAOE,MAAM;AACf;AAEA,OAAO,SAASI,uBAAuBA,CAAC;EAAEC,QAAQ,GAAG;AAAyB,CAAC,GAAG,CAAC,CAAC,EAAU;EAC5F,MAAMC,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAGH,QAAQ,EAAC;EACxC;EACA,MAAMI,aAAa,GAAGZ,YAAY,CAACS,SAAS,EAAE,EAAE,CAAC,EAAC;;EAElD;EACA,IAAII,eAAe,GAAG,EAAE;EACxB,KAAK,IAAIT,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,EAAE,EAAEA,CAAC,EAAE,EAAE;IAC3B;IACAS,eAAe,IAAId,UAAU,CAACM,IAAI,CAACC,KAAK,CAACD,IAAI,CAACS,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;EAC/D;EAEA,OAAOF,aAAa,GAAGC,eAAe;AACxC","ignoreList":[]}
1
+ {"version":3,"file":"generate_placeholder_ulid.js","names":["ULID_CHARS","encodeBase32","value","length","result","i","Math","floor","generatePlaceholderUlid","offsetMs","timestamp","Date","now","timeComponent","randomComponent","random"],"sources":["../../src/utils/generate_placeholder_ulid.ts"],"sourcesContent":["/**\n * The actual `ulid` library depends on a secure random number generator, which looks like it\n * may require a native dependency to polyfill in React Native.\n * Since this is only used as a local temporary ID, I think we can get away with a simpler\n * implementation that doesn't require any native dependencies.\n */\n\nconst ULID_CHARS = '0123456789ABCDEFGHJKMNPQRSTVWXYZ' // Crockford's Base32\n\nfunction encodeBase32(value: number, length: number) {\n let result = ''\n for (let i = 0; i < length; i++) {\n result = ULID_CHARS[value % 32] + result\n value = Math.floor(value / 32)\n }\n return result\n}\n\nexport function generatePlaceholderUlid({ offsetMs = 0 }: { offsetMs?: number } = {}): string {\n const timestamp = Date.now() + offsetMs // Milliseconds since epoch\n // 48 bits for timestamp (6 Base32 characters)\n const timeComponent = encodeBase32(timestamp, 10) // 48 bits = 6 bytes = 10 Base32 characters (approx, needs more precise bit shifting)\n\n // 80 bits for randomness (16 Base32 characters)\n let randomComponent = ''\n for (let i = 0; i < 16; i++) {\n // Generate 16 random Base32 chars\n randomComponent += ULID_CHARS[Math.floor(Math.random() * 32)]\n }\n\n return timeComponent + randomComponent\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,UAAU,GAAG,kCAAkC,EAAC;;AAEtD,SAASC,YAAYA,CAACC,KAAa,EAAEC,MAAc,EAAE;EACnD,IAAIC,MAAM,GAAG,EAAE;EACf,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,MAAM,EAAEE,CAAC,EAAE,EAAE;IAC/BD,MAAM,GAAGJ,UAAU,CAACE,KAAK,GAAG,EAAE,CAAC,GAAGE,MAAM;IACxCF,KAAK,GAAGI,IAAI,CAACC,KAAK,CAACL,KAAK,GAAG,EAAE,CAAC;EAChC;EACA,OAAOE,MAAM;AACf;AAEA,OAAO,SAASI,uBAAuBA,CAAC;EAAEC,QAAQ,GAAG;AAAyB,CAAC,GAAG,CAAC,CAAC,EAAU;EAC5F,MAAMC,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAGH,QAAQ,EAAC;EACxC;EACA,MAAMI,aAAa,GAAGZ,YAAY,CAACS,SAAS,EAAE,EAAE,CAAC,EAAC;;EAElD;EACA,IAAII,eAAe,GAAG,EAAE;EACxB,KAAK,IAAIT,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,EAAE,EAAEA,CAAC,EAAE,EAAE;IAC3B;IACAS,eAAe,IAAId,UAAU,CAACM,IAAI,CAACC,KAAK,CAACD,IAAI,CAACS,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;EAC/D;EAEA,OAAOF,aAAa,GAAGC,eAAe;AACxC","ignoreList":[]}
@@ -1,23 +1,9 @@
1
- type MessagesRequestOptions = {
1
+ export declare const getMessagesRequestArgs: ({ conversation_id, reply_root_id, }: {
2
2
  conversation_id: number;
3
3
  reply_root_id?: string | null;
4
- anchor?: string | null;
5
- };
6
- export declare const getMessagesRequestArgs: ({ conversation_id, reply_root_id, anchor, }: MessagesRequestOptions) => {
4
+ }) => {
7
5
  url: string;
8
6
  data: {
9
- where: {
10
- id_around: string;
11
- };
12
- perPage: number;
13
- fields: {
14
- Message: string[];
15
- Person: string[];
16
- ReactionCount: string[];
17
- };
18
- include: string[];
19
- } | {
20
- where?: undefined;
21
7
  perPage: number;
22
8
  fields: {
23
9
  Message: string[];
@@ -28,6 +14,8 @@ export declare const getMessagesRequestArgs: ({ conversation_id, reply_root_id,
28
14
  };
29
15
  reply_root_id: string | null;
30
16
  };
31
- export declare const getMessagesQueryKey: (options: MessagesRequestOptions) => import("../..").RequestQueryKey;
32
- export {};
17
+ export declare const getMessagesQueryKey: ({ conversation_id, reply_root_id, }: {
18
+ conversation_id: number;
19
+ reply_root_id?: string | null;
20
+ }) => import("../..").RequestQueryKey;
33
21
  //# sourceMappingURL=get_messages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get_messages.d.ts","sourceRoot":"","sources":["../../../src/utils/request/get_messages.ts"],"names":[],"mappings":"AAGA,KAAK,sBAAsB,GAAG;IAC5B,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,6CAIpC,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;CAiBxB,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,SAAS,sBAAsB,oCACd,CAAA"}
1
+ {"version":3,"file":"get_messages.d.ts","sourceRoot":"","sources":["../../../src/utils/request/get_messages.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,sBAAsB,GAAI,qCAGpC;IACD,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;;;;;;;;;;;;CAeA,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,qCAGjC;IACD,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B,oCAGA,CAAA"}
@@ -2,26 +2,28 @@ import { getRequestQueryKey } from '../../hooks/use_suspense_api';
2
2
  import { getMessageFields, getMessagesInclude } from './messages_data_options';
3
3
  export const getMessagesRequestArgs = ({
4
4
  conversation_id,
5
- reply_root_id,
6
- anchor
5
+ reply_root_id
7
6
  }) => {
8
7
  const normalizedReplyRootId = reply_root_id ?? null;
9
8
  const url = normalizedReplyRootId ? `/me/conversations/${conversation_id}/messages/${normalizedReplyRootId}/replies` : `/me/conversations/${conversation_id}/messages`;
10
- const anchored = anchor ? {
11
- where: {
12
- id_around: anchor
13
- }
14
- } : {};
15
9
  return {
16
10
  url,
17
11
  data: {
18
12
  perPage: 25,
19
13
  fields: getMessageFields,
20
- include: getMessagesInclude,
21
- ...anchored
14
+ include: getMessagesInclude
22
15
  },
23
16
  reply_root_id: normalizedReplyRootId
24
17
  };
25
18
  };
26
- export const getMessagesQueryKey = options => getRequestQueryKey(getMessagesRequestArgs(options));
19
+ export const getMessagesQueryKey = ({
20
+ conversation_id,
21
+ reply_root_id
22
+ }) => {
23
+ const requestArgs = getMessagesRequestArgs({
24
+ conversation_id,
25
+ reply_root_id
26
+ });
27
+ return getRequestQueryKey(requestArgs);
28
+ };
27
29
  //# sourceMappingURL=get_messages.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get_messages.js","names":["getRequestQueryKey","getMessageFields","getMessagesInclude","getMessagesRequestArgs","conversation_id","reply_root_id","anchor","normalizedReplyRootId","url","anchored","where","id_around","data","perPage","fields","include","getMessagesQueryKey","options"],"sources":["../../../src/utils/request/get_messages.ts"],"sourcesContent":["import { getRequestQueryKey } from '../../hooks/use_suspense_api'\nimport { getMessageFields, getMessagesInclude } from './messages_data_options'\n\ntype MessagesRequestOptions = {\n conversation_id: number\n reply_root_id?: string | null\n anchor?: string | null\n}\n\nexport const getMessagesRequestArgs = ({\n conversation_id,\n reply_root_id,\n anchor,\n}: MessagesRequestOptions) => {\n const normalizedReplyRootId = reply_root_id ?? null\n const url = normalizedReplyRootId\n ? `/me/conversations/${conversation_id}/messages/${normalizedReplyRootId}/replies`\n : `/me/conversations/${conversation_id}/messages`\n const anchored = anchor ? { where: { id_around: anchor } } : {}\n\n return {\n url,\n data: {\n perPage: 25,\n fields: getMessageFields,\n include: getMessagesInclude,\n ...anchored,\n },\n reply_root_id: normalizedReplyRootId,\n }\n}\n\nexport const getMessagesQueryKey = (options: MessagesRequestOptions) =>\n getRequestQueryKey(getMessagesRequestArgs(options))\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,yBAAyB;AAQ9E,OAAO,MAAMC,sBAAsB,GAAGA,CAAC;EACrCC,eAAe;EACfC,aAAa;EACbC;AACsB,CAAC,KAAK;EAC5B,MAAMC,qBAAqB,GAAGF,aAAa,IAAI,IAAI;EACnD,MAAMG,GAAG,GAAGD,qBAAqB,GAC7B,qBAAqBH,eAAe,aAAaG,qBAAqB,UAAU,GAChF,qBAAqBH,eAAe,WAAW;EACnD,MAAMK,QAAQ,GAAGH,MAAM,GAAG;IAAEI,KAAK,EAAE;MAAEC,SAAS,EAAEL;IAAO;EAAE,CAAC,GAAG,CAAC,CAAC;EAE/D,OAAO;IACLE,GAAG;IACHI,IAAI,EAAE;MACJC,OAAO,EAAE,EAAE;MACXC,MAAM,EAAEb,gBAAgB;MACxBc,OAAO,EAAEb,kBAAkB;MAC3B,GAAGO;IACL,CAAC;IACDJ,aAAa,EAAEE;EACjB,CAAC;AACH,CAAC;AAED,OAAO,MAAMS,mBAAmB,GAAIC,OAA+B,IACjEjB,kBAAkB,CAACG,sBAAsB,CAACc,OAAO,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"get_messages.js","names":["getRequestQueryKey","getMessageFields","getMessagesInclude","getMessagesRequestArgs","conversation_id","reply_root_id","normalizedReplyRootId","url","data","perPage","fields","include","getMessagesQueryKey","requestArgs"],"sources":["../../../src/utils/request/get_messages.ts"],"sourcesContent":["import { getRequestQueryKey } from '../../hooks/use_suspense_api'\nimport { getMessageFields, getMessagesInclude } from './messages_data_options'\n\nexport const getMessagesRequestArgs = ({\n conversation_id,\n reply_root_id,\n}: {\n conversation_id: number\n reply_root_id?: string | null\n}) => {\n const normalizedReplyRootId = reply_root_id ?? null\n const url = normalizedReplyRootId\n ? `/me/conversations/${conversation_id}/messages/${normalizedReplyRootId}/replies`\n : `/me/conversations/${conversation_id}/messages`\n\n return {\n url,\n data: {\n perPage: 25,\n fields: getMessageFields,\n include: getMessagesInclude,\n },\n reply_root_id: normalizedReplyRootId,\n }\n}\n\nexport const getMessagesQueryKey = ({\n conversation_id,\n reply_root_id,\n}: {\n conversation_id: number\n reply_root_id?: string | null\n}) => {\n const requestArgs = getMessagesRequestArgs({ conversation_id, reply_root_id })\n return getRequestQueryKey(requestArgs)\n}\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,yBAAyB;AAE9E,OAAO,MAAMC,sBAAsB,GAAGA,CAAC;EACrCC,eAAe;EACfC;AAIF,CAAC,KAAK;EACJ,MAAMC,qBAAqB,GAAGD,aAAa,IAAI,IAAI;EACnD,MAAME,GAAG,GAAGD,qBAAqB,GAC7B,qBAAqBF,eAAe,aAAaE,qBAAqB,UAAU,GAChF,qBAAqBF,eAAe,WAAW;EAEnD,OAAO;IACLG,GAAG;IACHC,IAAI,EAAE;MACJC,OAAO,EAAE,EAAE;MACXC,MAAM,EAAET,gBAAgB;MACxBU,OAAO,EAAET;IACX,CAAC;IACDG,aAAa,EAAEC;EACjB,CAAC;AACH,CAAC;AAED,OAAO,MAAMM,mBAAmB,GAAGA,CAAC;EAClCR,eAAe;EACfC;AAIF,CAAC,KAAK;EACJ,MAAMQ,WAAW,GAAGV,sBAAsB,CAAC;IAAEC,eAAe;IAAEC;EAAc,CAAC,CAAC;EAC9E,OAAOL,kBAAkB,CAACa,WAAW,CAAC;AACxC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "4.2.1-qa-staging.7",
3
+ "version": "4.2.1-qa-staging.8",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@fortawesome/fontawesome-svg-core": "^7.2.0",
35
35
  "@fortawesome/react-native-fontawesome": "^0.3.2",
36
- "@planningcenter/emoji-keyboard": "4.2.1-qa-staging.7",
36
+ "@planningcenter/emoji-keyboard": "4.2.1-qa-staging.8",
37
37
  "lodash-inflection": "^1.5.0"
38
38
  },
39
39
  "peerDependencies": {
@@ -84,5 +84,5 @@
84
84
  "sf-symbols-typescript": "^2.2.0",
85
85
  "typescript": "~6.0.3"
86
86
  },
87
- "gitHead": "ac14fbc71010cf1dcf5345f9e66f35bb79858660"
87
+ "gitHead": "79a6fab28e0ddadba0af22642a2d97eb9609f1cc"
88
88
  }
@@ -1,13 +1,7 @@
1
- import {
2
- getNewerPageParam,
3
- getNextPageParamFromMeta,
4
- mergePageWhere,
5
- } from '../../hooks/paginator_meta'
6
- import { NextPageCursor } from '../../types/api_primitives'
7
- import { RequestData } from '../../utils/client'
1
+ import { getNextPageParamFromMeta } from '../../hooks/paginator_meta'
8
2
 
9
3
  describe('getNextPageParamFromMeta', () => {
10
- it.each<[NextPageCursor | undefined, Partial<RequestData> | undefined]>([
4
+ it.each([
11
5
  [undefined, undefined],
12
6
  [{}, undefined],
13
7
  [{ idLt: '01ABC' }, { where: { id_lt: '01ABC' } }],
@@ -15,72 +9,7 @@ describe('getNextPageParamFromMeta', () => {
15
9
  [{ idGt: '01ABC' }, { where: { id_gt: '01ABC' } }],
16
10
  [{ idGte: '01ABC' }, { where: { id_gte: '01ABC' } }],
17
11
  [{ offset: '40' }, { offset: 40 }],
18
- [
19
- { idLt: '01ABC', order: 'desc' },
20
- { where: { id_lt: '01ABC' }, order: 'desc' },
21
- ],
22
- [
23
- { idGt: '01ABC', order: 'asc' },
24
- { where: { id_gt: '01ABC' }, order: 'asc' },
25
- ],
26
12
  ])('maps %p to %p', (input, expected) => {
27
13
  expect(getNextPageParamFromMeta(input)).toEqual(expected)
28
14
  })
29
15
  })
30
-
31
- describe('getNewerPageParam', () => {
32
- const page = (meta: { next?: NextPageCursor; prev?: NextPageCursor }) => ({
33
- data: [],
34
- links: {},
35
- meta: { count: 0, totalCount: 0, ...meta },
36
- })
37
-
38
- it('follows meta.prev on the anchored page', () => {
39
- const anchored = page({
40
- next: { idLt: '01A', order: 'desc' },
41
- prev: { idGt: '01E', order: 'asc' },
42
- })
43
-
44
- expect(getNewerPageParam(anchored, {})).toEqual({ where: { id_gt: '01E' }, order: 'asc' })
45
- })
46
-
47
- it('stops when the anchored page has no newer side', () => {
48
- expect(getNewerPageParam(page({ next: { idLt: '01A', order: 'desc' } }), {})).toBeUndefined()
49
- })
50
-
51
- it('follows meta.next on an ascending page', () => {
52
- const newer = page({ next: { idGt: '01H', order: 'asc' } })
53
-
54
- expect(getNewerPageParam(newer, { order: 'asc' })).toEqual({
55
- where: { id_gt: '01H' },
56
- order: 'asc',
57
- })
58
- })
59
-
60
- it('stops once an ascending page has no meta.next', () => {
61
- expect(getNewerPageParam(page({}), { order: 'asc' })).toBeUndefined()
62
- })
63
- })
64
-
65
- describe('mergePageWhere', () => {
66
- it('lets a page cursor replace the request bound instead of stacking bounds', () => {
67
- expect(mergePageWhere({ id_around: '01ANCHOR' }, { id_gt: '01NEWER' })).toEqual({
68
- id_gt: '01NEWER',
69
- })
70
- expect(mergePageWhere({ id_around: '01ANCHOR' }, { id_lt: '01OLDER' })).toEqual({
71
- id_lt: '01OLDER',
72
- })
73
- })
74
-
75
- it('keeps non-cursor filters alongside the cursor', () => {
76
- expect(mergePageWhere({ source_type: 'Group' }, { id_lt: '01OLDER' })).toEqual({
77
- source_type: 'Group',
78
- id_lt: '01OLDER',
79
- })
80
- })
81
-
82
- it('leaves the request where alone when the page has no cursor', () => {
83
- expect(mergePageWhere({ id_around: '01ANCHOR' }, {})).toEqual({ id_around: '01ANCHOR' })
84
- expect(mergePageWhere(undefined, undefined)).toEqual({})
85
- })
86
- })
@@ -104,7 +104,6 @@ let queryClient: QueryClient
104
104
 
105
105
  // A top-level rerender would rebuild the wrapper context and redraw every row.
106
106
  let setHarnessConversation: (next: ConversationResource) => void = () => {}
107
- let harnessAnchorMessageId: string | null = null
108
107
 
109
108
  function Harness() {
110
109
  const [current, setCurrent] = React.useState(conversation)
@@ -118,7 +117,6 @@ function Harness() {
118
117
  conversation={current}
119
118
  conversationId={CONVERSATION_ID}
120
119
  messages={loaded}
121
- anchorMessageId={harnessAnchorMessageId}
122
120
  hasNextPage
123
121
  onEndReached={() => {}}
124
122
  />
@@ -178,49 +176,9 @@ beforeEach(() => {
178
176
  afterEach(() => {
179
177
  queryClient.clear()
180
178
  jest.clearAllMocks()
181
- harnessAnchorMessageId = null
182
179
  })
183
180
 
184
181
  describe('MessageList', () => {
185
- it('pins the anchor row to the bottom edge as content lays out, until the user drags', () => {
186
- const scrollToIndex = jest.spyOn(FlatList.prototype, 'scrollToIndex').mockImplementation()
187
- harnessAnchorMessageId = messages[3].id
188
- renderList()
189
- const list = screen.UNSAFE_getByType(FlatList)
190
- const anchorIndex = list.props.data.findIndex(
191
- (item: { id: string }) => item.id === messages[3].id
192
- )
193
-
194
- act(() => list.props.onLayout({ nativeEvent: { layout: { height: 600 } } }))
195
- act(() => list.props.onContentSizeChange(0, 400))
196
- expect(scrollToIndex).not.toHaveBeenCalled()
197
-
198
- act(() => list.props.onContentSizeChange(0, 1000))
199
- act(() => list.props.onContentSizeChange(0, 2000))
200
- expect(anchorIndex).toBeGreaterThan(0)
201
- expect(scrollToIndex).toHaveBeenCalledTimes(2)
202
- expect(scrollToIndex).toHaveBeenLastCalledWith({
203
- index: anchorIndex,
204
- viewPosition: 0,
205
- animated: false,
206
- })
207
-
208
- act(() => list.props.onScrollBeginDrag({ nativeEvent: {} }))
209
- act(() => list.props.onContentSizeChange(0, 3000))
210
- expect(scrollToIndex).toHaveBeenCalledTimes(2)
211
- })
212
-
213
- it('leaves the offset alone when there is no anchor', () => {
214
- const scrollToIndex = jest.spyOn(FlatList.prototype, 'scrollToIndex').mockImplementation()
215
- renderList()
216
- const list = screen.UNSAFE_getByType(FlatList)
217
-
218
- act(() => list.props.onLayout({ nativeEvent: { layout: { height: 600 } } }))
219
- act(() => list.props.onContentSizeChange(0, 1000))
220
-
221
- expect(scrollToIndex).not.toHaveBeenCalled()
222
- })
223
-
224
182
  it('redraws only the reacted row when a reaction arrives', () => {
225
183
  renderList()
226
184
  const target = messages[3]
@@ -1,5 +1,5 @@
1
1
  import { useNavigation, useTheme as useNavigationTheme, useRoute } from '@react-navigation/native'
2
- import React, { useCallback, useContext, useEffect, useState } from 'react'
2
+ import React, { useCallback, useContext, useEffect, useRef, useState } from 'react'
3
3
  import {
4
4
  Linking,
5
5
  Platform,
@@ -34,6 +34,7 @@ import {
34
34
  FileAttachment,
35
35
  } from '../../types/resources/denormalized_attachment_resource_for_create'
36
36
  import {
37
+ Log,
37
38
  MAX_FONT_SIZE_MULTIPLIER_LANDMARK,
38
39
  platformFontWeightMedium,
39
40
  platformPressedOpacityStyle,
@@ -71,7 +72,7 @@ interface MessagesFormRootProps extends ViewProps {
71
72
  replyRootId?: string | null
72
73
  replyRootAuthorFirstName?: string | null
73
74
  onFlaggedInMessageForm?: (id: string) => void
74
- onBeforeSubmit?: () => void
75
+ onBeforeSubmit?: () => void | Promise<void>
75
76
  }
76
77
 
77
78
  const MessageFormContext = React.createContext<{
@@ -226,10 +227,31 @@ function MessageFormRoot({
226
227
  }
227
228
  }, [conversation.id, navigation, text])
228
229
 
229
- const handleSubmit = () => {
230
+ const catchingUp = useRef(false)
231
+
232
+ // A send from a window behind the live edge would leave a gap above it, so a failed
233
+ // catch-up stops the send and keeps what was typed.
234
+ const catchUpBeforeSend = async () => {
235
+ if (catchingUp.current) return false
236
+
237
+ catchingUp.current = true
238
+ try {
239
+ await onBeforeSubmit?.()
240
+ return true
241
+ } catch (error) {
242
+ Log.error('send stopped: live window fetch failed', error)
243
+ return false
244
+ } finally {
245
+ catchingUp.current = false
246
+ }
247
+ }
248
+
249
+ const handleSubmit = async () => {
230
250
  if (!canSubmit) return
231
251
 
232
252
  if (canGiphy && usingGiphy) {
253
+ if (!(await catchUpBeforeSend())) return
254
+
233
255
  TextInput.State.blurTextInput(TextInput.State.currentlyFocusedInput())
234
256
  Haptic.impactLight()
235
257
  navigateToSendGiphyAfterKeyboardHides()
@@ -250,9 +272,12 @@ function MessageFormRoot({
250
272
  mutateAsync({ text: messageText })
251
273
  reset()
252
274
  } else {
253
- onBeforeSubmit?.()
254
- mutateAsync({ text: messageText, attachments: attachmentsForSubmit })
275
+ // The live-window fetch replaces the cache, which would wipe an optimistic row
276
+ // added earlier.
277
+ if (!(await catchUpBeforeSend())) return
278
+
255
279
  reset()
280
+ mutateAsync({ text: messageText, attachments: attachmentsForSubmit })
256
281
  }
257
282
  }
258
283
  }