@planningcenter/chat-react-native 3.2.0-rc.2 → 3.2.0-rc.21
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.
- package/build/components/conversation/message_form.d.ts +2 -2
- package/build/components/conversation/message_form.d.ts.map +1 -1
- package/build/components/conversation/message_form.js +95 -41
- package/build/components/conversation/message_form.js.map +1 -1
- package/build/components/conversations/action_toggle_button.d.ts +1 -1
- package/build/components/conversations/action_toggle_button.d.ts.map +1 -1
- package/build/components/conversations/action_toggle_button.js +2 -1
- package/build/components/conversations/action_toggle_button.js.map +1 -1
- package/build/components/conversations/conversation_actions.d.ts.map +1 -1
- package/build/components/conversations/conversation_actions.js +25 -11
- package/build/components/conversations/conversation_actions.js.map +1 -1
- package/build/components/conversations/conversations.d.ts +3 -6
- package/build/components/conversations/conversations.d.ts.map +1 -1
- package/build/components/conversations/conversations.js +8 -18
- package/build/components/conversations/conversations.js.map +1 -1
- package/build/components/display/action_button.d.ts +2 -1
- package/build/components/display/action_button.d.ts.map +1 -1
- package/build/components/display/action_button.js +3 -4
- package/build/components/display/action_button.js.map +1 -1
- package/build/components/display/banner.d.ts +6 -1
- package/build/components/display/banner.d.ts.map +1 -1
- package/build/components/display/banner.js +2 -2
- package/build/components/display/banner.js.map +1 -1
- package/build/components/display/banner_collapsible.d.ts +1 -1
- package/build/components/display/banner_collapsible.d.ts.map +1 -1
- package/build/components/display/banner_collapsible.js +2 -2
- package/build/components/display/banner_collapsible.js.map +1 -1
- package/build/components/display/child_notice.d.ts +3 -1
- package/build/components/display/child_notice.d.ts.map +1 -1
- package/build/components/display/child_notice.js +2 -2
- package/build/components/display/child_notice.js.map +1 -1
- package/build/components/display/person.d.ts +3 -1
- package/build/components/display/person.d.ts.map +1 -1
- package/build/components/display/person.js +2 -2
- package/build/components/display/person.js.map +1 -1
- package/build/components/primitive/banner_primitive.d.ts +3 -0
- package/build/components/primitive/banner_primitive.d.ts.map +1 -1
- package/build/components/primitive/banner_primitive.js +4 -5
- package/build/components/primitive/banner_primitive.js.map +1 -1
- package/build/contexts/api_provider.d.ts +1 -1
- package/build/contexts/api_provider.d.ts.map +1 -1
- package/build/contexts/api_provider.js +3 -3
- package/build/contexts/api_provider.js.map +1 -1
- package/build/contexts/chat_context.d.ts +5 -3
- package/build/contexts/chat_context.d.ts.map +1 -1
- package/build/contexts/chat_context.js +8 -3
- package/build/contexts/chat_context.js.map +1 -1
- package/build/contexts/conversations_context.d.ts +14 -0
- package/build/contexts/conversations_context.d.ts.map +1 -0
- package/build/contexts/conversations_context.js +38 -0
- package/build/contexts/conversations_context.js.map +1 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +226 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.js +54 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.js.map +1 -0
- package/build/hooks/groups/use_groups_conversation_create.d.ts +9 -0
- package/build/hooks/groups/use_groups_conversation_create.d.ts.map +1 -0
- package/build/hooks/groups/use_groups_conversation_create.js +36 -0
- package/build/hooks/groups/use_groups_conversation_create.js.map +1 -0
- package/build/hooks/use_api.d.ts +41 -41
- package/build/hooks/use_api.d.ts.map +1 -1
- package/build/hooks/use_api.js +5 -0
- package/build/hooks/use_api.js.map +1 -1
- package/build/hooks/use_api_client.d.ts.map +1 -1
- package/build/hooks/use_api_client.js +5 -3
- package/build/hooks/use_api_client.js.map +1 -1
- package/build/hooks/use_chat_permissions.d.ts +14 -14
- package/build/hooks/use_conversations.d.ts +6 -32
- package/build/hooks/use_conversations.d.ts.map +1 -1
- package/build/hooks/use_conversations.js +15 -14
- package/build/hooks/use_conversations.js.map +1 -1
- package/build/hooks/use_conversations_actions.d.ts +221 -0
- package/build/hooks/use_conversations_actions.d.ts.map +1 -0
- package/build/hooks/use_conversations_actions.js +103 -0
- package/build/hooks/use_conversations_actions.js.map +1 -0
- package/build/hooks/use_conversations_cache.d.ts +18 -0
- package/build/hooks/use_conversations_cache.d.ts.map +1 -0
- package/build/hooks/{use_conversation_jolt_events.js → use_conversations_cache.js} +27 -17
- package/build/hooks/use_conversations_cache.js.map +1 -0
- package/build/hooks/use_conversations_jolt_events.d.ts +3 -0
- package/build/hooks/use_conversations_jolt_events.d.ts.map +1 -0
- package/build/hooks/use_conversations_jolt_events.js +15 -0
- package/build/hooks/use_conversations_jolt_events.js.map +1 -0
- package/build/hooks/use_current_person.d.ts +15 -0
- package/build/hooks/use_current_person.d.ts.map +1 -1
- package/build/hooks/use_current_person.js +26 -9
- package/build/hooks/use_current_person.js.map +1 -1
- package/build/hooks/use_giphy.d.ts +9 -0
- package/build/hooks/use_giphy.d.ts.map +1 -0
- package/build/hooks/use_giphy.js +63 -0
- package/build/hooks/use_giphy.js.map +1 -0
- package/build/hooks/use_groups.d.ts +26 -26
- package/build/hooks/use_groups_groups.d.ts +26 -26
- package/build/hooks/use_jolt.d.ts.map +1 -1
- package/build/hooks/use_jolt.js +42 -20
- package/build/hooks/use_jolt.js.map +1 -1
- package/build/hooks/use_message_create.d.ts +11 -0
- package/build/hooks/use_message_create.d.ts.map +1 -0
- package/build/hooks/use_message_create.js +35 -0
- package/build/hooks/use_message_create.js.map +1 -0
- package/build/hooks/use_suspense_api.d.ts.map +1 -1
- package/build/hooks/use_suspense_api.js +5 -0
- package/build/hooks/use_suspense_api.js.map +1 -1
- package/build/hooks/use_teams.d.ts +26 -26
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/navigation/index.d.ts +65 -38
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +29 -10
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_details_screen.js +2 -2
- package/build/screens/conversation_details_screen.js.map +1 -1
- package/build/screens/conversation_filter_recipients/components/checkbox_row.d.ts +10 -0
- package/build/screens/conversation_filter_recipients/components/checkbox_row.d.ts.map +1 -0
- package/build/screens/conversation_filter_recipients/components/checkbox_row.js +74 -0
- package/build/screens/conversation_filter_recipients/components/checkbox_row.js.map +1 -0
- package/build/screens/conversation_filter_recipients/components/header_row.d.ts +10 -0
- package/build/screens/conversation_filter_recipients/components/header_row.d.ts.map +1 -0
- package/build/screens/conversation_filter_recipients/components/header_row.js +69 -0
- package/build/screens/conversation_filter_recipients/components/header_row.js.map +1 -0
- package/build/screens/conversation_filter_recipients/components/navigation_header.d.ts +5 -0
- package/build/screens/conversation_filter_recipients/components/navigation_header.d.ts.map +1 -0
- package/build/screens/conversation_filter_recipients/components/navigation_header.js +46 -0
- package/build/screens/conversation_filter_recipients/components/navigation_header.js.map +1 -0
- package/build/screens/conversation_filter_recipients/context/conversation_filter_recipients_context.d.ts +17 -0
- package/build/screens/conversation_filter_recipients/context/conversation_filter_recipients_context.d.ts.map +1 -0
- package/build/screens/conversation_filter_recipients/context/conversation_filter_recipients_context.js +37 -0
- package/build/screens/conversation_filter_recipients/context/conversation_filter_recipients_context.js.map +1 -0
- package/build/screens/{create → conversation_filter_recipients}/conversation_filter_recipients_screen.d.ts +1 -3
- package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.d.ts.map +1 -0
- package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.js +87 -0
- package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.js.map +1 -0
- package/build/screens/conversation_filter_recipients/hooks/use_flattened_array_of_service_types_with_teams.d.ts +10 -0
- package/build/screens/conversation_filter_recipients/hooks/use_flattened_array_of_service_types_with_teams.d.ts.map +1 -0
- package/build/screens/conversation_filter_recipients/hooks/use_flattened_array_of_service_types_with_teams.js +32 -0
- package/build/screens/conversation_filter_recipients/hooks/use_flattened_array_of_service_types_with_teams.js.map +1 -0
- package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.d.ts +8 -0
- package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.d.ts.map +1 -0
- package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.js +65 -0
- package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.js.map +1 -0
- package/build/screens/conversation_filter_recipients/types.d.ts +38 -0
- package/build/screens/conversation_filter_recipients/types.d.ts.map +1 -0
- package/build/screens/conversation_filter_recipients/types.js +6 -0
- package/build/screens/conversation_filter_recipients/types.js.map +1 -0
- package/build/screens/conversation_filters/hooks/filters.d.ts +40 -40
- package/build/screens/conversation_filters/hooks/filters.js +1 -1
- package/build/screens/conversation_filters/hooks/filters.js.map +1 -1
- package/build/screens/conversation_new/components/form_list.d.ts +12 -0
- package/build/screens/conversation_new/components/form_list.d.ts.map +1 -0
- package/build/screens/conversation_new/components/form_list.js +42 -0
- package/build/screens/conversation_new/components/form_list.js.map +1 -0
- package/build/screens/conversation_new/components/groups_form.d.ts +7 -0
- package/build/screens/conversation_new/components/groups_form.d.ts.map +1 -0
- package/build/screens/conversation_new/components/groups_form.js +105 -0
- package/build/screens/conversation_new/components/groups_form.js.map +1 -0
- package/build/screens/conversation_new/components/source_app_error_card.d.ts +2 -0
- package/build/screens/conversation_new/components/source_app_error_card.d.ts.map +1 -0
- package/build/screens/conversation_new/components/source_app_error_card.js +16 -0
- package/build/screens/conversation_new/components/source_app_error_card.js.map +1 -0
- package/build/screens/conversation_new/components/team_form.d.ts +8 -0
- package/build/screens/conversation_new/components/team_form.d.ts.map +1 -0
- package/build/screens/conversation_new/components/team_form.js +11 -0
- package/build/screens/conversation_new/components/team_form.js.map +1 -0
- package/build/screens/conversation_new/conversation_new_screen.d.ts +15 -0
- package/build/screens/conversation_new/conversation_new_screen.d.ts.map +1 -0
- package/build/screens/conversation_new/conversation_new_screen.js +16 -0
- package/build/screens/conversation_new/conversation_new_screen.js.map +1 -0
- package/build/screens/conversation_screen.d.ts +1 -0
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +1 -1
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/conversation_select_recipients/components/groups_without_chat_disclaimer_row.d.ts +2 -0
- package/build/screens/conversation_select_recipients/components/groups_without_chat_disclaimer_row.d.ts.map +1 -0
- package/build/screens/conversation_select_recipients/components/groups_without_chat_disclaimer_row.js +17 -0
- package/build/screens/conversation_select_recipients/components/groups_without_chat_disclaimer_row.js.map +1 -0
- package/build/screens/conversation_select_recipients/components/recipient_link_row.d.ts +12 -0
- package/build/screens/conversation_select_recipients/components/recipient_link_row.d.ts.map +1 -0
- package/build/screens/conversation_select_recipients/components/recipient_link_row.js +61 -0
- package/build/screens/conversation_select_recipients/components/recipient_link_row.js.map +1 -0
- package/build/screens/conversation_select_recipients/components/view_more_link_row.d.ts +7 -0
- package/build/screens/conversation_select_recipients/components/view_more_link_row.d.ts.map +1 -0
- package/build/screens/conversation_select_recipients/components/view_more_link_row.js +21 -0
- package/build/screens/conversation_select_recipients/components/view_more_link_row.js.map +1 -0
- package/build/screens/conversation_select_recipients/conversation_select_group_recipients_screen.d.ts +4 -0
- package/build/screens/conversation_select_recipients/conversation_select_group_recipients_screen.d.ts.map +1 -0
- package/build/screens/conversation_select_recipients/conversation_select_group_recipients_screen.js +48 -0
- package/build/screens/conversation_select_recipients/conversation_select_group_recipients_screen.js.map +1 -0
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.d.ts +4 -0
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.d.ts.map +1 -0
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.js +86 -0
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.js.map +1 -0
- package/build/screens/conversation_select_recipients/types/screen_props.d.ts +9 -0
- package/build/screens/conversation_select_recipients/types/screen_props.d.ts.map +1 -0
- package/build/screens/conversation_select_recipients/types/screen_props.js +2 -0
- package/build/screens/conversation_select_recipients/types/screen_props.js.map +1 -0
- package/build/screens/conversations/components/list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/list_header_component.js +22 -4
- package/build/screens/conversations/components/list_header_component.js.map +1 -1
- package/build/screens/conversations/conversations_screen.d.ts +2 -1
- package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations/conversations_screen.js +35 -11
- package/build/screens/conversations/conversations_screen.js.map +1 -1
- package/build/screens/message_actions_screen.d.ts +2 -2
- package/build/screens/message_actions_screen.d.ts.map +1 -1
- package/build/screens/message_actions_screen.js.map +1 -1
- package/build/screens/send_giphy_screen.d.ts +10 -0
- package/build/screens/send_giphy_screen.d.ts.map +1 -0
- package/build/screens/send_giphy_screen.js +126 -0
- package/build/screens/send_giphy_screen.js.map +1 -0
- package/build/types/resources/groups/groups_group_resource.d.ts +1 -1
- package/build/types/resources/groups/groups_group_resource.js.map +1 -1
- package/build/types/resources/groups/groups_member_resource_with_person.d.ts +14 -0
- package/build/types/resources/groups/groups_member_resource_with_person.d.ts.map +1 -0
- package/build/types/resources/groups/groups_member_resource_with_person.js +2 -0
- package/build/types/resources/groups/groups_member_resource_with_person.js.map +1 -0
- package/build/types/resources/member.d.ts +0 -10
- package/build/types/resources/member.d.ts.map +1 -1
- package/build/types/resources/member.js.map +1 -1
- package/build/types/resources/oauth_token.d.ts +4 -4
- package/build/types/resources/oauth_token.d.ts.map +1 -1
- package/build/types/resources/oauth_token.js.map +1 -1
- package/build/utils/cache/page_mutations.d.ts +18 -0
- package/build/utils/cache/page_mutations.d.ts.map +1 -1
- package/build/utils/cache/page_mutations.js +13 -0
- package/build/utils/cache/page_mutations.js.map +1 -1
- package/build/utils/client/client.d.ts +4 -8
- package/build/utils/client/client.d.ts.map +1 -1
- package/build/utils/client/client.js +10 -9
- package/build/utils/client/client.js.map +1 -1
- package/build/utils/destructure_chat_group_graph_id.d.ts +10 -0
- package/build/utils/destructure_chat_group_graph_id.d.ts.map +1 -0
- package/build/utils/destructure_chat_group_graph_id.js +8 -0
- package/build/utils/destructure_chat_group_graph_id.js.map +1 -0
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +1 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/request/conversation.d.ts +1 -3
- package/build/utils/request/conversation.d.ts.map +1 -1
- package/build/utils/request/conversation.js +37 -30
- package/build/utils/request/conversation.js.map +1 -1
- package/build/utils/session.d.ts +6 -2
- package/build/utils/session.d.ts.map +1 -1
- package/build/utils/session.js +6 -1
- package/build/utils/session.js.map +1 -1
- package/build/utils/uri.d.ts +10 -2
- package/build/utils/uri.d.ts.map +1 -1
- package/build/utils/uri.js +24 -6
- package/build/utils/uri.js.map +1 -1
- package/build/vendor/tapestry/alias_tokens_color_map.d.ts +2 -0
- package/build/vendor/tapestry/alias_tokens_color_map.d.ts.map +1 -1
- package/build/vendor/tapestry/alias_tokens_color_map.js +2 -0
- package/build/vendor/tapestry/alias_tokens_color_map.js.map +1 -1
- package/package.json +4 -3
- package/src/__tests__/hooks/useTheme.tsx +1 -1
- package/src/__tests__/utils/cache/page_mutations.ts +49 -15
- package/src/__tests__/{client.ts → utils/client.ts} +7 -115
- package/src/__tests__/{session.ts → utils/session.ts} +4 -4
- package/src/__tests__/utils/uri.ts +107 -0
- package/src/components/conversation/message_form.tsx +127 -58
- package/src/components/conversations/action_toggle_button.tsx +2 -1
- package/src/components/conversations/conversation_actions.tsx +41 -14
- package/src/components/conversations/conversations.tsx +39 -52
- package/src/components/display/action_button.tsx +4 -3
- package/src/components/display/banner.tsx +7 -1
- package/src/components/display/banner_collapsible.tsx +6 -1
- package/src/components/display/child_notice.tsx +9 -3
- package/src/components/display/person.tsx +4 -3
- package/src/components/primitive/banner_primitive.tsx +12 -6
- package/src/contexts/api_provider.tsx +3 -3
- package/src/contexts/chat_context.tsx +13 -6
- package/src/contexts/conversations_context.tsx +69 -0
- package/src/hooks/groups/use_group_members_for_new_conversation.ts +62 -0
- package/src/hooks/groups/use_groups_conversation_create.ts +50 -0
- package/src/hooks/use_api.ts +11 -5
- package/src/hooks/use_api_client.ts +7 -3
- package/src/hooks/use_conversations.ts +34 -16
- package/src/hooks/use_conversations_actions.ts +119 -0
- package/src/hooks/{use_conversation_jolt_events.ts → use_conversations_cache.ts} +35 -20
- package/src/hooks/use_conversations_jolt_events.ts +25 -0
- package/src/hooks/use_current_person.ts +37 -9
- package/src/hooks/use_giphy.ts +97 -0
- package/src/hooks/use_jolt.ts +56 -20
- package/src/hooks/use_message_create.ts +55 -0
- package/src/hooks/use_suspense_api.ts +6 -0
- package/src/index.tsx +2 -1
- package/src/navigation/index.tsx +39 -10
- package/src/screens/conversation_details_screen.tsx +2 -2
- package/src/screens/conversation_filter_recipients/components/checkbox_row.tsx +101 -0
- package/src/screens/conversation_filter_recipients/components/header_row.tsx +99 -0
- package/src/screens/conversation_filter_recipients/components/navigation_header.tsx +68 -0
- package/src/screens/conversation_filter_recipients/context/conversation_filter_recipients_context.tsx +53 -0
- package/src/screens/conversation_filter_recipients/conversation_filter_recipients_screen.tsx +120 -0
- package/src/screens/conversation_filter_recipients/hooks/use_flattened_array_of_service_types_with_teams.tsx +50 -0
- package/src/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.ts +90 -0
- package/src/screens/conversation_filter_recipients/types.tsx +47 -0
- package/src/screens/conversation_filters/hooks/filters.ts +1 -1
- package/src/screens/conversation_new/components/form_list.tsx +67 -0
- package/src/screens/conversation_new/components/groups_form.tsx +163 -0
- package/src/screens/conversation_new/components/source_app_error_card.tsx +24 -0
- package/src/screens/conversation_new/components/team_form.tsx +18 -0
- package/src/screens/conversation_new/conversation_new_screen.tsx +29 -0
- package/src/screens/conversation_screen.tsx +2 -1
- package/src/screens/conversation_select_recipients/components/groups_without_chat_disclaimer_row.tsx +21 -0
- package/src/screens/conversation_select_recipients/components/recipient_link_row.tsx +91 -0
- package/src/screens/conversation_select_recipients/components/view_more_link_row.tsx +30 -0
- package/src/screens/conversation_select_recipients/conversation_select_group_recipients_screen.tsx +79 -0
- package/src/screens/conversation_select_recipients/conversation_select_recipients_screen.tsx +121 -0
- package/src/screens/conversation_select_recipients/types/screen_props.tsx +11 -0
- package/src/screens/conversations/components/list_header_component.tsx +25 -4
- package/src/screens/conversations/conversations_screen.tsx +39 -17
- package/src/screens/message_actions_screen.tsx +2 -2
- package/src/screens/send_giphy_screen.tsx +184 -0
- package/src/types/resources/groups/groups_group_resource.ts +1 -1
- package/src/types/resources/groups/groups_member_resource_with_person.ts +13 -0
- package/src/types/resources/member.ts +0 -11
- package/src/types/resources/oauth_token.ts +4 -4
- package/src/utils/cache/page_mutations.ts +22 -0
- package/src/utils/client/client.ts +13 -13
- package/src/utils/destructure_chat_group_graph_id.ts +25 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/request/conversation.ts +39 -34
- package/src/utils/session.ts +10 -4
- package/src/utils/uri.ts +30 -6
- package/src/vendor/tapestry/alias_tokens_color_map.ts +3 -0
- package/build/contexts/swipeable_active_conversation.d.ts +0 -11
- package/build/contexts/swipeable_active_conversation.d.ts.map +0 -1
- package/build/contexts/swipeable_active_conversation.js +0 -16
- package/build/contexts/swipeable_active_conversation.js.map +0 -1
- package/build/hooks/use_conversation_jolt_events.d.ts +0 -2
- package/build/hooks/use_conversation_jolt_events.d.ts.map +0 -1
- package/build/hooks/use_conversation_jolt_events.js.map +0 -1
- package/build/screens/create/conversation_create_screen.d.ts +0 -9
- package/build/screens/create/conversation_create_screen.d.ts.map +0 -1
- package/build/screens/create/conversation_create_screen.js +0 -122
- package/build/screens/create/conversation_create_screen.js.map +0 -1
- package/build/screens/create/conversation_filter_recipients_screen.d.ts.map +0 -1
- package/build/screens/create/conversation_filter_recipients_screen.js +0 -52
- package/build/screens/create/conversation_filter_recipients_screen.js.map +0 -1
- package/build/screens/create/conversation_select_recipients_screen.d.ts +0 -8
- package/build/screens/create/conversation_select_recipients_screen.d.ts.map +0 -1
- package/build/screens/create/conversation_select_recipients_screen.js +0 -97
- package/build/screens/create/conversation_select_recipients_screen.js.map +0 -1
- package/src/contexts/swipeable_active_conversation.tsx +0 -27
- package/src/screens/create/conversation_create_screen.tsx +0 -151
- package/src/screens/create/conversation_filter_recipients_screen.tsx +0 -79
- package/src/screens/create/conversation_select_recipients_screen.tsx +0 -128
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deleteRecordInPagesData,
|
|
3
|
+
updateAllRecordsInPagesData,
|
|
3
4
|
updateOrCreateRecordInPagesData,
|
|
4
5
|
updateRecordInPagesData,
|
|
5
6
|
} from '../../../utils/'
|
|
@@ -28,11 +29,44 @@ const data = {
|
|
|
28
29
|
],
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
describe('
|
|
32
|
+
describe('updateAllRecordsInPagesData', () => {
|
|
33
|
+
it('should update all records in the pages data', () => {
|
|
34
|
+
const result = updateAllRecordsInPagesData({
|
|
35
|
+
data,
|
|
36
|
+
processRecord: r => ({ ...r, text: 'updated ' + r.text }),
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
expect(result).toEqual({
|
|
40
|
+
pageParams: {},
|
|
41
|
+
pages: [
|
|
42
|
+
{
|
|
43
|
+
data: [
|
|
44
|
+
{ id: '1', type: 'Message', text: 'updated message 1' },
|
|
45
|
+
{ id: '2', type: 'Message', text: 'updated message 2' },
|
|
46
|
+
],
|
|
47
|
+
included: [],
|
|
48
|
+
links: {},
|
|
49
|
+
meta: { count: 2, totalCount: 2 },
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
data: [
|
|
53
|
+
{ id: '3', type: 'Message', text: 'updated message 3' },
|
|
54
|
+
{ id: '4', type: 'Message', text: 'updated message 4' },
|
|
55
|
+
],
|
|
56
|
+
included: [],
|
|
57
|
+
links: {},
|
|
58
|
+
meta: { count: 2, totalCount: 2 },
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
describe('updateOrCreateRecordInPagesData', () => {
|
|
32
66
|
it('should update the record in the pages data', () => {
|
|
33
67
|
const id = '3'
|
|
34
68
|
const record = createRecord({ id })
|
|
35
|
-
const result =
|
|
69
|
+
const result = updateOrCreateRecordInPagesData({ data, record })
|
|
36
70
|
|
|
37
71
|
expect(result).toEqual({
|
|
38
72
|
pageParams: {},
|
|
@@ -63,7 +97,7 @@ describe('updateRecordInPagesData', () => {
|
|
|
63
97
|
const id = '2'
|
|
64
98
|
const record = createRecord({ id })
|
|
65
99
|
|
|
66
|
-
const result =
|
|
100
|
+
const result = updateOrCreateRecordInPagesData<typeof record>({
|
|
67
101
|
data,
|
|
68
102
|
record,
|
|
69
103
|
processRecord: r => ({ ...r, text: 'updated ' + r.text }),
|
|
@@ -93,20 +127,9 @@ describe('updateRecordInPagesData', () => {
|
|
|
93
127
|
],
|
|
94
128
|
})
|
|
95
129
|
})
|
|
96
|
-
|
|
97
|
-
it('should skip the record if it does not exist', () => {
|
|
98
|
-
const id = '5'
|
|
99
|
-
const record = createRecord({ id })
|
|
100
|
-
const result = updateRecordInPagesData<typeof record>({
|
|
101
|
-
data,
|
|
102
|
-
record,
|
|
103
|
-
processRecord: r => ({ ...r, text: 'updated ' + r.text }),
|
|
104
|
-
})
|
|
105
|
-
expect(result).toEqual(data)
|
|
106
|
-
})
|
|
107
130
|
})
|
|
108
131
|
|
|
109
|
-
describe('updateOrCreateRecordInPagesData', () => {
|
|
132
|
+
describe('updateOrCreateRecordInPagesData function', () => {
|
|
110
133
|
it('should update the record in the pages data', () => {
|
|
111
134
|
const id = '3'
|
|
112
135
|
const record = createRecord({ id })
|
|
@@ -207,6 +230,17 @@ describe('updateOrCreateRecordInPagesData', () => {
|
|
|
207
230
|
],
|
|
208
231
|
})
|
|
209
232
|
})
|
|
233
|
+
|
|
234
|
+
it('should skip the record if it does not exist', () => {
|
|
235
|
+
const id = '5'
|
|
236
|
+
const record = createRecord({ id })
|
|
237
|
+
const result = updateRecordInPagesData<typeof record>({
|
|
238
|
+
data,
|
|
239
|
+
record,
|
|
240
|
+
processRecord: r => ({ ...r, text: 'updated ' + r.text }),
|
|
241
|
+
})
|
|
242
|
+
expect(result).toEqual(data)
|
|
243
|
+
})
|
|
210
244
|
})
|
|
211
245
|
|
|
212
246
|
describe('deleteRecordInPagesData', () => {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import MockServer from '
|
|
2
|
-
import Client from '
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { ApiError, OAuthToken } from '../types'
|
|
1
|
+
import MockServer from '../../__utils__/server'
|
|
2
|
+
import Client from '../../utils/client/client'
|
|
3
|
+
import DefaultFixtures from '../../__utils__/fixtures/defaults'
|
|
4
|
+
import { BASE_URL } from '../../__utils__/handlers'
|
|
5
|
+
import { ApiError } from '../../types'
|
|
7
6
|
|
|
8
7
|
const APP_BASE_URL = BASE_URL
|
|
9
|
-
|
|
10
|
-
let session: Session
|
|
11
8
|
let client: Client
|
|
12
9
|
let clientWithDefaultHeaders: Client
|
|
13
10
|
let fetchSpy: jest.SpyInstance
|
|
@@ -21,20 +18,17 @@ const onUnauthorizedResponse = jest.fn()
|
|
|
21
18
|
beforeEach(() => {
|
|
22
19
|
jest.clearAllMocks()
|
|
23
20
|
fetchSpy = jest.spyOn(globalThis, 'fetch')
|
|
24
|
-
session = new Session({ env: 'development' })
|
|
25
21
|
client = new Client({
|
|
26
|
-
app: 'chat',
|
|
27
22
|
version: '2018-11-01',
|
|
28
|
-
|
|
23
|
+
root: APP_BASE_URL,
|
|
29
24
|
onUnauthorizedResponse,
|
|
30
25
|
})
|
|
31
26
|
clientWithDefaultHeaders = new Client({
|
|
32
|
-
app: 'chat',
|
|
33
27
|
version: '2018-11-01',
|
|
28
|
+
root: APP_BASE_URL,
|
|
34
29
|
defaultHeaders: {
|
|
35
30
|
'X-Custom-Default-Header': 'important data',
|
|
36
31
|
},
|
|
37
|
-
session,
|
|
38
32
|
onUnauthorizedResponse,
|
|
39
33
|
})
|
|
40
34
|
})
|
|
@@ -345,96 +339,6 @@ describe('delete', () => {
|
|
|
345
339
|
})
|
|
346
340
|
})
|
|
347
341
|
|
|
348
|
-
describe('url switching', () => {
|
|
349
|
-
it('Changes to session switches the base url', async () => {
|
|
350
|
-
const devBase = 'http://api.pco.test/chat/v2'
|
|
351
|
-
const prodBase = 'https://api.planningcenteronline.com/chat/v2'
|
|
352
|
-
const stagingBase = 'https://api-staging.planningcenteronline.com/chat/v2'
|
|
353
|
-
|
|
354
|
-
MockServer.get(prodBase + '/records', {}, 200, { once: true })
|
|
355
|
-
MockServer.get(stagingBase + '/records', {}, 200, { once: true })
|
|
356
|
-
|
|
357
|
-
const newClient = new Client({
|
|
358
|
-
app: 'chat',
|
|
359
|
-
session,
|
|
360
|
-
version: '2018-11-01',
|
|
361
|
-
onUnauthorizedResponse: () => {},
|
|
362
|
-
})
|
|
363
|
-
|
|
364
|
-
await newClient.get({
|
|
365
|
-
url: '/records',
|
|
366
|
-
data: { fields: { Record: ['id'] } },
|
|
367
|
-
})
|
|
368
|
-
|
|
369
|
-
expect(fetchSpy).toHaveBeenCalledWith(
|
|
370
|
-
devBase + '/records?fields[Record]=id&per_page=100',
|
|
371
|
-
expect.any(Object)
|
|
372
|
-
)
|
|
373
|
-
|
|
374
|
-
session.env = 'staging'
|
|
375
|
-
|
|
376
|
-
await newClient.get({
|
|
377
|
-
url: '/records',
|
|
378
|
-
data: { fields: { Record: ['id'] } },
|
|
379
|
-
})
|
|
380
|
-
|
|
381
|
-
expect(fetchSpy).toHaveBeenLastCalledWith(
|
|
382
|
-
'https://api-staging.planningcenteronline.com/chat/v2' +
|
|
383
|
-
'/records?fields[Record]=id&per_page=100',
|
|
384
|
-
expect.any(Object)
|
|
385
|
-
)
|
|
386
|
-
|
|
387
|
-
session.env = 'production'
|
|
388
|
-
|
|
389
|
-
await newClient.get({
|
|
390
|
-
url: '/records',
|
|
391
|
-
data: { fields: { Record: ['id'] } },
|
|
392
|
-
})
|
|
393
|
-
|
|
394
|
-
expect(fetchSpy).toHaveBeenLastCalledWith(
|
|
395
|
-
'https://api.planningcenteronline.com/chat/v2' + '/records?fields[Record]=id&per_page=100',
|
|
396
|
-
expect.any(Object)
|
|
397
|
-
)
|
|
398
|
-
})
|
|
399
|
-
|
|
400
|
-
it('Changes to session switches the base url with custom headers', async () => {
|
|
401
|
-
const token: OAuthToken = {
|
|
402
|
-
access_token: 'foo',
|
|
403
|
-
token_type: undefined,
|
|
404
|
-
created_at: 0,
|
|
405
|
-
expires_in: undefined,
|
|
406
|
-
scope: '',
|
|
407
|
-
refresh_token: undefined,
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
session.token = token
|
|
411
|
-
|
|
412
|
-
await client.get({
|
|
413
|
-
url: '/records',
|
|
414
|
-
data: { fields: { Record: ['id'] } },
|
|
415
|
-
})
|
|
416
|
-
|
|
417
|
-
requestHeadersShouldContain({
|
|
418
|
-
...fetchSpy.mock.calls[0][1],
|
|
419
|
-
key: 'Authorization',
|
|
420
|
-
value: 'foo',
|
|
421
|
-
})
|
|
422
|
-
|
|
423
|
-
session.token.access_token = 'bar'
|
|
424
|
-
|
|
425
|
-
await client.get({
|
|
426
|
-
url: '/records',
|
|
427
|
-
data: { fields: { Record: ['id'] } },
|
|
428
|
-
})
|
|
429
|
-
|
|
430
|
-
requestHeadersShouldContain({
|
|
431
|
-
...fetchSpy.mock.calls[1][1],
|
|
432
|
-
key: 'Authorization',
|
|
433
|
-
value: 'bar',
|
|
434
|
-
})
|
|
435
|
-
})
|
|
436
|
-
})
|
|
437
|
-
|
|
438
342
|
describe('error handling', () => {
|
|
439
343
|
describe('401 errors', () => {
|
|
440
344
|
it('defaults', async () => {
|
|
@@ -466,15 +370,3 @@ describe('error handling', () => {
|
|
|
466
370
|
}
|
|
467
371
|
})
|
|
468
372
|
})
|
|
469
|
-
|
|
470
|
-
const requestHeadersShouldContain = ({
|
|
471
|
-
headers,
|
|
472
|
-
key,
|
|
473
|
-
value,
|
|
474
|
-
}: {
|
|
475
|
-
headers: Record<string, unknown>
|
|
476
|
-
key: string
|
|
477
|
-
value: unknown
|
|
478
|
-
}) => {
|
|
479
|
-
expect(headers[key]).toContain(value)
|
|
480
|
-
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { OAuthToken } from '
|
|
2
|
-
import { Session } from '
|
|
1
|
+
import { OAuthToken } from '../../types'
|
|
2
|
+
import { Session } from '../../utils/session'
|
|
3
3
|
|
|
4
4
|
const token: OAuthToken = {
|
|
5
5
|
access_token: 'access_token',
|
|
6
6
|
refresh_token: 'refresh_token',
|
|
7
|
-
token_type: undefined,
|
|
7
|
+
token_type: 'undefined',
|
|
8
8
|
created_at: 0,
|
|
9
|
-
expires_in:
|
|
9
|
+
expires_in: 0,
|
|
10
10
|
scope: '',
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Uri } from '../../utils'
|
|
2
|
+
|
|
3
|
+
describe('URI', () => {
|
|
4
|
+
it('should be defined', () => {
|
|
5
|
+
expect(Uri).toBeDefined()
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
it('should create a new instance', () => {
|
|
9
|
+
const uri = new Uri({
|
|
10
|
+
session: {
|
|
11
|
+
env: 'production',
|
|
12
|
+
token: undefined,
|
|
13
|
+
type: 'OAuth',
|
|
14
|
+
isAuthenticated: false,
|
|
15
|
+
isChurchCenterToken: false,
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
expect(uri).toBeDefined()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe('baseUrl', () => {
|
|
22
|
+
describe('planning center', () => {
|
|
23
|
+
it('should return the correct base URL for production', () => {
|
|
24
|
+
const uri = new Uri({
|
|
25
|
+
session: {
|
|
26
|
+
env: 'production',
|
|
27
|
+
token: undefined,
|
|
28
|
+
type: 'OAuth',
|
|
29
|
+
isAuthenticated: false,
|
|
30
|
+
isChurchCenterToken: false,
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
expect(uri.baseUrl).toBe('https://api.planningcenteronline.com')
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('should return the correct base URL for staging', () => {
|
|
37
|
+
const uri = new Uri({
|
|
38
|
+
session: {
|
|
39
|
+
env: 'staging',
|
|
40
|
+
token: undefined,
|
|
41
|
+
type: 'OAuth',
|
|
42
|
+
isAuthenticated: false,
|
|
43
|
+
isChurchCenterToken: false,
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
expect(uri.baseUrl).toBe('https://api-staging.planningcenteronline.com')
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('should return the correct base URL for development', () => {
|
|
50
|
+
const uri = new Uri({
|
|
51
|
+
session: {
|
|
52
|
+
env: 'development',
|
|
53
|
+
token: undefined,
|
|
54
|
+
type: 'OAuth',
|
|
55
|
+
isAuthenticated: false,
|
|
56
|
+
isChurchCenterToken: false,
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
expect(uri.baseUrl).toBe('http://api.pco.test')
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
describe('church center', () => {
|
|
64
|
+
it('should return the correct base URL for production', () => {
|
|
65
|
+
const uri = new Uri({
|
|
66
|
+
session: {
|
|
67
|
+
env: 'production',
|
|
68
|
+
token: undefined,
|
|
69
|
+
type: 'ChurchCenterOauth',
|
|
70
|
+
isAuthenticated: false,
|
|
71
|
+
isChurchCenterToken: true,
|
|
72
|
+
},
|
|
73
|
+
graph: 'churchcenter',
|
|
74
|
+
})
|
|
75
|
+
expect(uri.baseUrl).toBe('https://api.churchcenter.com')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('should return the correct base URL for staging', () => {
|
|
79
|
+
const uri = new Uri({
|
|
80
|
+
session: {
|
|
81
|
+
env: 'staging',
|
|
82
|
+
token: undefined,
|
|
83
|
+
type: 'ChurchCenterOauth',
|
|
84
|
+
isAuthenticated: false,
|
|
85
|
+
isChurchCenterToken: true,
|
|
86
|
+
},
|
|
87
|
+
graph: 'churchcenter',
|
|
88
|
+
})
|
|
89
|
+
expect(uri.baseUrl).toBe('https://api.staging.churchcenter.com')
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('should return the correct base URL for development', () => {
|
|
93
|
+
const uri = new Uri({
|
|
94
|
+
session: {
|
|
95
|
+
env: 'development',
|
|
96
|
+
token: undefined,
|
|
97
|
+
type: 'ChurchCenterOauth',
|
|
98
|
+
isAuthenticated: false,
|
|
99
|
+
isChurchCenterToken: true,
|
|
100
|
+
},
|
|
101
|
+
graph: 'churchcenter',
|
|
102
|
+
})
|
|
103
|
+
expect(uri.baseUrl).toBe('http://api.churchcenter.test')
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
})
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { useTheme as useNavigationTheme } from '@react-navigation/native'
|
|
2
|
-
import {
|
|
3
|
-
import React from 'react'
|
|
1
|
+
import { useNavigation, useTheme as useNavigationTheme, useRoute } from '@react-navigation/native'
|
|
2
|
+
import React, { useContext, useEffect, useState } from 'react'
|
|
4
3
|
import { StyleSheet, TextInput, View, ViewProps } from 'react-native'
|
|
5
|
-
import { IconButton } from '../../components'
|
|
4
|
+
import { IconButton, Text } from '../../components'
|
|
6
5
|
import { useTheme } from '../../hooks'
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
6
|
+
import { ConversationResource } from '../../types'
|
|
7
|
+
import { useMessageCreate } from '../../hooks/use_message_create'
|
|
8
|
+
import { ConversationScreenProps } from '../../screens/conversation_screen'
|
|
9
|
+
import { ChatContext } from '../../contexts/chat_context'
|
|
11
10
|
|
|
12
11
|
export const MessageForm = {
|
|
13
12
|
Root: MessageFormRoot,
|
|
@@ -26,51 +25,77 @@ const MessageFormContext = React.createContext({
|
|
|
26
25
|
setText: (_text: string) => {},
|
|
27
26
|
onSubmit: () => {},
|
|
28
27
|
disabled: false,
|
|
28
|
+
canGiphy: false,
|
|
29
|
+
usingGiphy: false,
|
|
30
|
+
setUsingGiphy: (_usingGiphy: boolean) => {},
|
|
29
31
|
})
|
|
30
32
|
|
|
31
33
|
function MessageFormRoot({ conversation, children }: MessagesFormRootProps) {
|
|
34
|
+
const { giphyApiKey } = useContext(ChatContext)
|
|
35
|
+
const canGiphy = !!giphyApiKey
|
|
32
36
|
const styles = useMessageFormStyles()
|
|
33
37
|
const [text, setText] = React.useState('')
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
return apiClient.chat.post<ApiResource<MessageResource>>({
|
|
45
|
-
url: `/me/conversations/${conversation.id}/messages`,
|
|
46
|
-
data: {
|
|
47
|
-
...requestParams.data,
|
|
48
|
-
data: {
|
|
49
|
-
type: 'Message',
|
|
50
|
-
attributes: { text },
|
|
51
|
-
},
|
|
52
|
-
fields: fieldsWithValueJoined,
|
|
53
|
-
},
|
|
54
|
-
})
|
|
55
|
-
},
|
|
56
|
-
onSuccess: (result: ApiResource<MessageResource>) => {
|
|
57
|
-
const updatedMessage = result.data
|
|
58
|
-
type QueryData = InfiniteData<ApiCollection<MessageResource>>
|
|
59
|
-
const queryKey = getMessagesQueryKey({ conversation_id: conversation.id })
|
|
60
|
-
|
|
38
|
+
const [usingGiphy, setUsingGiphy] = useState(false)
|
|
39
|
+
const navigation = useNavigation()
|
|
40
|
+
const route = useRoute() as ConversationScreenProps['route']
|
|
41
|
+
const { status, isPending, reset, mutate } = useMessageCreate({ conversationId: conversation.id })
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (canGiphy && !usingGiphy && text.startsWith('/giphy ')) {
|
|
45
|
+
setUsingGiphy(true)
|
|
61
46
|
setText('')
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
47
|
+
}
|
|
48
|
+
}, [canGiphy, text, usingGiphy])
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
switch (status) {
|
|
52
|
+
case 'success':
|
|
53
|
+
setText('')
|
|
54
|
+
reset()
|
|
55
|
+
break
|
|
56
|
+
}
|
|
57
|
+
}, [reset, status])
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (route.params.clear_input) {
|
|
61
|
+
setText('')
|
|
62
|
+
setUsingGiphy(false)
|
|
63
|
+
navigation.setParams({ ...route.params, clear_input: false })
|
|
64
|
+
}
|
|
65
|
+
}, [navigation, route.params])
|
|
66
|
+
|
|
67
|
+
const canSubmit = (() => {
|
|
68
|
+
if (isPending) return false
|
|
69
|
+
if (text.length > 0) return true
|
|
70
|
+
return false
|
|
71
|
+
})()
|
|
72
|
+
const disabled = !canSubmit
|
|
73
|
+
|
|
74
|
+
const handleSubmit = () => {
|
|
75
|
+
if (!canSubmit) return
|
|
76
|
+
|
|
77
|
+
if (canGiphy && usingGiphy) {
|
|
78
|
+
TextInput.State.blurTextInput(TextInput.State.currentlyFocusedInput())
|
|
79
|
+
navigation.navigate('SendGiphy', {
|
|
80
|
+
conversation_id: conversation.id,
|
|
81
|
+
search_term: text,
|
|
82
|
+
})
|
|
83
|
+
} else {
|
|
84
|
+
mutate({ text })
|
|
85
|
+
}
|
|
86
|
+
}
|
|
70
87
|
|
|
71
88
|
return (
|
|
72
89
|
<MessageFormContext.Provider
|
|
73
|
-
value={{
|
|
90
|
+
value={{
|
|
91
|
+
text,
|
|
92
|
+
setText,
|
|
93
|
+
onSubmit: handleSubmit,
|
|
94
|
+
disabled,
|
|
95
|
+
canGiphy,
|
|
96
|
+
usingGiphy,
|
|
97
|
+
setUsingGiphy,
|
|
98
|
+
}}
|
|
74
99
|
>
|
|
75
100
|
<View style={styles.textInputContainer}>{children}</View>
|
|
76
101
|
</MessageFormContext.Provider>
|
|
@@ -79,38 +104,51 @@ function MessageFormRoot({ conversation, children }: MessagesFormRootProps) {
|
|
|
79
104
|
|
|
80
105
|
function MessageFormInput() {
|
|
81
106
|
const styles = useMessageFormStyles()
|
|
82
|
-
const { text, setText, onSubmit } = React.useContext(MessageFormContext)
|
|
107
|
+
const { text, setText, onSubmit, usingGiphy } = React.useContext(MessageFormContext)
|
|
83
108
|
|
|
84
109
|
return (
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
110
|
+
<View style={styles.textInput}>
|
|
111
|
+
{usingGiphy ? (
|
|
112
|
+
<View style={styles.giphyBadge}>
|
|
113
|
+
<Text>/Giphy</Text>
|
|
114
|
+
</View>
|
|
115
|
+
) : null}
|
|
116
|
+
|
|
117
|
+
<TextInput
|
|
118
|
+
aria-disabled={true}
|
|
119
|
+
placeholder="Send a message"
|
|
120
|
+
onChangeText={setText}
|
|
121
|
+
value={text}
|
|
122
|
+
onSubmitEditing={onSubmit}
|
|
123
|
+
/>
|
|
124
|
+
</View>
|
|
93
125
|
)
|
|
94
126
|
}
|
|
95
127
|
|
|
96
128
|
function MessageFormSubmitBtn() {
|
|
97
129
|
const styles = useMessageFormStyles()
|
|
98
|
-
const { onSubmit, disabled } = React.useContext(MessageFormContext)
|
|
130
|
+
const { onSubmit, disabled, usingGiphy } = React.useContext(MessageFormContext)
|
|
99
131
|
|
|
100
132
|
return (
|
|
101
133
|
<IconButton
|
|
102
134
|
disabled={disabled}
|
|
103
|
-
accessibilityLabel=
|
|
135
|
+
accessibilityLabel={usingGiphy ? 'Search Giphy' : 'Send message'}
|
|
104
136
|
size="md"
|
|
105
137
|
appearance="neutral"
|
|
106
138
|
style={styles.textInputSend}
|
|
107
|
-
name={'general.upArrow'}
|
|
139
|
+
name={usingGiphy ? 'general.search' : 'general.upArrow'}
|
|
108
140
|
onPress={onSubmit}
|
|
109
141
|
/>
|
|
110
142
|
)
|
|
111
143
|
}
|
|
112
144
|
|
|
113
145
|
function MessageFormAttachmentPicker() {
|
|
146
|
+
const { usingGiphy } = React.useContext(MessageFormContext)
|
|
147
|
+
|
|
148
|
+
if (usingGiphy) {
|
|
149
|
+
return null
|
|
150
|
+
}
|
|
151
|
+
|
|
114
152
|
return (
|
|
115
153
|
<IconButton
|
|
116
154
|
accessibilityLabel="Shazam"
|
|
@@ -122,8 +160,32 @@ function MessageFormAttachmentPicker() {
|
|
|
122
160
|
}
|
|
123
161
|
|
|
124
162
|
function MessageFormCommands() {
|
|
163
|
+
const { canGiphy, usingGiphy, setUsingGiphy } = React.useContext(MessageFormContext)
|
|
164
|
+
|
|
165
|
+
if (!canGiphy) {
|
|
166
|
+
return null
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (usingGiphy) {
|
|
170
|
+
return (
|
|
171
|
+
<IconButton
|
|
172
|
+
accessibilityLabel="Exit Giphy Search"
|
|
173
|
+
size="md"
|
|
174
|
+
appearance="neutral"
|
|
175
|
+
name={'general.x'}
|
|
176
|
+
onPress={() => setUsingGiphy(false)}
|
|
177
|
+
/>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
125
181
|
return (
|
|
126
|
-
<IconButton
|
|
182
|
+
<IconButton
|
|
183
|
+
accessibilityLabel="Search Giphy"
|
|
184
|
+
size="md"
|
|
185
|
+
appearance="neutral"
|
|
186
|
+
name={'general.bolt'}
|
|
187
|
+
onPress={() => setUsingGiphy(true)}
|
|
188
|
+
/>
|
|
127
189
|
)
|
|
128
190
|
}
|
|
129
191
|
|
|
@@ -148,12 +210,19 @@ const useMessageFormStyles = () => {
|
|
|
148
210
|
paddingHorizontal: 20,
|
|
149
211
|
borderColor: theme.colors.fillColorNeutral050Base,
|
|
150
212
|
flex: 1,
|
|
213
|
+
flexDirection: 'row',
|
|
214
|
+
gap: 12,
|
|
215
|
+
},
|
|
216
|
+
giphyBadge: {
|
|
217
|
+
backgroundColor: theme.colors.fillColorNeutral050Base,
|
|
218
|
+
borderRadius: 24,
|
|
219
|
+
padding: 8,
|
|
220
|
+
paddingHorizontal: 12,
|
|
151
221
|
},
|
|
152
222
|
textInputSend: {
|
|
153
223
|
borderRadius: 24,
|
|
154
224
|
height: 36,
|
|
155
225
|
width: 36,
|
|
156
|
-
backgroundColor: theme.colors.fillColorNeutral040,
|
|
157
226
|
},
|
|
158
227
|
})
|
|
159
228
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { StyleSheet } from 'react-native'
|
|
3
|
+
import { Pressable, type PressableProps } from 'react-native-gesture-handler'
|
|
3
4
|
import { Icon, IconString, Spinner, Text } from '../display'
|
|
4
5
|
import { useCreateAndroidRippleColor, useTheme } from '../../hooks'
|
|
5
6
|
import { platformFontWeightMedium, platformPressedOpacityStyle } from '../../utils/styles'
|