@planningcenter/chat-react-native 3.11.0-rc.9 → 3.11.0

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 (199) hide show
  1. package/build/components/conversation/attachments/image_attachment.d.ts.map +1 -1
  2. package/build/components/conversation/attachments/image_attachment.js +9 -2
  3. package/build/components/conversation/attachments/image_attachment.js.map +1 -1
  4. package/build/components/conversation/message.d.ts +1 -1
  5. package/build/components/conversation/message.d.ts.map +1 -1
  6. package/build/components/conversation/message.js +85 -26
  7. package/build/components/conversation/message.js.map +1 -1
  8. package/build/components/conversation/message_form/message_form_attachment_image.d.ts +1 -1
  9. package/build/components/conversation/message_form/message_form_attachment_image.d.ts.map +1 -1
  10. package/build/components/conversation/message_form/message_form_attachment_image.js.map +1 -1
  11. package/build/components/conversation/message_form/message_form_attachment_video.d.ts +1 -1
  12. package/build/components/conversation/message_form/message_form_attachment_video.d.ts.map +1 -1
  13. package/build/components/conversation/message_form/message_form_attachment_video.js.map +1 -1
  14. package/build/components/conversation/message_form.d.ts.map +1 -1
  15. package/build/components/conversation/message_form.js +12 -10
  16. package/build/components/conversation/message_form.js.map +1 -1
  17. package/build/components/conversations/conversations.d.ts.map +1 -1
  18. package/build/components/conversations/conversations.js +5 -1
  19. package/build/components/conversations/conversations.js.map +1 -1
  20. package/build/components/display/spinner.d.ts +6 -1
  21. package/build/components/display/spinner.d.ts.map +1 -1
  22. package/build/components/display/spinner.js +2 -2
  23. package/build/components/display/spinner.js.map +1 -1
  24. package/build/components/display/text.js +10 -2
  25. package/build/components/display/text.js.map +1 -1
  26. package/build/components/primitive/form_sheet.d.ts +1 -0
  27. package/build/components/primitive/form_sheet.d.ts.map +1 -1
  28. package/build/components/primitive/form_sheet.js +2 -2
  29. package/build/components/primitive/form_sheet.js.map +1 -1
  30. package/build/contexts/api_provider.d.ts +1 -0
  31. package/build/contexts/api_provider.d.ts.map +1 -1
  32. package/build/contexts/api_provider.js +24 -2
  33. package/build/contexts/api_provider.js.map +1 -1
  34. package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +1 -1
  35. package/build/hooks/groups/use_groups_conversation_create.d.ts.map +1 -1
  36. package/build/hooks/groups/use_groups_conversation_create.js +3 -1
  37. package/build/hooks/groups/use_groups_conversation_create.js.map +1 -1
  38. package/build/hooks/services/use_find_or_create_services_conversation.d.ts +2 -0
  39. package/build/hooks/services/use_find_or_create_services_conversation.d.ts.map +1 -1
  40. package/build/hooks/services/use_find_or_create_services_conversation.js +22 -19
  41. package/build/hooks/services/use_find_or_create_services_conversation.js.map +1 -1
  42. package/build/hooks/{use_services_team.d.ts → services/use_services_team.d.ts} +1 -1
  43. package/build/hooks/services/use_services_team.d.ts.map +1 -0
  44. package/build/hooks/{use_services_team.js → services/use_services_team.js} +1 -1
  45. package/build/hooks/services/use_services_team.js.map +1 -0
  46. package/build/hooks/use_attachment_uploader.d.ts +5 -13
  47. package/build/hooks/use_attachment_uploader.d.ts.map +1 -1
  48. package/build/hooks/use_attachment_uploader.js.map +1 -1
  49. package/build/hooks/use_chat_permissions.d.ts +10 -0
  50. package/build/hooks/use_chat_permissions.d.ts.map +1 -1
  51. package/build/hooks/use_chat_permissions.js +10 -9
  52. package/build/hooks/use_chat_permissions.js.map +1 -1
  53. package/build/hooks/use_conversation.d.ts +1 -1
  54. package/build/hooks/use_conversation_messages_jolt_events.d.ts.map +1 -1
  55. package/build/hooks/use_conversation_messages_jolt_events.js +16 -1
  56. package/build/hooks/use_conversation_messages_jolt_events.js.map +1 -1
  57. package/build/hooks/use_giphy.d.ts +1 -1
  58. package/build/hooks/use_giphy.d.ts.map +1 -1
  59. package/build/hooks/use_giphy.js.map +1 -1
  60. package/build/hooks/use_message_create_or_update.d.ts +8 -4
  61. package/build/hooks/use_message_create_or_update.d.ts.map +1 -1
  62. package/build/hooks/use_message_create_or_update.js +58 -4
  63. package/build/hooks/use_message_create_or_update.js.map +1 -1
  64. package/build/hooks/use_read_receipts.d.ts +1 -1
  65. package/build/hooks/use_suspense_api.d.ts +2 -2
  66. package/build/index.d.ts +1 -1
  67. package/build/index.d.ts.map +1 -1
  68. package/build/index.js +1 -1
  69. package/build/index.js.map +1 -1
  70. package/build/navigation/index.d.ts +11 -0
  71. package/build/navigation/index.d.ts.map +1 -1
  72. package/build/navigation/index.js +10 -0
  73. package/build/navigation/index.js.map +1 -1
  74. package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.d.ts.map +1 -1
  75. package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.js +81 -17
  76. package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.js.map +1 -1
  77. package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.d.ts +171 -4
  78. package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.d.ts.map +1 -1
  79. package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.js +49 -8
  80. package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.js.map +1 -1
  81. package/build/screens/conversation_filter_recipients/types.d.ts +7 -0
  82. package/build/screens/conversation_filter_recipients/types.d.ts.map +1 -1
  83. package/build/screens/conversation_filter_recipients/types.js +6 -0
  84. package/build/screens/conversation_filter_recipients/types.js.map +1 -1
  85. package/build/screens/conversation_filters/components/rows.js +1 -1
  86. package/build/screens/conversation_filters/components/rows.js.map +1 -1
  87. package/build/screens/conversation_new/components/groups_form.js +2 -2
  88. package/build/screens/conversation_new/components/groups_form.js.map +1 -1
  89. package/build/screens/conversation_new/components/services_form.d.ts +3 -1
  90. package/build/screens/conversation_new/components/services_form.d.ts.map +1 -1
  91. package/build/screens/conversation_new/components/services_form.js +6 -5
  92. package/build/screens/conversation_new/components/services_form.js.map +1 -1
  93. package/build/screens/conversation_new/conversation_new_screen.d.ts +2 -0
  94. package/build/screens/conversation_new/conversation_new_screen.d.ts.map +1 -1
  95. package/build/screens/conversation_new/conversation_new_screen.js +2 -2
  96. package/build/screens/conversation_new/conversation_new_screen.js.map +1 -1
  97. package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.d.ts.map +1 -1
  98. package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.js +38 -33
  99. package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.js.map +1 -1
  100. package/build/screens/team_conversation_screen.d.ts +8 -0
  101. package/build/screens/team_conversation_screen.d.ts.map +1 -0
  102. package/build/screens/team_conversation_screen.js +28 -0
  103. package/build/screens/team_conversation_screen.js.map +1 -0
  104. package/build/types/resources/denormalized_attachment_resource.d.ts +9 -32
  105. package/build/types/resources/denormalized_attachment_resource.d.ts.map +1 -1
  106. package/build/types/resources/denormalized_attachment_resource.js.map +1 -1
  107. package/build/types/resources/denormalized_attachment_resource_for_create.d.ts +50 -0
  108. package/build/types/resources/denormalized_attachment_resource_for_create.d.ts.map +1 -0
  109. package/build/types/resources/denormalized_attachment_resource_for_create.js +2 -0
  110. package/build/types/resources/denormalized_attachment_resource_for_create.js.map +1 -0
  111. package/build/types/resources/message.d.ts +4 -0
  112. package/build/types/resources/message.d.ts.map +1 -1
  113. package/build/types/resources/message.js.map +1 -1
  114. package/build/types/resources/services/chat_resource.d.ts +52 -0
  115. package/build/types/resources/services/chat_resource.d.ts.map +1 -0
  116. package/build/types/resources/services/chat_resource.js +7 -0
  117. package/build/types/resources/services/chat_resource.js.map +1 -0
  118. package/build/types/resources/services/index.d.ts +1 -0
  119. package/build/types/resources/services/index.d.ts.map +1 -1
  120. package/build/types/resources/services/index.js +1 -0
  121. package/build/types/resources/services/index.js.map +1 -1
  122. package/build/types/resources/services/team_resource.d.ts +9 -41
  123. package/build/types/resources/services/team_resource.d.ts.map +1 -1
  124. package/build/types/resources/services/team_resource.js +0 -5
  125. package/build/types/resources/services/team_resource.js.map +1 -1
  126. package/build/utils/cache/optimistically_create_message.d.ts +10 -0
  127. package/build/utils/cache/optimistically_create_message.d.ts.map +1 -0
  128. package/build/utils/cache/optimistically_create_message.js +43 -0
  129. package/build/utils/cache/optimistically_create_message.js.map +1 -0
  130. package/build/utils/cache/optimistically_update_message.d.ts +7 -0
  131. package/build/utils/cache/optimistically_update_message.d.ts.map +1 -0
  132. package/build/utils/cache/optimistically_update_message.js +21 -0
  133. package/build/utils/cache/optimistically_update_message.js.map +1 -0
  134. package/build/utils/cache/page_mutations.d.ts +6 -3
  135. package/build/utils/cache/page_mutations.d.ts.map +1 -1
  136. package/build/utils/cache/page_mutations.js +4 -4
  137. package/build/utils/cache/page_mutations.js.map +1 -1
  138. package/build/utils/convert_attachments_for_create.d.ts +12 -0
  139. package/build/utils/convert_attachments_for_create.d.ts.map +1 -0
  140. package/build/utils/convert_attachments_for_create.js +70 -0
  141. package/build/utils/convert_attachments_for_create.js.map +1 -0
  142. package/build/utils/generate_placeholder_ulid.d.ts +10 -0
  143. package/build/utils/generate_placeholder_ulid.d.ts.map +1 -0
  144. package/build/utils/generate_placeholder_ulid.js +28 -0
  145. package/build/utils/generate_placeholder_ulid.js.map +1 -0
  146. package/build/utils/index.d.ts +1 -0
  147. package/build/utils/index.d.ts.map +1 -1
  148. package/build/utils/index.js +1 -0
  149. package/build/utils/index.js.map +1 -1
  150. package/build/utils/response_error.d.ts +1 -0
  151. package/build/utils/response_error.d.ts.map +1 -1
  152. package/build/utils/response_error.js +6 -0
  153. package/build/utils/response_error.js.map +1 -1
  154. package/package.json +2 -2
  155. package/src/components/conversation/attachments/image_attachment.tsx +25 -10
  156. package/src/components/conversation/message.tsx +116 -28
  157. package/src/components/conversation/message_form/message_form_attachment_image.tsx +1 -1
  158. package/src/components/conversation/message_form/message_form_attachment_video.tsx +1 -1
  159. package/src/components/conversation/message_form.tsx +16 -13
  160. package/src/components/conversations/conversations.tsx +8 -1
  161. package/src/components/display/spinner.tsx +7 -2
  162. package/src/components/display/text.tsx +10 -2
  163. package/src/components/primitive/form_sheet.tsx +3 -2
  164. package/src/contexts/api_provider.tsx +37 -3
  165. package/src/hooks/groups/use_groups_conversation_create.ts +3 -1
  166. package/src/hooks/services/use_find_or_create_services_conversation.ts +29 -21
  167. package/src/hooks/{use_services_team.ts → services/use_services_team.ts} +2 -2
  168. package/src/hooks/use_attachment_uploader.ts +9 -25
  169. package/src/hooks/use_chat_permissions.ts +12 -9
  170. package/src/hooks/use_conversation_messages_jolt_events.ts +19 -1
  171. package/src/hooks/use_giphy.ts +1 -1
  172. package/src/hooks/use_message_create_or_update.ts +82 -6
  173. package/src/index.tsx +1 -1
  174. package/src/navigation/index.tsx +10 -0
  175. package/src/screens/conversation_filter_recipients/conversation_filter_recipients_screen.tsx +118 -17
  176. package/src/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.ts +61 -10
  177. package/src/screens/conversation_filter_recipients/types.tsx +8 -0
  178. package/src/screens/conversation_filters/components/rows.tsx +1 -1
  179. package/src/screens/conversation_new/components/groups_form.tsx +2 -2
  180. package/src/screens/conversation_new/components/services_form.tsx +17 -3
  181. package/src/screens/conversation_new/conversation_new_screen.tsx +11 -2
  182. package/src/screens/conversation_select_recipients/conversation_select_recipients_screen.tsx +90 -74
  183. package/src/screens/team_conversation_screen.tsx +46 -0
  184. package/src/types/resources/denormalized_attachment_resource.ts +9 -37
  185. package/src/types/resources/denormalized_attachment_resource_for_create.ts +65 -0
  186. package/src/types/resources/message.ts +6 -0
  187. package/src/types/resources/services/chat_resource.ts +66 -0
  188. package/src/types/resources/services/index.ts +1 -0
  189. package/src/types/resources/services/team_resource.ts +10 -53
  190. package/src/utils/__tests__/convert_attachments_for_create.test.ts +175 -0
  191. package/src/utils/cache/optimistically_create_message.ts +71 -0
  192. package/src/utils/cache/optimistically_update_message.ts +37 -0
  193. package/src/utils/cache/page_mutations.ts +5 -3
  194. package/src/utils/convert_attachments_for_create.ts +92 -0
  195. package/src/utils/generate_placeholder_ulid.ts +32 -0
  196. package/src/utils/index.ts +1 -0
  197. package/src/utils/response_error.ts +8 -0
  198. package/build/hooks/use_services_team.d.ts.map +0 -1
  199. package/build/hooks/use_services_team.js.map +0 -1
