@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,13 +1,17 @@
|
|
|
1
1
|
import React, { ReactNode, useCallback, useEffect, useRef, useState } from 'react'
|
|
2
|
-
import { Platform,
|
|
2
|
+
import { Platform, Pressable, StyleSheet, View, ViewStyle } from 'react-native'
|
|
3
3
|
import ReanimatedSwipeable, {
|
|
4
4
|
SwipeableMethods,
|
|
5
5
|
} from 'react-native-gesture-handler/ReanimatedSwipeable'
|
|
6
|
+
import { useConversationsContext } from '../../contexts/conversations_context'
|
|
6
7
|
import { useTheme } from '../../hooks'
|
|
7
|
-
import {
|
|
8
|
-
|
|
8
|
+
import {
|
|
9
|
+
useConversationsMarkRead,
|
|
10
|
+
useConversationsMute,
|
|
11
|
+
} from '../../hooks/use_conversations_actions'
|
|
9
12
|
import { ConversationResource } from '../../types'
|
|
10
|
-
import {
|
|
13
|
+
import { tokens } from '../../vendor/tapestry/tokens'
|
|
14
|
+
import { ActionToggleButton } from './action_toggle_button'
|
|
11
15
|
|
|
12
16
|
export function ConversationActions({
|
|
13
17
|
children,
|
|
@@ -22,7 +26,7 @@ export function ConversationActions({
|
|
|
22
26
|
}) {
|
|
23
27
|
const swipeableRef = useRef<SwipeableMethods>(null)
|
|
24
28
|
const styles = useStyles()
|
|
25
|
-
const { activeConversationId, setActiveConversationId } =
|
|
29
|
+
const { activeConversationId, setActiveConversationId } = useConversationsContext()
|
|
26
30
|
const [disabled, setDisabled] = useState(false)
|
|
27
31
|
const overshootLeft = Platform.OS === 'ios'
|
|
28
32
|
|
|
@@ -75,23 +79,45 @@ interface LeftActionsProps {
|
|
|
75
79
|
|
|
76
80
|
function LeftActions({ conversation, onClose }: LeftActionsProps) {
|
|
77
81
|
const styles = useStyles()
|
|
78
|
-
const
|
|
82
|
+
const emptyConversation = conversation.lastMessageCreatedAt === null
|
|
83
|
+
|
|
84
|
+
const muteToggleContent = {
|
|
85
|
+
true: { iconName: 'general.bell', label: 'Unmute' },
|
|
86
|
+
false: { iconName: 'general.bellMuted', label: 'Mute' },
|
|
87
|
+
} as const
|
|
88
|
+
|
|
89
|
+
const latestMessageUnreadToggleContent = {
|
|
90
|
+
true: { iconName: 'general.outlinedTextMessage', label: 'Mark read' },
|
|
91
|
+
false: { iconName: 'general.textMessageNotifications', label: 'Mark unread' },
|
|
92
|
+
} as const
|
|
93
|
+
const { muted, setMuted, isPending } = useConversationsMute({ conversation })
|
|
94
|
+
const { read, markRead, isPending: markReadPending } = useConversationsMarkRead({ conversation })
|
|
79
95
|
|
|
80
96
|
const handleMute = useCallback(() => {
|
|
81
97
|
setMuted(!muted)
|
|
82
98
|
onClose()
|
|
83
|
-
}, [muted, onClose])
|
|
99
|
+
}, [muted, onClose, setMuted])
|
|
100
|
+
|
|
101
|
+
const handleLatestMessageUnread = useCallback(() => {
|
|
102
|
+
markRead(!read)
|
|
103
|
+
onClose()
|
|
104
|
+
}, [read, onClose, markRead])
|
|
84
105
|
|
|
85
106
|
return (
|
|
86
107
|
<View style={styles.actionButtonContainer}>
|
|
87
108
|
<ActionToggleButton
|
|
88
|
-
loading={
|
|
109
|
+
loading={markReadPending}
|
|
110
|
+
disabled={emptyConversation}
|
|
111
|
+
toggled={!read}
|
|
112
|
+
onPress={handleLatestMessageUnread}
|
|
113
|
+
toggleContent={latestMessageUnreadToggleContent}
|
|
114
|
+
backgroundColor={tokens.fillColorInteractionSwipeDefault}
|
|
115
|
+
/>
|
|
116
|
+
<ActionToggleButton
|
|
117
|
+
loading={isPending}
|
|
89
118
|
toggled={muted}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
false: { iconName: 'general.bell', label: 'Unmute' },
|
|
93
|
-
}}
|
|
94
|
-
onPress={() => handleMute()}
|
|
119
|
+
onPress={handleMute}
|
|
120
|
+
toggleContent={muteToggleContent}
|
|
95
121
|
backgroundColor={tokens.fillColorInteractionSwipeSecondary}
|
|
96
122
|
/>
|
|
97
123
|
</View>
|
|
@@ -99,6 +125,7 @@ function LeftActions({ conversation, onClose }: LeftActionsProps) {
|
|
|
99
125
|
}
|
|
100
126
|
|
|
101
127
|
const ACTION_BUTTON_WIDTH = 120
|
|
128
|
+
const ACTION_BUTTON_COUNT = 2
|
|
102
129
|
|
|
103
130
|
const useStyles = () => {
|
|
104
131
|
const { colors } = useTheme()
|
|
@@ -109,7 +136,7 @@ const useStyles = () => {
|
|
|
109
136
|
actionButtonContainer: {
|
|
110
137
|
flexDirection: 'row',
|
|
111
138
|
alignItems: 'center',
|
|
112
|
-
width: ACTION_BUTTON_WIDTH,
|
|
139
|
+
width: ACTION_BUTTON_WIDTH * ACTION_BUTTON_COUNT,
|
|
113
140
|
alignContent: 'stretch',
|
|
114
141
|
},
|
|
115
142
|
swipeableContainer: {
|
|
@@ -2,71 +2,58 @@ import { useNavigation } from '@react-navigation/native'
|
|
|
2
2
|
import { FlashList } from '@shopify/flash-list'
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import { StyleSheet, View } from 'react-native'
|
|
5
|
+
import { useConversationsContext } from '../../contexts/conversations_context'
|
|
5
6
|
import { useTheme } from '../../hooks'
|
|
6
|
-
import { useConversationsJoltEvents } from '../../hooks/use_conversation_jolt_events'
|
|
7
|
-
import { useConversations } from '../../hooks/use_conversations'
|
|
8
7
|
import { Text } from '../display'
|
|
9
|
-
import { ConversationRequestArgs } from '../../utils/request/conversation'
|
|
10
8
|
import { ConversationPreview } from './conversation_preview'
|
|
11
|
-
import { ConversationActionsProvider } from '../../contexts/swipeable_active_conversation'
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
chat_group_graph_id?: string
|
|
20
|
-
ListHeaderComponent?: ListHeaderComponent
|
|
10
|
+
interface ConversationsProps {
|
|
11
|
+
ListHeaderComponent?:
|
|
12
|
+
| React.ComponentType<any>
|
|
13
|
+
| React.ReactElement<any, string | React.JSXElementConstructor<any>>
|
|
14
|
+
| null
|
|
15
|
+
| undefined
|
|
21
16
|
}
|
|
22
17
|
|
|
23
|
-
export const Conversations = ({
|
|
24
|
-
ListHeaderComponent,
|
|
25
|
-
filter,
|
|
26
|
-
chat_group_graph_id,
|
|
27
|
-
gids,
|
|
28
|
-
group_source_app_name,
|
|
29
|
-
}: ConversationsProps) => {
|
|
18
|
+
export const Conversations = ({ ListHeaderComponent }: ConversationsProps) => {
|
|
30
19
|
const styles = useStyles()
|
|
31
20
|
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
const {
|
|
22
|
+
conversations,
|
|
23
|
+
fetchNextPage,
|
|
24
|
+
refetch,
|
|
25
|
+
isRefetching,
|
|
26
|
+
isFetched,
|
|
27
|
+
args: { chat_group_graph_id },
|
|
28
|
+
} = useConversationsContext()
|
|
38
29
|
const navigation = useNavigation()
|
|
39
30
|
|
|
40
|
-
useConversationsJoltEvents()
|
|
41
|
-
|
|
42
31
|
const showBadges = !chat_group_graph_id
|
|
43
32
|
|
|
44
33
|
return (
|
|
45
|
-
<
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
</View>
|
|
69
|
-
</ConversationActionsProvider>
|
|
34
|
+
<View style={styles.container}>
|
|
35
|
+
<FlashList
|
|
36
|
+
data={conversations}
|
|
37
|
+
estimatedItemSize={97}
|
|
38
|
+
contentContainerStyle={styles.contentContainer}
|
|
39
|
+
onRefresh={refetch}
|
|
40
|
+
refreshing={!isFetched && isRefetching}
|
|
41
|
+
ListHeaderComponent={ListHeaderComponent}
|
|
42
|
+
ListEmptyComponent={
|
|
43
|
+
<View style={styles.listEmpty}>
|
|
44
|
+
<Text variant="secondary">No conversations found</Text>
|
|
45
|
+
</View>
|
|
46
|
+
}
|
|
47
|
+
renderItem={({ item }) => (
|
|
48
|
+
<ConversationPreview
|
|
49
|
+
conversation={item}
|
|
50
|
+
onPress={() => navigation.navigate('Conversation', { conversation_id: item.id })}
|
|
51
|
+
showBadges={showBadges}
|
|
52
|
+
/>
|
|
53
|
+
)}
|
|
54
|
+
onEndReached={() => fetchNextPage()}
|
|
55
|
+
/>
|
|
56
|
+
</View>
|
|
70
57
|
)
|
|
71
58
|
}
|
|
72
59
|
|
|
@@ -8,11 +8,13 @@ import { Text } from './text'
|
|
|
8
8
|
|
|
9
9
|
export const ActionButton = ({
|
|
10
10
|
visible = true,
|
|
11
|
+
disabled = false,
|
|
11
12
|
onPress,
|
|
12
13
|
title,
|
|
13
14
|
infoText,
|
|
14
15
|
}: {
|
|
15
16
|
visible?: boolean
|
|
17
|
+
disabled?: boolean
|
|
16
18
|
onPress: () => void
|
|
17
19
|
title: string
|
|
18
20
|
infoText?: string
|
|
@@ -32,11 +34,11 @@ export const ActionButton = ({
|
|
|
32
34
|
return (
|
|
33
35
|
<Animated.View style={styles.container}>
|
|
34
36
|
{Boolean(infoText) && (
|
|
35
|
-
<Text style={styles.infoText} variant="
|
|
37
|
+
<Text style={styles.infoText} variant="footnote">
|
|
36
38
|
{infoText}
|
|
37
39
|
</Text>
|
|
38
40
|
)}
|
|
39
|
-
<Button variant="fill" size="lg" onPress={onPress} title={title} />
|
|
41
|
+
<Button variant="fill" size="lg" onPress={onPress} title={title} disabled={disabled} />
|
|
40
42
|
</Animated.View>
|
|
41
43
|
)
|
|
42
44
|
}
|
|
@@ -56,7 +58,6 @@ const useStyles = () => {
|
|
|
56
58
|
},
|
|
57
59
|
infoText: {
|
|
58
60
|
textAlign: 'center',
|
|
59
|
-
color: colors.textColorDefaultSecondary,
|
|
60
61
|
},
|
|
61
62
|
})
|
|
62
63
|
}
|
|
@@ -3,6 +3,7 @@ import BannerPrimitive, {
|
|
|
3
3
|
type BannerStatusIconProps,
|
|
4
4
|
type BannerRootProps,
|
|
5
5
|
} from '../primitive/banner_primitive'
|
|
6
|
+
import { ViewStyle } from 'react-native'
|
|
6
7
|
|
|
7
8
|
type descriptionUnion = string | ReactElement | undefined
|
|
8
9
|
|
|
@@ -29,6 +30,10 @@ export interface BannerProps {
|
|
|
29
30
|
* Hides the status icon. By default, the status icon is shown.
|
|
30
31
|
*/
|
|
31
32
|
showIcon?: boolean
|
|
33
|
+
/**
|
|
34
|
+
* Adds a style to the banner.
|
|
35
|
+
*/
|
|
36
|
+
style?: ViewStyle
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
export function Banner({
|
|
@@ -37,12 +42,13 @@ export function Banner({
|
|
|
37
42
|
heading,
|
|
38
43
|
iconName,
|
|
39
44
|
showIcon = true,
|
|
45
|
+
style,
|
|
40
46
|
}: BannerProps) {
|
|
41
47
|
if (!description && !heading) return null
|
|
42
48
|
|
|
43
49
|
return (
|
|
44
50
|
<BannerPrimitive.Root appearance={appearance}>
|
|
45
|
-
<BannerPrimitive.StaticLayout>
|
|
51
|
+
<BannerPrimitive.StaticLayout style={style}>
|
|
46
52
|
{showIcon && <BannerPrimitive.StatusIcon iconName={iconName} />}
|
|
47
53
|
<BannerPrimitive.Content>
|
|
48
54
|
{Boolean(heading) && <BannerPrimitive.Heading>{heading}</BannerPrimitive.Heading>}
|
|
@@ -20,6 +20,7 @@ export function BannerCollapsible({
|
|
|
20
20
|
heading,
|
|
21
21
|
iconName,
|
|
22
22
|
showIcon = true,
|
|
23
|
+
style,
|
|
23
24
|
}: BannerCollapsibleProps) {
|
|
24
25
|
const [expanded, setExpanded] = React.useState(false)
|
|
25
26
|
|
|
@@ -31,7 +32,11 @@ export function BannerCollapsible({
|
|
|
31
32
|
|
|
32
33
|
return (
|
|
33
34
|
<BannerPrimitive.Root appearance={appearance}>
|
|
34
|
-
<BannerPrimitive.CollapsibleLayout
|
|
35
|
+
<BannerPrimitive.CollapsibleLayout
|
|
36
|
+
onPress={toggleCollapsible}
|
|
37
|
+
expanded={expanded}
|
|
38
|
+
style={style}
|
|
39
|
+
>
|
|
35
40
|
{showIcon && <BannerPrimitive.StatusIcon iconName={iconName} />}
|
|
36
41
|
<BannerPrimitive.Content>
|
|
37
42
|
{Boolean(heading) && <BannerPrimitive.Heading>{heading}</BannerPrimitive.Heading>}
|
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import { MemberResource } from '../../types'
|
|
3
3
|
import { BannerCollapsible } from './banner_collapsible'
|
|
4
4
|
import BannerPrimitive from '../primitive/banner_primitive'
|
|
5
|
-
import { View, StyleSheet } from 'react-native'
|
|
5
|
+
import { View, StyleSheet, type ViewStyle } from 'react-native'
|
|
6
6
|
import { Avatar } from './avatar'
|
|
7
7
|
import { platformFontWeightMedium, pluralize } from '../../utils'
|
|
8
8
|
import { Text } from './text'
|
|
@@ -13,14 +13,20 @@ import { Text } from './text'
|
|
|
13
13
|
|
|
14
14
|
interface ChildNoticeProps {
|
|
15
15
|
childMembers: MemberResource[]
|
|
16
|
+
style?: ViewStyle
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export function ChildNotice({ childMembers }: ChildNoticeProps) {
|
|
19
|
+
export function ChildNotice({ childMembers, style }: ChildNoticeProps) {
|
|
19
20
|
const styles = useStyles()
|
|
20
21
|
const heading = `${pluralize(childMembers.length, 'member')} under age 13`
|
|
21
22
|
|
|
22
23
|
return (
|
|
23
|
-
<BannerCollapsible
|
|
24
|
+
<BannerCollapsible
|
|
25
|
+
appearance="warning"
|
|
26
|
+
iconName="general.shieldExclamation"
|
|
27
|
+
heading={heading}
|
|
28
|
+
style={style}
|
|
29
|
+
>
|
|
24
30
|
<BannerPrimitive.Text>
|
|
25
31
|
Under age members cannot chat. They won't see conversations or notifications.
|
|
26
32
|
</BannerPrimitive.Text>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { StyleSheet, View } from 'react-native'
|
|
2
|
+
import { StyleSheet, View, type ViewStyle } from 'react-native'
|
|
3
3
|
import { platformFontWeightMedium } from '../../utils/styles'
|
|
4
4
|
import { MemberResource } from '../../types'
|
|
5
5
|
import { Avatar } from './avatar'
|
|
@@ -13,13 +13,14 @@ import { space } from '../../utils'
|
|
|
13
13
|
|
|
14
14
|
interface PersonProps {
|
|
15
15
|
person: MemberResource
|
|
16
|
+
style?: ViewStyle
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export function Person({ person }: PersonProps) {
|
|
19
|
+
export function Person({ person, style }: PersonProps) {
|
|
19
20
|
const styles = useStyles()
|
|
20
21
|
|
|
21
22
|
return (
|
|
22
|
-
<View style={styles.wrapper}>
|
|
23
|
+
<View style={[styles.wrapper, style]}>
|
|
23
24
|
<Avatar sourceUri={person.avatar} />
|
|
24
25
|
<View style={styles.content}>
|
|
25
26
|
<Text style={styles.name}>{person.name}</Text>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { createContext, FC, ReactNode, useContext } from 'react'
|
|
2
|
-
import { Pressable, StyleSheet, View } from 'react-native'
|
|
2
|
+
import { Pressable, StyleSheet, View, ViewStyle } from 'react-native'
|
|
3
3
|
import {
|
|
4
4
|
useStatusColorAppearanceMap,
|
|
5
5
|
type StatusAppearanceUnion,
|
|
@@ -94,13 +94,14 @@ BannerRoot.displayName = 'Banner.Root'
|
|
|
94
94
|
|
|
95
95
|
interface BannerStaticLayoutProps {
|
|
96
96
|
children: ReactNode
|
|
97
|
+
style?: ViewStyle
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
function BannerStaticLayout({ children }: BannerStaticLayoutProps) {
|
|
100
|
+
function BannerStaticLayout({ children, style }: BannerStaticLayoutProps) {
|
|
100
101
|
const { appearance } = useBannerContext()
|
|
101
102
|
const styles = useStyles({ appearance })
|
|
102
103
|
|
|
103
|
-
return <View style={styles.staticLayout}>{children}</View>
|
|
104
|
+
return <View style={[styles.staticLayout, style]}>{children}</View>
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
BannerStaticLayout.displayName = 'Banner.StaticLayout'
|
|
@@ -113,9 +114,15 @@ interface BannerCollapsibleLayoutProps {
|
|
|
113
114
|
children: ReactNode
|
|
114
115
|
expanded?: boolean
|
|
115
116
|
onPress?: () => void
|
|
117
|
+
style?: ViewStyle
|
|
116
118
|
}
|
|
117
119
|
|
|
118
|
-
function BannerCollapsibleLayout({
|
|
120
|
+
function BannerCollapsibleLayout({
|
|
121
|
+
children,
|
|
122
|
+
expanded,
|
|
123
|
+
onPress,
|
|
124
|
+
style,
|
|
125
|
+
}: BannerCollapsibleLayoutProps) {
|
|
119
126
|
const { appearance = 'neutral' } = useBannerContext()
|
|
120
127
|
const styles = useStyles({ appearance })
|
|
121
128
|
const iconName = expanded ? 'general.upCaret' : 'general.downCaret'
|
|
@@ -127,7 +134,7 @@ function BannerCollapsibleLayout({ children, expanded, onPress }: BannerCollapsi
|
|
|
127
134
|
return (
|
|
128
135
|
<Pressable
|
|
129
136
|
onPress={onPress}
|
|
130
|
-
style={({ pressed }) => [styles.staticLayout, pressed && platformPressedOpacityStyle]}
|
|
137
|
+
style={({ pressed }) => [styles.staticLayout, pressed && platformPressedOpacityStyle, style]}
|
|
131
138
|
android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}
|
|
132
139
|
accessibilityState={{ expanded }}
|
|
133
140
|
accessibilityRole="button"
|
|
@@ -271,7 +278,6 @@ const useStyles = ({ appearance = 'neutral' }: Styles = {}) => {
|
|
|
271
278
|
padding: space(1.5),
|
|
272
279
|
gap: space(1),
|
|
273
280
|
borderRadius: tokens.borderRadiusMd,
|
|
274
|
-
flex: 1,
|
|
275
281
|
},
|
|
276
282
|
content: {
|
|
277
283
|
gap: space(0.5),
|
|
@@ -17,7 +17,7 @@ const defaultQueryFn = ({ queryKey }: { queryKey: QueryKey }) => {
|
|
|
17
17
|
return apiClient[app].get({ url, data, headers })
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export const
|
|
20
|
+
export const chatQueryClient = new QueryClient({
|
|
21
21
|
defaultOptions: {
|
|
22
22
|
queries: {
|
|
23
23
|
queryFn: defaultQueryFn,
|
|
@@ -35,10 +35,10 @@ export function ApiProvider({ children }: ViewProps) {
|
|
|
35
35
|
useEffect(() => {
|
|
36
36
|
if (!sessionChanged) return
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
chatQueryClient.clear()
|
|
39
39
|
}, [sessionChanged])
|
|
40
40
|
|
|
41
|
-
return <QueryClientProvider client={
|
|
41
|
+
return <QueryClientProvider client={chatQueryClient}>{children}</QueryClientProvider>
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function useSessionChanged(value: Pick<ChatContextValue, 'token' | 'env'>): boolean {
|
|
@@ -6,11 +6,12 @@ import { ENV, PartialToken, ResponseError, Session } from '../utils'
|
|
|
6
6
|
import { ChatTheme, defaultTheme, DefaultTheme } from '../utils/theme'
|
|
7
7
|
|
|
8
8
|
export type ChatContextValue = {
|
|
9
|
-
token?: PartialToken
|
|
10
|
-
onUnauthorizedResponse: (_response: ResponseError) => void
|
|
11
|
-
theme: ChatTheme
|
|
12
9
|
env?: ENV
|
|
10
|
+
giphyApiKey?: string
|
|
11
|
+
onUnauthorizedResponse: (_response: ResponseError) => void
|
|
13
12
|
session: Session
|
|
13
|
+
theme: ChatTheme
|
|
14
|
+
token?: PartialToken
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export interface ChatProviderProps extends Omit<ChatContextValue, 'client' | 'theme' | 'session'> {
|
|
@@ -18,15 +19,16 @@ export interface ChatProviderProps extends Omit<ChatContextValue, 'client' | 'th
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export const ChatContext = createContext<ChatContextValue>({
|
|
21
|
-
theme: defaultTheme('light'),
|
|
22
|
-
token: undefined,
|
|
23
22
|
env: undefined,
|
|
23
|
+
giphyApiKey: undefined,
|
|
24
24
|
onUnauthorizedResponse: () => {},
|
|
25
25
|
session: new Session(),
|
|
26
|
+
theme: defaultTheme('light'),
|
|
27
|
+
token: undefined,
|
|
26
28
|
})
|
|
27
29
|
|
|
28
30
|
export function ChatProvider({ children, value }: { children: any; value: ChatProviderProps }) {
|
|
29
|
-
const { env, token, onUnauthorizedResponse } = value
|
|
31
|
+
const { env, token, onUnauthorizedResponse, giphyApiKey } = value
|
|
30
32
|
const theme = useCreateChatTheme(value.theme || {})
|
|
31
33
|
const session = useMemo(() => new Session({ token, env }), [env, token])
|
|
32
34
|
|
|
@@ -36,6 +38,7 @@ export function ChatProvider({ children, value }: { children: any; value: ChatPr
|
|
|
36
38
|
onUnauthorizedResponse,
|
|
37
39
|
session,
|
|
38
40
|
theme,
|
|
41
|
+
giphyApiKey,
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
return <ChatContext.Provider value={contextValue}>{children}</ChatContext.Provider>
|
|
@@ -46,6 +49,10 @@ export interface CreateChatThemeProps {
|
|
|
46
49
|
colorScheme?: ColorSchemeName
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
export const useChatContext = () => {
|
|
53
|
+
return React.useContext(ChatContext)
|
|
54
|
+
}
|
|
55
|
+
|
|
49
56
|
export const useCreateChatTheme = ({
|
|
50
57
|
theme: customTheme = {},
|
|
51
58
|
colorScheme: appColorScheme,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { createContext, PropsWithChildren, useContext, useMemo, useState } from 'react'
|
|
2
|
+
import { ConversationFiltersParams } from '../screens/conversation_filters/screen_props'
|
|
3
|
+
import { useConversations, UseConversationsValue } from '../hooks/use_conversations'
|
|
4
|
+
import {
|
|
5
|
+
FetchNextPageOptions,
|
|
6
|
+
InfiniteQueryObserverResult,
|
|
7
|
+
InfiniteData,
|
|
8
|
+
} from '@tanstack/react-query'
|
|
9
|
+
import { ApiCollection, ConversationResource } from '../types'
|
|
10
|
+
import { useConversationsJoltEvents } from '../hooks/use_conversations_jolt_events'
|
|
11
|
+
|
|
12
|
+
interface ConversationsContextValue extends UseConversationsValue {
|
|
13
|
+
activeConversationId?: number
|
|
14
|
+
setActiveConversationId: (_id: number) => void
|
|
15
|
+
args: ConversationFiltersParams
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const defaultQueryValue: UseConversationsValue = {
|
|
19
|
+
conversations: [],
|
|
20
|
+
refetch: () => Promise.resolve(null),
|
|
21
|
+
error: null,
|
|
22
|
+
isError: false,
|
|
23
|
+
fetchNextPage,
|
|
24
|
+
hasNextPage: false,
|
|
25
|
+
isFetching: false,
|
|
26
|
+
isFetched: false,
|
|
27
|
+
isRefetching: false,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const ConversationsContext = createContext<ConversationsContextValue>({
|
|
31
|
+
args: {},
|
|
32
|
+
activeConversationId: undefined,
|
|
33
|
+
setActiveConversationId: () => {},
|
|
34
|
+
...defaultQueryValue,
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export const ConversationsContextProvider = ({
|
|
38
|
+
children,
|
|
39
|
+
args,
|
|
40
|
+
}: PropsWithChildren<{ args: ConversationFiltersParams }>) => {
|
|
41
|
+
const [activeConversationId, setActiveConversationId] = useState<number | undefined>()
|
|
42
|
+
const { chat_group_graph_id, group_source_app_name } = args
|
|
43
|
+
|
|
44
|
+
const query = useConversations({ chat_group_graph_id, group_source_app_name })
|
|
45
|
+
|
|
46
|
+
const value = useMemo(
|
|
47
|
+
() => ({
|
|
48
|
+
args,
|
|
49
|
+
activeConversationId,
|
|
50
|
+
setActiveConversationId,
|
|
51
|
+
...query,
|
|
52
|
+
}),
|
|
53
|
+
[args, activeConversationId, query]
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
useConversationsJoltEvents(args)
|
|
57
|
+
|
|
58
|
+
return <ConversationsContext.Provider value={value}>{children}</ConversationsContext.Provider>
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function fetchNextPage(
|
|
62
|
+
_options?: FetchNextPageOptions
|
|
63
|
+
): Promise<
|
|
64
|
+
InfiniteQueryObserverResult<InfiniteData<ApiCollection<ConversationResource>, unknown>, Response>
|
|
65
|
+
> {
|
|
66
|
+
throw new Error('Function not implemented.')
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const useConversationsContext = () => useContext(ConversationsContext)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { MemberBadge, MemberResource } from '../../types'
|
|
2
|
+
import { GroupsGroupMemberResource } from '../../types/resources/groups/groups_member_resource_with_person'
|
|
3
|
+
import { useApiPaginator } from '../use_api'
|
|
4
|
+
import { useCurrentPerson } from '../use_current_person'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This is specifically for the new conversation screen because we assign
|
|
8
|
+
* the "Conversation owner" badge to the current person.
|
|
9
|
+
*/
|
|
10
|
+
export function useGroupMembersForNewConversation({ id }: { id: number }) {
|
|
11
|
+
const currentPerson = useCurrentPerson()
|
|
12
|
+
const response = useApiPaginator<GroupsGroupMemberResource>({
|
|
13
|
+
url: `/me/groups/${id}/memberships`,
|
|
14
|
+
data: {
|
|
15
|
+
perPage: 100,
|
|
16
|
+
include: ['person'],
|
|
17
|
+
fields: {
|
|
18
|
+
Membership: ['person, role'],
|
|
19
|
+
Person: ['avatar_url', 'name', 'first_name', 'last_name', 'child'],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
app: 'groups',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const { data: memberships = [] } = response
|
|
26
|
+
const members: MemberResource[] = memberships.map(membership => {
|
|
27
|
+
const { person } = membership
|
|
28
|
+
return {
|
|
29
|
+
type: 'Member',
|
|
30
|
+
avatar: person.avatarUrl,
|
|
31
|
+
badges: buildBadges(membership, currentPerson.id),
|
|
32
|
+
child: person.child,
|
|
33
|
+
id: +person.id,
|
|
34
|
+
name: `${person.firstName} ${person.lastName}`,
|
|
35
|
+
source: [],
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
const adultMembers = members.filter(member => !member.child)
|
|
39
|
+
const childMembers = members.filter(member => member.child)
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
...response,
|
|
43
|
+
data: members,
|
|
44
|
+
adultMembers,
|
|
45
|
+
childMembers,
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function buildBadges(
|
|
50
|
+
membership: GroupsGroupMemberResource,
|
|
51
|
+
currentPersonId: number
|
|
52
|
+
): MemberBadge[] {
|
|
53
|
+
const { person } = membership
|
|
54
|
+
const badges = []
|
|
55
|
+
if (membership.role === 'leader') {
|
|
56
|
+
badges.push({ title: 'Leader' })
|
|
57
|
+
}
|
|
58
|
+
if (person.id === currentPersonId) {
|
|
59
|
+
badges.push({ title: 'Conversation owner' })
|
|
60
|
+
}
|
|
61
|
+
return badges
|
|
62
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useMutation } from '@tanstack/react-query'
|
|
2
|
+
import { ApiResource, ConversationResource, ResourceObject } from '../../types'
|
|
3
|
+
import { useApiClient } from '../use_api_client'
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
groupId: number
|
|
7
|
+
title?: string
|
|
8
|
+
onSuccess: (conversationId: number) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function useGroupsConversationCreate({ groupId, title, onSuccess }: Props) {
|
|
12
|
+
const apiClient = useApiClient()
|
|
13
|
+
return useMutation({
|
|
14
|
+
throwOnError: true,
|
|
15
|
+
onSuccess: result => {
|
|
16
|
+
onSuccess && onSuccess(result.data.id)
|
|
17
|
+
},
|
|
18
|
+
mutationFn: () =>
|
|
19
|
+
apiClient.groups
|
|
20
|
+
.post<ApiResource<ChatConversationPayload>>({
|
|
21
|
+
url: `/me/groups/${groupId}/chat_conversation_payload`,
|
|
22
|
+
data: {
|
|
23
|
+
data: {
|
|
24
|
+
type: '',
|
|
25
|
+
attributes: {
|
|
26
|
+
title,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
.then(res => res.data.value)
|
|
32
|
+
.then(payload =>
|
|
33
|
+
apiClient.chat.post<ApiResource<ConversationResource>>({
|
|
34
|
+
url: '/me/conversations',
|
|
35
|
+
data: {
|
|
36
|
+
data: {
|
|
37
|
+
type: 'Conversation',
|
|
38
|
+
attributes: {
|
|
39
|
+
payload,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
),
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface ChatConversationPayload extends ResourceObject {
|
|
49
|
+
value: string
|
|
50
|
+
}
|