@@ -1,51 +1,19 @@
1
1
  import { ResourceObject } from '../../api_primitives';
2
- interface ServicesChatResource extends ResourceObject {
3
- type: 'Chat';
4
- }
5
- export interface TeamResource extends ServicesChatResource {
6
- teamsILead: TeamResponseItem[];
7
- }
8
- export interface TeamResponseItem {
2
+ export interface Team extends ResourceObject {
3
+ id: number;
9
4
  name: string;
10
- value: {
11
- teamId: number;
12
- serviceTypeId: number;
13
- };
5
+ serviceType: ServiceType;
6
+ serviceTypeId: number;
14
7
  serviceTypeName: string;
15
8
  teamName: string;
16
9
  order: [number, string, string];
17
10
  }
18
- export interface TeamOptionResource extends ServicesChatResource {
19
- teams: TeamOptionResponseItem[];
20
- }
21
- export interface TeamOptionResponseItem extends TeamResponseItem {
22
- group: TeamOptionResponseItemGroupName;
23
- }
24
- export type TeamOptionResponseItemGroupName = 'teams_i_lead' | 'other_teams';
25
- export interface PlansResource extends ServicesChatResource {
26
- plans: PlansResponseItem[];
27
- }
28
- export interface PlansResponseItem {
29
- value: number;
30
- name: string;
31
- }
32
- export interface TeamPeopleResource extends ServicesChatResource {
33
- people: TeamPersonResponseItem[];
34
- }
35
- export interface TeamPersonResponseItem {
11
+ export interface ServiceType {
36
12
  id: number;
13
+ type: 'ServiceType';
14
+ links: {
15
+ self: string;
16
+ };
37
17
  name: string;
38
- avatar: string;
39
- badges: {
40
- title: string;
41
- }[];
42
- child: boolean;
43
- }
44
- export interface ServicesChatPayloadResource extends ServicesChatResource {
45
- payload: string;
46
- }
47
- export interface ServicesChatGroupIdentifiersResource extends ServicesChatResource {
48
- groupIdentifiers: string[];
49
18
  }
50
- export {};
51
19
  //# sourceMappingURL=team_resource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"team_resource.d.ts","sourceRoot":"","sources":["../../../../src/types/resources/services/team_resource.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,UAAU,oBAAqB,SAAQ,cAAc;IACnD,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,Y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d.ts","sourceRoot":"","sources":["../../../../src/types/resources/services/team_resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAGrD,MAAM,WAAW,IAAK,SAAQ,cAAc;IAC1C,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,WAAW,CAAA;IACxB,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,IAAI,EAAE,MAAM,CAAA;CACb"}
@@ -1,7 +1,2 @@
1
- // All of our calls out to services go out to /chat, which isn't a typical pco-api vertex.
2
- // They all have a shared type of 'Chat' which has the following array attributes:
3
- // group_identifiers, people, plans, teams and, teams_i_lead.
4
- // All of these have a type array, are only rendered on request, and are exclusively used for this form.
5
- // There is also a payload which is a string, and is used to create a conversation in chat.
6
1
  export {};
7
2
  //# sourceMappingURL=team_resource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"team_resource.js","sourceRoot":"","sources":["../../../../src/types/resources/services/team_resource.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,kFAAkF;AAClF,6DAA6D;AAC7D,wGAAwG;AACxG,2FAA2F","sourcesContent":["// All of our calls out to services go out to /chat, which isn't a typical pco-api vertex.\n// They all have a shared type of 'Chat' which has the following array attributes:\n// group_identifiers, people, plans, teams and, teams_i_lead.\n// All of these have a type array, are only rendered on request, and are exclusively used for this form.\n// There is also a payload which is a string, and is used to create a conversation in chat.\n\nimport { ResourceObject } from '../../api_primitives'\n\ninterface ServicesChatResource extends ResourceObject {\n type: 'Chat'\n}\n\nexport interface TeamResource extends ServicesChatResource {\n teamsILead: TeamResponseItem[]\n}\nexport interface TeamResponseItem {\n name: string\n value: {\n teamId: number\n serviceTypeId: number\n }\n serviceTypeName: string\n teamName: string\n order: [number, string, string] // [serviceTypeId, serviceTypeName, teamName]\n}\n\nexport interface TeamOptionResource extends ServicesChatResource {\n teams: TeamOptionResponseItem[]\n}\n\nexport interface TeamOptionResponseItem extends TeamResponseItem {\n group: TeamOptionResponseItemGroupName\n}\n\nexport type TeamOptionResponseItemGroupName = 'teams_i_lead' | 'other_teams'\n\nexport interface PlansResource extends ServicesChatResource {\n plans: PlansResponseItem[]\n}\n\nexport interface PlansResponseItem {\n value: number\n name: string\n}\n\nexport interface TeamPeopleResource extends ServicesChatResource {\n people: TeamPersonResponseItem[]\n}\n\nexport interface TeamPersonResponseItem {\n id: number\n name: string\n avatar: string\n badges: { title: string }[]\n child: boolean\n}\n\nexport interface ServicesChatPayloadResource extends ServicesChatResource {\n payload: string\n}\n\nexport interface ServicesChatGroupIdentifiersResource extends ServicesChatResource {\n groupIdentifiers: string[]\n}\n"]}
1
+ {"version":3,"file":"team_resource.js","sourceRoot":"","sources":["../../../../src/types/resources/services/team_resource.ts"],"names":[],"mappings":"","sourcesContent":["import { ResourceObject } from '../../api_primitives'\n\n// Returned by /me/teams\nexport interface Team extends ResourceObject {\n id: number // equivalent to TeamResponseItem.value.teamId\n name: string\n serviceType: ServiceType\n serviceTypeId: number // equivalent to TeamResponseItem.value.serviceTypeId\n serviceTypeName: string\n teamName: string\n order: [number, string, string] // [serviceTypeId, serviceTypeName, teamName]\n}\n\nexport interface ServiceType {\n id: number\n type: 'ServiceType'\n links: {\n self: string\n }\n name: string\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { CurrentPersonResource, MessageResource } from '../../types';
2
+ import { DenormalizedAttachmentResourceForCreate } from '../../types/resources/denormalized_attachment_resource_for_create';
3
+ export declare function optimisticallyCreateMessage({ conversationId, text, attachments, currentPerson, message, }: {
4
+ conversationId: number;
5
+ text: string;
6
+ attachments?: DenormalizedAttachmentResourceForCreate[];
7
+ currentPerson: CurrentPersonResource;
8
+ message?: MessageResource;
9
+ }): MessageResource;
10
+ //# sourceMappingURL=optimistically_create_message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimistically_create_message.d.ts","sourceRoot":"","sources":["../../../src/utils/cache/optimistically_create_message.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAKnF,OAAO,EAAE,uCAAuC,EAAE,MAAM,mEAAmE,CAAA;AAI3H,wBAAgB,2BAA2B,CAAC,EAC1C,cAAc,EACd,IAAI,EACJ,WAAW,EACX,aAAa,EACb,OAAO,GACR,EAAE;IACD,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,uCAAuC,EAAE,CAAA;IACvD,aAAa,EAAE,qBAAqB,CAAA;IACpC,OAAO,CAAC,EAAE,eAAe,CAAA;CAC1B,mBA0CA"}
@@ -0,0 +1,43 @@
1
+ import { getMessagesQueryKey } from '../../hooks/use_conversation_messages';
2
+ import { chatQueryClient } from '../../contexts/api_provider';
3
+ import { updateOrCreateRecordInPagesData } from './page_mutations';
4
+ import { convertAttachmentsForCreate } from '../convert_attachments_for_create';
5
+ import { generatePlaceholderUlid } from '../generate_placeholder_ulid';
6
+ export function optimisticallyCreateMessage({ conversationId, text, attachments, currentPerson, message, }) {
7
+ const id = message?.id || generateTempMessageId();
8
+ // Convert attachments to denormalized format for optimistic UI
9
+ const decoratedAttachments = convertAttachmentsForCreate(attachments || []);
10
+ // Create an optimistic message
11
+ const optimisticMessage = {
12
+ ...message,
13
+ type: 'Message',
14
+ id,
15
+ text,
16
+ html: '', // Will be filled by server
17
+ createdAt: new Date().toISOString(),
18
+ deletedAt: null,
19
+ textEditedAt: null,
20
+ mine: true,
21
+ attachments: decoratedAttachments,
22
+ attachmentsForCreate: attachments || [],
23
+ author: currentPerson,
24
+ reactionCounts: [],
25
+ renderAuthor: false,
26
+ renderTime: true,
27
+ myLatestInConversation: true,
28
+ lastInGroup: true,
29
+ pending: true,
30
+ };
31
+ const queryKey = getMessagesQueryKey({ conversation_id: conversationId });
32
+ chatQueryClient.setQueryData(queryKey, data => updateOrCreateRecordInPagesData({
33
+ data,
34
+ record: optimisticMessage,
35
+ }));
36
+ return optimisticMessage;
37
+ }
38
+ const generateTempMessageId = () => {
39
+ // Put it 5 seconds in the future to account for server lag of previously created messages
40
+ // that are still pending. This gets overwritten by the server anyway.
41
+ return `${generatePlaceholderUlid({ offsetMs: 5000 })}-temp`;
42
+ };
43
+ //# sourceMappingURL=optimistically_create_message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimistically_create_message.js","sourceRoot":"","sources":["../../../src/utils/cache/optimistically_create_message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAA;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAA;AAG/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAEtE,MAAM,UAAU,2BAA2B,CAAC,EAC1C,cAAc,EACd,IAAI,EACJ,WAAW,EACX,aAAa,EACb,OAAO,GAOR;IACC,MAAM,EAAE,GAAG,OAAO,EAAE,EAAE,IAAI,qBAAqB,EAAE,CAAA;IAEjD,+DAA+D;IAC/D,MAAM,oBAAoB,GAAqC,2BAA2B,CACxF,WAAW,IAAI,EAAE,CAClB,CAAA;IAED,+BAA+B;IAC/B,MAAM,iBAAiB,GAAoB;QACzC,GAAG,OAAO;QACV,IAAI,EAAE,SAAS;QACf,EAAE;QACF,IAAI;QACJ,IAAI,EAAE,EAAE,EAAE,2BAA2B;QACrC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,IAAI;QAClB,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,oBAAoB;QACjC,oBAAoB,EAAE,WAAW,IAAI,EAAE;QACvC,MAAM,EAAE,aAAa;QACrB,cAAc,EAAE,EAAE;QAClB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,IAAI;QAChB,sBAAsB,EAAE,IAAI;QAC5B,WAAW,EAAE,IAAI;QACjB,OAAO,EAAE,IAAI;KACd,CAAA;IAID,MAAM,QAAQ,GAAG,mBAAmB,CAAC,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC,CAAA;IAEzE,eAAe,CAAC,YAAY,CAAY,QAAQ,EAAE,IAAI,CAAC,EAAE,CACvD,+BAA+B,CAAC;QAC9B,IAAI;QACJ,MAAM,EAAE,iBAAoC;KAC7C,CAAC,CACH,CAAA;IAED,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAED,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACjC,0FAA0F;IAC1F,sEAAsE;IACtE,OAAO,GAAG,uBAAuB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,OAAO,CAAA;AAC9D,CAAC,CAAA","sourcesContent":["import { InfiniteData } from '@tanstack/react-query'\nimport { ApiCollection, CurrentPersonResource, MessageResource } from '../../types'\nimport { getMessagesQueryKey } from '../../hooks/use_conversation_messages'\nimport { chatQueryClient } from '../../contexts/api_provider'\nimport { updateOrCreateRecordInPagesData } from './page_mutations'\nimport { convertAttachmentsForCreate } from '../convert_attachments_for_create'\nimport { DenormalizedAttachmentResourceForCreate } from '../../types/resources/denormalized_attachment_resource_for_create'\nimport { DenormalizedAttachmentResource } from '../../types/resources/denormalized_attachment_resource'\nimport { generatePlaceholderUlid } from '../generate_placeholder_ulid'\n\nexport function optimisticallyCreateMessage({\n conversationId,\n text,\n attachments,\n currentPerson,\n message,\n}: {\n conversationId: number\n text: string\n attachments?: DenormalizedAttachmentResourceForCreate[]\n currentPerson: CurrentPersonResource\n message?: MessageResource\n}) {\n const id = message?.id || generateTempMessageId()\n\n // Convert attachments to denormalized format for optimistic UI\n const decoratedAttachments: DenormalizedAttachmentResource[] = convertAttachmentsForCreate(\n attachments || []\n )\n\n // Create an optimistic message\n const optimisticMessage: MessageResource = {\n ...message,\n type: 'Message',\n id,\n text,\n html: '', // Will be filled by server\n createdAt: new Date().toISOString(),\n deletedAt: null,\n textEditedAt: null,\n mine: true,\n attachments: decoratedAttachments,\n attachmentsForCreate: attachments || [],\n author: currentPerson,\n reactionCounts: [],\n renderAuthor: false,\n renderTime: true,\n myLatestInConversation: true,\n lastInGroup: true,\n pending: true,\n }\n\n // Add the optimistic message to the cache\n type QueryData = InfiniteData<ApiCollection<MessageResource>>\n const queryKey = getMessagesQueryKey({ conversation_id: conversationId })\n\n chatQueryClient.setQueryData<QueryData>(queryKey, data =>\n updateOrCreateRecordInPagesData({\n data,\n record: optimisticMessage as MessageResource,\n })\n )\n\n return optimisticMessage\n}\n\nconst generateTempMessageId = () => {\n // Put it 5 seconds in the future to account for server lag of previously created messages\n // that are still pending. This gets overwritten by the server anyway.\n return `${generatePlaceholderUlid({ offsetMs: 5000 })}-temp`\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { MessageResource } from '../../types';
2
+ export declare function optimisticallyUpdateMessage({ conversationId, message, text, }: {
3
+ conversationId: number;
4
+ message: MessageResource;
5
+ text: string;
6
+ }): MessageResource;
7
+ //# sourceMappingURL=optimistically_update_message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimistically_update_message.d.ts","sourceRoot":"","sources":["../../../src/utils/cache/optimistically_update_message.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,eAAe,EAAE,MAAM,aAAa,CAAA;AAK5D,wBAAgB,2BAA2B,CAAC,EAC1C,cAAc,EACd,OAAO,EACP,IAAI,GACL,EAAE;IACD,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,eAAe,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;CACb,mBAsBA"}
@@ -0,0 +1,21 @@
1
+ import { getMessagesQueryKey } from '../../hooks/use_conversation_messages';
2
+ import { chatQueryClient } from '../../contexts/api_provider';
3
+ import { updateOrCreateRecordInPagesData } from './page_mutations';
4
+ export function optimisticallyUpdateMessage({ conversationId, message, text, }) {
5
+ const queryKey = getMessagesQueryKey({ conversation_id: conversationId });
6
+ let optimisticMessage = message;
7
+ chatQueryClient.setQueryData(queryKey, data => updateOrCreateRecordInPagesData({
8
+ data,
9
+ record: message,
10
+ processRecord: (next, prev) => {
11
+ optimisticMessage = {
12
+ ...(prev || next),
13
+ text,
14
+ pending: true,
15
+ };
16
+ return optimisticMessage;
17
+ },
18
+ }));
19
+ return optimisticMessage;
20
+ }
21
+ //# sourceMappingURL=optimistically_update_message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimistically_update_message.js","sourceRoot":"","sources":["../../../src/utils/cache/optimistically_update_message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAA;AAElE,MAAM,UAAU,2BAA2B,CAAC,EAC1C,cAAc,EACd,OAAO,EACP,IAAI,GAKL;IAEC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC,CAAA;IAEzE,IAAI,iBAAiB,GAAG,OAAO,CAAA;IAE/B,eAAe,CAAC,YAAY,CAAY,QAAQ,EAAE,IAAI,CAAC,EAAE,CACvD,+BAA+B,CAAC;QAC9B,IAAI;QACJ,MAAM,EAAE,OAAO;QACf,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;YAC5B,iBAAiB,GAAG;gBAClB,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC;gBACjB,IAAI;gBACJ,OAAO,EAAE,IAAI;aACd,CAAA;YACD,OAAO,iBAAiB,CAAA;QAC1B,CAAC;KACF,CAAC,CACH,CAAA;IAED,OAAO,iBAAiB,CAAA;AAC1B,CAAC","sourcesContent":["import { InfiniteData } from '@tanstack/react-query'\nimport { ApiCollection, MessageResource } from '../../types'\nimport { getMessagesQueryKey } from '../../hooks/use_conversation_messages'\nimport { chatQueryClient } from '../../contexts/api_provider'\nimport { updateOrCreateRecordInPagesData } from './page_mutations'\n\nexport function optimisticallyUpdateMessage({\n conversationId,\n message,\n text,\n}: {\n conversationId: number\n message: MessageResource\n text: string\n}) {\n type QueryData = InfiniteData<ApiCollection<MessageResource>>\n const queryKey = getMessagesQueryKey({ conversation_id: conversationId })\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"]}
@@ -43,8 +43,8 @@ export declare function updateOrCreateRecordInPagesData<T extends ResourceObject
43
43
  pageParams: any;
44
44
  } | undefined;
45
45
  /**
46
- * updateOrCreateRecordInPagesData
47
- * Updates record if found in the cache, otherwise inserts.
46
+ * updateAllRecordsInPagesData
47
+ * Updates all records in the cache using the provided processRecord function.
48
48
  */
49
49
  export declare function updateAllRecordsInPagesData<T extends ResourceObject>({ data, processRecord, }: {
50
50
  data?: {
@@ -74,7 +74,7 @@ export declare function addRecordInPagesData<T extends ResourceObject>({ data, r
74
74
  /**
75
75
  * deleteRecordInPagesData
76
76
  */
77
- export declare function deleteRecordInPagesData<T extends ResourceObject>({ data, record, }: {
77
+ export declare function deleteRecordInPagesData<T extends ResourceObject>({ data, record, matchFn, }: {
78
78
  data?: {
79
79
  pages: ApiCollection<T>[];
80
80
  pageParams: any;
@@ -82,6 +82,9 @@ export declare function deleteRecordInPagesData<T extends ResourceObject>({ data
82
82
  record: {
83
83
  id: string | number;
84
84
  };
85
+ matchFn?: (message: T, record: {
86
+ id: string | number;
87
+ }) => boolean;
85
88
  }): {
86
89
  pages: {
87
90
  data: T[];
@@ -1 +1 @@
1
- {"version":3,"file":"page_mutations.d.ts","sourceRoot":"","sources":["../../../src/utils/cache/page_mutations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE3D;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,cAAc,EAAE,EAChE,IAAI,EACJ,MAAM,EACN,aAAsB,GACvB,EAAE;IACD,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;QAAC,UAAU,EAAE,GAAG,CAAA;KAAE,CAAA;IACrD,MAAM,EAAE,CAAC,CAAA;IACT,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAA;CAC1C;;;;;;gBAHiD,GAAG;cAkBpD;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,CAAC,SAAS,cAAc,EAAE,EACxE,IAAI,EACJ,MAAM,EACN,aAAsB,GACvB,EAAE;IACD,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;QAAC,UAAU,EAAE,GAAG,CAAA;KAAE,CAAA;IACrD,MAAM,EAAE,CAAC,CAAA;IACT,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;CAC3C;;;;;;gBAHiD,GAAG;cA2BpD;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,cAAc,EAAE,EACpE,IAAI,EACJ,aAAsB,GACvB,EAAE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AAA;CAChC;;gBAHiD,GAAG;cAapD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,cAAc,EAAE,EAChE,IAAI,EACJ,MAAM,EACN,OAAiD,GAClD,EAAE;IACD,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;QAAC,UAAU,EAAE,GAAG,CAAA;KAAE,CAAA;IACrD,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IAC/B,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,KAAK,OAAO,CAAA;CACnE;;;;;;gBAHiD,GAAG;cAepD"}
@@ -48,8 +48,8 @@ export function updateOrCreateRecordInPagesData({ data, record, processRecord =
48
48
  return { ...data, pages: newPages };
49
49
  }
50
50
  /**
51
- * updateOrCreateRecordInPagesData
52
- * Updates record if found in the cache, otherwise inserts.
51
+ * updateAllRecordsInPagesData
52
+ * Updates all records in the cache using the provided processRecord function.
53
53
  */
54
54
  export function updateAllRecordsInPagesData({ data, processRecord = r => r, }) {
55
55
  if (!data)
@@ -72,12 +72,12 @@ export function addRecordInPagesData({ data, record, processRecord = r => r, })
72
72
  /**
73
73
  * deleteRecordInPagesData
74
74
  */
75
- export function deleteRecordInPagesData({ data, record, }) {
75
+ export function deleteRecordInPagesData({ data, record, matchFn = (message, rec) => message.id === rec.id, }) {
76
76
  if (!data)
77
77
  return data;
78
78
  const newPages = data.pages.map(page => {
79
79
  const newData = page.data.filter(message => {
80
- return message.id !== record.id;
80
+ return !matchFn(message, record);
81
81
  });
82
82
  return { ...page, data: newData };
83
83
  });
@@ -1 +1 @@
1
- {"version":3,"file":"page_mutations.js","sourceRoot":"","sources":["../../../src/utils/cache/page_mutations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,MAA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AC,CAAC,EAAE,CAAA;IACpC,SAAS,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;IAE3D,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;IAEvB,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAA2B,EAChE,IAAI,EACJ,MAAM,GAIP;IACC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAEtB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;YACzC,OAAO,OAAO,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAA;QACjC,CAAC,CAAC,CAAA;QAEF,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;IACnC,CAAC,CAAC,CAAA;IAEF,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;AACrC,CAAC","sourcesContent":["/**\n * Helpers to handle updating messages in the cache\n * Messages are ordered by ULID on the client so we may\n * have diverging logic from other kinds of api data\n */\n\nimport { ApiCollection, ResourceObject } from '../../types'\n\n/**\n * updateRecordInPagesData\n * Updates record if found in the cache, otherwise noops.\n */\nexport function updateRecordInPagesData<T extends ResourceObject>({\n data,\n record,\n processRecord = r => r,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n record: T\n processRecord?: (_next: T, _prev: T) => T\n}) {\n if (!data) return data\n\n const newPages = data.pages.map(page => {\n const newData = page.data.map(message => {\n if (message.id === record.id) {\n return processRecord(record, message)\n }\n return message\n })\n\n return { ...page, data: newData }\n })\n\n return { ...data, pages: newPages }\n}\n\n/**\n * updateOrCreateRecordInPagesData\n * Updates record if found in the cache, otherwise inserts.\n */\nexport function updateOrCreateRecordInPagesData<T extends ResourceObject>({\n data,\n record,\n processRecord = r => r,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n record: T\n processRecord?: (_next: T, _prev?: T) => T\n}) {\n if (!data) return data\n\n let foundRecord = false\n const newPages = data.pages.map(page => {\n const newData = page.data.map(message => {\n if (message.id === record.id) {\n foundRecord = true\n return processRecord(record, message)\n }\n return message\n })\n\n return { ...page, data: newData }\n })\n\n if (!foundRecord) {\n // This is a fallback for when the record is not found in the cache.\n const firstPage = { ...newPages[0] }\n firstPage.data = [processRecord(record), ...firstPage.data]\n newPages[0] = firstPage\n }\n\n return { ...data, pages: newPages }\n}\n\n/**\n * updateOrCreateRecordInPagesData\n * Updates record if found in the cache, otherwise inserts.\n */\nexport function updateAllRecordsInPagesData<T extends ResourceObject>({\n data,\n processRecord = r => r,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n processRecord?: (_next: T) => T\n}) {\n if (!data) return data\n\n const newPages = data.pages.map(page => {\n const newData = page.data.map(processRecord)\n\n return { ...page, data: newData }\n })\n\n return { ...data, pages: newPages }\n}\n\nexport function addRecordInPagesData<T extends ResourceObject>({\n data,\n record,\n processRecord = r => r,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n record: T\n processRecord?: (_next: T) => T\n}) {\n if (!data) return data\n\n const newPages = [...data.pages]\n const firstPage = { ...newPages[0] }\n firstPage.data = [processRecord(record), ...firstPage.data]\n\n newPages[0] = firstPage\n\n return { ...data, pages: newPages }\n}\n\n/**\n * deleteRecordInPagesData\n */\nexport function deleteRecordInPagesData<T extends ResourceObject>({\n data,\n record,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n record: { id: string | number }\n}) {\n if (!data) return data\n\n const newPages = data.pages.map(page => {\n const newData = page.data.filter(message => {\n return message.id !== record.id\n })\n\n return { ...page, data: newData }\n })\n\n return { ...data, pages: newPages }\n}\n"]}
1
+ {"version":3,"file":"page_mutations.js","sourceRoot":"","sources":["../../../src/utils/cache/page_mutations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAA2B,EAChE,IAAI,EACJ,MAAM,EACN,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAKvB;IACC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAEtB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YACtC,IAAI,OAAO,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;gBAC7B,OAAO,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;YACvC,CAAC;YACD,OAAO,OAAO,CAAA;QAChB,CAAC,CAAC,CAAA;QAEF,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;IACnC,CAAC,CAAC,CAAA;IAEF,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,+BAA+B,CAA2B,EACxE,IAAI,EACJ,MAAM,EACN,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAKvB;IACC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAEtB,IAAI,WAAW,GAAG,KAAK,CAAA;IACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YACtC,IAAI,OAAO,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,EAAE,CAA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AAE,OAAO,IAAI,CAAA;IAEtB,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;IAChC,MAAM,SAAS,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;IACpC,SAAS,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;IAE3D,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;IAEvB,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAA2B,EAChE,IAAI,EACJ,MAAM,EACN,OAAO,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,GAKlD;IACC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAEtB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;YACzC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QAClC,CAAC,CAAC,CAAA;QAEF,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;IACnC,CAAC,CAAC,CAAA;IAEF,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;AACrC,CAAC","sourcesContent":["/**\n * Helpers to handle updating messages in the cache\n * Messages are ordered by ULID on the client so we may\n * have diverging logic from other kinds of api data\n */\n\nimport { ApiCollection, ResourceObject } from '../../types'\n\n/**\n * updateRecordInPagesData\n * Updates record if found in the cache, otherwise noops.\n */\nexport function updateRecordInPagesData<T extends ResourceObject>({\n data,\n record,\n processRecord = r => r,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n record: T\n processRecord?: (_next: T, _prev: T) => T\n}) {\n if (!data) return data\n\n const newPages = data.pages.map(page => {\n const newData = page.data.map(message => {\n if (message.id === record.id) {\n return processRecord(record, message)\n }\n return message\n })\n\n return { ...page, data: newData }\n })\n\n return { ...data, pages: newPages }\n}\n\n/**\n * updateOrCreateRecordInPagesData\n * Updates record if found in the cache, otherwise inserts.\n */\nexport function updateOrCreateRecordInPagesData<T extends ResourceObject>({\n data,\n record,\n processRecord = r => r,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n record: T\n processRecord?: (_next: T, _prev?: T) => T\n}) {\n if (!data) return data\n\n let foundRecord = false\n const newPages = data.pages.map(page => {\n const newData = page.data.map(message => {\n if (message.id === record.id) {\n foundRecord = true\n return processRecord(record, message)\n }\n return message\n })\n\n return { ...page, data: newData }\n })\n\n if (!foundRecord) {\n // This is a fallback for when the record is not found in the cache.\n const firstPage = { ...newPages[0] }\n firstPage.data = [processRecord(record), ...firstPage.data]\n newPages[0] = firstPage\n }\n\n return { ...data, pages: newPages }\n}\n\n/**\n * updateAllRecordsInPagesData\n * Updates all records in the cache using the provided processRecord function.\n */\nexport function updateAllRecordsInPagesData<T extends ResourceObject>({\n data,\n processRecord = r => r,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n processRecord?: (_next: T) => T\n}) {\n if (!data) return data\n\n const newPages = data.pages.map(page => {\n const newData = page.data.map(processRecord)\n\n return { ...page, data: newData }\n })\n\n return { ...data, pages: newPages }\n}\n\nexport function addRecordInPagesData<T extends ResourceObject>({\n data,\n record,\n processRecord = r => r,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n record: T\n processRecord?: (_next: T) => T\n}) {\n if (!data) return data\n\n const newPages = [...data.pages]\n const firstPage = { ...newPages[0] }\n firstPage.data = [processRecord(record), ...firstPage.data]\n\n newPages[0] = firstPage\n\n return { ...data, pages: newPages }\n}\n\n/**\n * deleteRecordInPagesData\n */\nexport function deleteRecordInPagesData<T extends ResourceObject>({\n data,\n record,\n matchFn = (message, rec) => message.id === rec.id,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n record: { id: string | number }\n matchFn?: (message: T, record: { id: string | number }) => boolean\n}) {\n if (!data) return data\n\n const newPages = data.pages.map(page => {\n const newData = page.data.filter(message => {\n return !matchFn(message, record)\n })\n\n return { ...page, data: newData }\n })\n\n return { ...data, pages: newPages }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { DenormalizedAttachmentResource } from '../types/resources/denormalized_attachment_resource';
2
+ import { DenormalizedAttachmentResourceForCreate } from '../types/resources/denormalized_attachment_resource_for_create';
3
+ /**
4
+ * Converts an array of DenormalizedAttachmentResourceForCreate to DenormalizedAttachmentResource.
5
+ * This is used to create optimistic UI attachments that match the server format.
6
+ */
7
+ export declare function convertAttachmentsForCreate(attachments: DenormalizedAttachmentResourceForCreate[]): DenormalizedAttachmentResource[];
8
+ /**
9
+ * Converts a single DenormalizedAttachmentResourceForCreate to DenormalizedAttachmentResource.
10
+ */
11
+ export declare function convertAttachmentForCreate(attachment: DenormalizedAttachmentResourceForCreate): DenormalizedAttachmentResource;
12
+ //# sourceMappingURL=convert_attachments_for_create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert_attachments_for_create.d.ts","sourceRoot":"","sources":["../../src/utils/convert_attachments_for_create.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAI/B,MAAM,qDAAqD,CAAA;AAC5D,OAAO,EACL,uCAAuC,EAGxC,MAAM,gEAAgE,CAAA;AAEvE;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,uCAAuC,EAAE,GACrD,8BAA8B,EAAE,CAElC;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,uCAAuC,GAClD,8BAA8B,CAahC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Converts an array of DenormalizedAttachmentResourceForCreate to DenormalizedAttachmentResource.
3
+ * This is used to create optimistic UI attachments that match the server format.
4
+ */
5
+ export function convertAttachmentsForCreate(attachments) {
6
+ return attachments.map(convertAttachmentForCreate);
7
+ }
8
+ /**
9
+ * Converts a single DenormalizedAttachmentResourceForCreate to DenormalizedAttachmentResource.
10
+ */
11
+ export function convertAttachmentForCreate(attachment) {
12
+ switch (attachment.type) {
13
+ case 'MessageAttachment':
14
+ return convertMessageAttachmentForCreate(attachment);
15
+ case 'giphy':
16
+ return convertGiphyAttachmentForCreate(attachment);
17
+ case 'ExpandedLink':
18
+ // ExpandedLink is already in the correct format
19
+ return attachment;
20
+ default:
21
+ // This should never happen with proper TypeScript typing
22
+ throw new Error(`Unknown attachment type: ${attachment.type}`);
23
+ }
24
+ }
25
+ /**
26
+ * Converts a MessageAttachment from "for create" format to denormalized format.
27
+ */
28
+ function convertMessageAttachmentForCreate(attachment) {
29
+ return {
30
+ type: 'MessageAttachment',
31
+ id: attachment.id,
32
+ attributes: {
33
+ filename: attachment.file.name,
34
+ key: '', // Will be filled by server
35
+ contentType: attachment.file.type,
36
+ byteSize: attachment.file.size,
37
+ checksum: '', // Will be filled by server
38
+ url: attachment.file.uri, // Use local file URI for optimistic UI
39
+ metadata: {
40
+ width: attachment.file.width,
41
+ height: attachment.file.height,
42
+ analyzed: false,
43
+ identified: false,
44
+ },
45
+ },
46
+ };
47
+ }
48
+ /**
49
+ * Converts a GiphyAttachment from "for create" format to denormalized format.
50
+ */
51
+ function convertGiphyAttachmentForCreate(attachment) {
52
+ return {
53
+ type: 'giphy',
54
+ id: attachment.id,
55
+ title: attachment.title,
56
+ originalGiphyTitle: attachment.original_giphy_title,
57
+ titleLink: attachment.title_link,
58
+ thumbUrl: attachment.thumb_url,
59
+ giphy: {
60
+ original: attachment.giphy.original,
61
+ fixedHeight: attachment.giphy.fixed_height,
62
+ fixedHeightStill: attachment.giphy.fixed_height_still,
63
+ fixedHeightDownsampled: attachment.giphy.fixed_height_downsampled,
64
+ fixedWidth: attachment.giphy.fixed_width,
65
+ fixedWidthStill: attachment.giphy.fixed_width_still,
66
+ fixedWidthDownsampled: attachment.giphy.fixed_width_downsampled,
67
+ },
68
+ };
69
+ }
70
+ //# sourceMappingURL=convert_attachments_for_create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert_attachments_for_create.js","sourceRoot":"","sources":["../../src/utils/convert_attachments_for_create.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,WAAsD;IAEtD,OAAO,WAAW,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,UAAmD;IAEnD,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,mBAAmB;YACtB,OAAO,iCAAiC,CAAC,UAAU,CAAC,CAAA;QACtD,KAAK,OAAO;YACV,OAAO,+BAA+B,CAAC,UAAU,CAAC,CAAA;QACpD,KAAK,cAAc;YACjB,gDAAgD;YAChD,OAAO,UAAwD,CAAA;QACjE;YACE,yDAAyD;YACzD,MAAM,IAAI,KAAK,CAAC,4BAA6B,UAAkB,CAAC,IAAI,EAAE,CAAC,CAAA;IAC3E,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,iCAAiC,CACxC,UAA0D;IAE1D,OAAO;QACL,IAAI,EAAE,mBAAmB;QACzB,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,UAAU,EAAE;YACV,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI;YAC9B,GAAG,EAAE,EAAE,EAAE,2BAA2B;YACpC,WAAW,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI;YACjC,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI;YAC9B,QAAQ,EAAE,EAAE,EAAE,2BAA2B;YACzC,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,uCAAuC;YACjE,QAAQ,EAAE;gBACR,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK;gBAC5B,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM;gBAC9B,QAAQ,EAAE,KAAK;gBACf,UAAU,EAAE,KAAK;aAClB;SACF;KACF,CAAA;AACH,CAAC;AAED;;GAEG;AACH,SAAS,+BAA+B,CACtC,UAAwD;IAExD,OAAO;QACL,IAAI,EAAE,OAAO;QACb,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,kBAAkB,EAAE,UAAU,CAAC,oBAAoB;QACnD,SAAS,EAAE,UAAU,CAAC,UAAU;QAChC,QAAQ,EAAE,UAAU,CAAC,SAAS;QAC9B,KAAK,EAAE;YACL,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ;YACnC,WAAW,EAAE,UAAU,CAAC,KAAK,CAAC,YAAY;YAC1C,gBAAgB,EAAE,UAAU,CAAC,KAAK,CAAC,kBAAkB;YACrD,sBAAsB,EAAE,UAAU,CAAC,KAAK,CAAC,wBAAwB;YACjE,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,WAAW;YACxC,eAAe,EAAE,UAAU,CAAC,KAAK,CAAC,iBAAiB;YACnD,qBAAqB,EAAE,UAAU,CAAC,KAAK,CAAC,uBAAuB;SAChE;KACF,CAAA;AACH,CAAC","sourcesContent":["import {\n DenormalizedAttachmentResource,\n DenormalizedMessageAttachmentResource,\n DenormalizedGiphyAttachmentResource,\n DenormalizedExpandedLinkAttachmentResource,\n} from '../types/resources/denormalized_attachment_resource'\nimport {\n DenormalizedAttachmentResourceForCreate,\n DenormalizedMessageAttachmentResourceForCreate,\n DenormalizedGiphyAttachmentResourceForCreate,\n} from '../types/resources/denormalized_attachment_resource_for_create'\n\n/**\n * Converts an array of DenormalizedAttachmentResourceForCreate to DenormalizedAttachmentResource.\n * This is used to create optimistic UI attachments that match the server format.\n */\nexport function convertAttachmentsForCreate(\n attachments: DenormalizedAttachmentResourceForCreate[]\n): DenormalizedAttachmentResource[] {\n return attachments.map(convertAttachmentForCreate)\n}\n\n/**\n * Converts a single DenormalizedAttachmentResourceForCreate to DenormalizedAttachmentResource.\n */\nexport function convertAttachmentForCreate(\n attachment: DenormalizedAttachmentResourceForCreate\n): DenormalizedAttachmentResource {\n switch (attachment.type) {\n case 'MessageAttachment':\n return convertMessageAttachmentForCreate(attachment)\n case 'giphy':\n return convertGiphyAttachmentForCreate(attachment)\n case 'ExpandedLink':\n // ExpandedLink is already in the correct format\n return attachment as DenormalizedExpandedLinkAttachmentResource\n default:\n // This should never happen with proper TypeScript typing\n throw new Error(`Unknown attachment type: ${(attachment as any).type}`)\n }\n}\n\n/**\n * Converts a MessageAttachment from \"for create\" format to denormalized format.\n */\nfunction convertMessageAttachmentForCreate(\n attachment: DenormalizedMessageAttachmentResourceForCreate\n): DenormalizedMessageAttachmentResource {\n return {\n type: 'MessageAttachment',\n id: attachment.id,\n attributes: {\n filename: attachment.file.name,\n key: '', // Will be filled by server\n contentType: attachment.file.type,\n byteSize: attachment.file.size,\n checksum: '', // Will be filled by server\n url: attachment.file.uri, // Use local file URI for optimistic UI\n metadata: {\n width: attachment.file.width,\n height: attachment.file.height,\n analyzed: false,\n identified: false,\n },\n },\n }\n}\n\n/**\n * Converts a GiphyAttachment from \"for create\" format to denormalized format.\n */\nfunction convertGiphyAttachmentForCreate(\n attachment: DenormalizedGiphyAttachmentResourceForCreate\n): DenormalizedGiphyAttachmentResource {\n return {\n type: 'giphy',\n id: attachment.id,\n title: attachment.title,\n originalGiphyTitle: attachment.original_giphy_title,\n titleLink: attachment.title_link,\n thumbUrl: attachment.thumb_url,\n giphy: {\n original: attachment.giphy.original,\n fixedHeight: attachment.giphy.fixed_height,\n fixedHeightStill: attachment.giphy.fixed_height_still,\n fixedHeightDownsampled: attachment.giphy.fixed_height_downsampled,\n fixedWidth: attachment.giphy.fixed_width,\n fixedWidthStill: attachment.giphy.fixed_width_still,\n fixedWidthDownsampled: attachment.giphy.fixed_width_downsampled,\n },\n }\n}\n"]}
@@ -0,0 +1,10 @@
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
+ */
7
+ export declare function generatePlaceholderUlid({ offsetMs }?: {
8
+ offsetMs?: number;
9
+ }): string;
10
+ //# sourceMappingURL=generate_placeholder_ulid.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,28 @@
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
+ */
7
+ const ULID_CHARS = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'; // Crockford's Base32
8
+ function encodeBase32(value, length) {
9
+ let result = '';
10
+ for (let i = 0; i < length; i++) {
11
+ result = ULID_CHARS[value % 32] + result;
12
+ value = Math.floor(value / 32);
13
+ }
14
+ return result;
15
+ }
16
+ export function generatePlaceholderUlid({ offsetMs = 0 } = {}) {
17
+ const timestamp = Date.now() + offsetMs; // Milliseconds since epoch
18
+ // 48 bits for timestamp (6 Base32 characters)
19
+ const timeComponent = encodeBase32(timestamp, 10); // 48 bits = 6 bytes = 10 Base32 characters (approx, needs more precise bit shifting)
20
+ // 80 bits for randomness (16 Base32 characters)
21
+ let randomComponent = '';
22
+ for (let i = 0; i < 16; i++) {
23
+ // Generate 16 random Base32 chars
24
+ randomComponent += ULID_CHARS[Math.floor(Math.random() * 32)];
25
+ }
26
+ return timeComponent + randomComponent;
27
+ }
28
+ //# sourceMappingURL=generate_placeholder_ulid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate_placeholder_ulid.js","sourceRoot":"","sources":["../../src/utils/generate_placeholder_ulid.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,UAAU,GAAG,kCAAkC,CAAA,CAAC,qBAAqB;AAE3E,SAAS,YAAY,CAAC,KAAa,EAAE,MAAc;IACjD,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,MAAM,GAAG,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,MAAM,CAAA;QACxC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAA;IAChC,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,EAAE,QAAQ,GAAG,CAAC,KAA4B,EAAE;IAClF,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAA,CAAC,2BAA2B;IACnE,8CAA8C;IAC9C,MAAM,aAAa,GAAG,YAAY,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA,CAAC,qFAAqF;IAEvI,gDAAgD;IAChD,IAAI,eAAe,GAAG,EAAE,CAAA;IACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,kCAAkC;QAClC,eAAe,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;IAC/D,CAAC;IAED,OAAO,aAAa,GAAG,eAAe,CAAA;AACxC,CAAC","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"]}
@@ -8,4 +8,5 @@ export * from './cache';
8
8
  export * from './native_adapters';
9
9
  export * from './pluralize';
10
10
  export * from './destructure_chat_group_graph_id';
11
+ export * from './convert_attachments_for_create';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,mCAAmC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,mCAAmC,CAAA;AACjD,cAAc,kCAAkC,CAAA"}
@@ -8,4 +8,5 @@ export * from './cache';
8
8
  export * from './native_adapters';
9
9
  export * from './pluralize';
10
10
  export * from './destructure_chat_group_graph_id';
11
+ export * from './convert_attachments_for_create';
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,mCAAmC,CAAA","sourcesContent":["export * from './session'\nexport * from './theme'\nexport * from './styles'\nexport * from './space'\nexport * from './client'\nexport * from './uri'\nexport * from './cache'\nexport * from './native_adapters'\nexport * from './pluralize'\nexport * from './destructure_chat_group_graph_id'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,mCAAmC,CAAA;AACjD,cAAc,kCAAkC,CAAA","sourcesContent":["export * from './session'\nexport * from './theme'\nexport * from './styles'\nexport * from './space'\nexport * from './client'\nexport * from './uri'\nexport * from './cache'\nexport * from './native_adapters'\nexport * from './pluralize'\nexport * from './destructure_chat_group_graph_id'\nexport * from './convert_attachments_for_create'\n"]}
@@ -6,4 +6,5 @@ export declare class ResponseError extends Error {
6
6
  response: ApiError;
7
7
  constructor(response: ApiError);
8
8
  }
9
+ export declare const throwResponseError: (error: unknown) => Promise<never>;
9
10
  //# sourceMappingURL=response_error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"response_error.d.ts","sourceRoot":"","sources":["../../src/utils/response_error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAElD,qBAAa,aAAc,SAAQ,KAAK;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC1B,QAAQ,EAAE,QAAQ,CAAA;gBAEN,QAAQ,EAAE,QAAQ;CAQ/B"}
1
+ {"version":3,"file":"response_error.d.ts","sourceRoot":"","sources":["../../src/utils/response_error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAElD,qBAAa,aAAc,SAAQ,KAAK;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC1B,QAAQ,EAAE,QAAQ,CAAA;gBAEN,QAAQ,EAAE,QAAQ;CAQ/B;AAED,eAAO,MAAM,kBAAkB,UAAW,OAAO,mBAMhD,CAAA"}
@@ -12,4 +12,10 @@ export class ResponseError extends Error {
12
12
  this.response = response;
13
13
  }
14
14
  }
15
+ export const throwResponseError = (error) => {
16
+ if (error instanceof Response) {
17
+ throw new ResponseError(error);
18
+ }
19
+ return Promise.reject(error);
20
+ };
15
21
  //# sourceMappingURL=response_error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"response_error.js","sourceRoot":"","sources":["../../src/utils/response_error.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,MAAM,CAAQ;IACd,UAAU,CAAQ;IAClB,MAAM,CAAoB;IAC1B,QAAQ,CAAU;IAElB,YAAY,QAAkB;QAC5B,KAAK,CAAC,kBAAkB,QAAQ,EAAE,MAAM,IAAI,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;QACnE,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE,MAAM,CAAA;QAC9B,IAAI,CAAC,UAAU,GAAG,QAAQ,EAAE,UAAU,CAAA;QACtC,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAA;QACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CACF","sourcesContent":["import { ApiError } from '../types/api_primitives'\n\nexport class ResponseError extends Error {\n status: number\n statusText: string\n errors: ApiError['errors']\n response: ApiError\n\n constructor(response: ApiError) {\n super(`ResponseError: ${response?.status} ${response?.statusText}`)\n this.name = 'ResponseError'\n this.status = response?.status\n this.statusText = response?.statusText\n this.errors = response?.errors || []\n this.response = response\n }\n}\n"]}
1
+ {"version":3,"file":"response_error.js","sourceRoot":"","sources":["../../src/utils/response_error.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,MAAM,CAAQ;IACd,UAAU,CAAQ;IAClB,MAAM,CAAoB;IAC1B,QAAQ,CAAU;IAElB,YAAY,QAAkB;QAC5B,KAAK,CAAC,kBAAkB,QAAQ,EAAE,MAAM,IAAI,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;QACnE,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE,MAAM,CAAA;QAC9B,IAAI,CAAC,UAAU,GAAG,QAAQ,EAAE,UAAU,CAAA;QACtC,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAA;QACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAAE,EAAE;IACnD,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,aAAa,CAAC,KAAiB,CAAC,CAAA;IAC5C,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC,CAAA","sourcesContent":["import { ApiError } from '../types/api_primitives'\n\nexport class ResponseError extends Error {\n status: number\n statusText: string\n errors: ApiError['errors']\n response: ApiError\n\n constructor(response: ApiError) {\n super(`ResponseError: ${response?.status} ${response?.statusText}`)\n this.name = 'ResponseError'\n this.status = response?.status\n this.statusText = response?.statusText\n this.errors = response?.errors || []\n this.response = response\n }\n}\n\nexport const throwResponseError = (error: unknown) => {\n if (error instanceof Response) {\n throw new ResponseError(error as ApiError)\n }\n\n return Promise.reject(error)\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "3.11.0-rc.9",
3
+ "version": "3.11.0",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -55,5 +55,5 @@
55
55
  "prettier": "^3.4.2",
56
56
  "typescript": "<5.6.0"
57
57
  },
58
- "gitHead": "632d0a10b4a0f7bf3246b04c0e160b9219d7e897"
58
+ "gitHead": "d68607004fe3e05b3e6519564f39953f67c457cb"
59
59
  }
@@ -1,7 +1,12 @@
1
1
  import React, { useMemo, useState, Dispatch, SetStateAction } from 'react'
2
2
  import { StyleSheet, Modal, SafeAreaView, View, Linking, Dimensions } from 'react-native'
3
3
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
4
- import { Gesture, GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler'
4
+ import {
5
+ Gesture,
6
+ GestureDetector,
7
+ GestureHandlerRootView,
8
+ Pressable,
9
+ } from 'react-native-gesture-handler'
5
10
  import {
6
11
  runOnJS,
7
12
  useAnimatedStyle,
@@ -509,15 +514,17 @@ const LightboxModal = ({
509
514
  <SafeAreaView style={styles.modal}>
510
515
  <GestureHandlerRootView>
511
516
  <GestureDetector gesture={composedGesture}>
512
- <Image
513
- source={{ uri }}
514
- loadingBackgroundStyles={styles.lightboxImageLoading}
515
- style={styles.lightboxImage}
516
- animatedImageStyle={animatedImageStyles}
517
- resizeMode="contain"
518
- animated={true}
519
- alt=""
520
- />
517
+ <PreventPressEventsBubbling>
518
+ <Image
519
+ source={{ uri }}
520
+ loadingBackgroundStyles={styles.lightboxImageLoading}
521
+ style={styles.lightboxImage}
522
+ animatedImageStyle={animatedImageStyles}
523
+ resizeMode="contain"
524
+ animated={true}
525
+ alt=""
526
+ />
527
+ </PreventPressEventsBubbling>
521
528
  </GestureDetector>
522
529
  <View style={styles.actionToolbar} accessibilityRole="toolbar">
523
530
  <View style={styles.actionToolbarTextMeta}>
@@ -552,6 +559,14 @@ const LightboxModal = ({
552
559
  )
553
560
  }
554
561
 
562
+ const PreventPressEventsBubbling = ({ children }: { children: React.ReactNode }) => {
563
+ return (
564
+ <Pressable onLongPress={() => {}} onPress={() => {}}>
565
+ {children}
566
+ </Pressable>
567
+ )
568
+ }
569
+
555
570
  interface UseStylesProps {
556
571
  imageWidth?: number
557
572
  imageHeight?: number