@planningcenter/chat-react-native 4.7.1-rc.0 → 4.8.0-qa-staging.1
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/conversations/app_update_banner.d.ts +2 -0
- package/build/components/conversations/app_update_banner.d.ts.map +1 -0
- package/build/components/conversations/app_update_banner.js +52 -0
- package/build/components/conversations/app_update_banner.js.map +1 -0
- package/build/components/conversations/conversation_actions.d.ts.map +1 -1
- package/build/components/conversations/conversation_actions.js +333 -193
- package/build/components/conversations/conversation_actions.js.map +1 -1
- package/build/components/conversations/conversation_preview.d.ts.map +1 -1
- package/build/components/conversations/conversation_preview.js +106 -91
- package/build/components/conversations/conversation_preview.js.map +1 -1
- package/build/components/conversations/conversations.d.ts.map +1 -1
- package/build/components/conversations/conversations.js +63 -56
- package/build/components/conversations/conversations.js.map +1 -1
- package/build/components/conversations/conversations_blank_state.d.ts +2 -1
- package/build/components/conversations/conversations_blank_state.d.ts.map +1 -1
- package/build/components/conversations/conversations_blank_state.js +71 -39
- package/build/components/conversations/conversations_blank_state.js.map +1 -1
- package/build/components/conversations/hidden_indicator.d.ts +4 -0
- package/build/components/conversations/hidden_indicator.d.ts.map +1 -0
- package/build/components/conversations/hidden_indicator.js +52 -0
- package/build/components/conversations/hidden_indicator.js.map +1 -0
- package/build/components/conversations/hidden_results_footer.d.ts +2 -0
- package/build/components/conversations/hidden_results_footer.d.ts.map +1 -0
- package/build/components/conversations/hidden_results_footer.js +34 -0
- package/build/components/conversations/hidden_results_footer.js.map +1 -0
- package/build/components/display/toast.d.ts +3 -0
- package/build/components/display/toast.d.ts.map +1 -0
- package/build/components/display/toast.js +224 -0
- package/build/components/display/toast.js.map +1 -0
- package/build/components/group_conversation_list.d.ts.map +1 -1
- package/build/components/group_conversation_list.js +1 -0
- package/build/components/group_conversation_list.js.map +1 -1
- package/build/components/primitive/banner_primitive.js +7 -3
- package/build/components/primitive/banner_primitive.js.map +1 -1
- package/build/contexts/api_provider.d.ts.map +1 -1
- package/build/contexts/api_provider.js +2 -0
- package/build/contexts/api_provider.js.map +1 -1
- package/build/contexts/chat_context.d.ts +0 -2
- package/build/contexts/chat_context.d.ts.map +1 -1
- package/build/contexts/chat_context.js +16 -93
- package/build/contexts/chat_context.js.map +1 -1
- package/build/contexts/conversations_context.d.ts +3 -1
- package/build/contexts/conversations_context.d.ts.map +1 -1
- package/build/contexts/conversations_context.js +39 -31
- package/build/contexts/conversations_context.js.map +1 -1
- package/build/contexts/session_context.d.ts.map +1 -1
- package/build/contexts/session_context.js +3 -0
- package/build/contexts/session_context.js.map +1 -1
- package/build/hooks/groups/use_group_chat_conversation_payload.d.ts +11 -1
- package/build/hooks/groups/use_group_chat_conversation_payload.d.ts.map +1 -1
- package/build/hooks/groups/use_group_chat_conversation_payload.js +92 -47
- package/build/hooks/groups/use_group_chat_conversation_payload.js.map +1 -1
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +33 -25
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -1
- package/build/hooks/groups/use_group_members_for_new_conversation.js +125 -110
- package/build/hooks/groups/use_group_members_for_new_conversation.js.map +1 -1
- package/build/hooks/groups/use_groups_conversation_create.d.ts.map +1 -1
- package/build/hooks/groups/use_groups_conversation_create.js +39 -31
- package/build/hooks/groups/use_groups_conversation_create.js.map +1 -1
- package/build/hooks/groups/use_groups_proxy.d.ts +2 -0
- package/build/hooks/groups/use_groups_proxy.d.ts.map +1 -0
- package/build/hooks/groups/use_groups_proxy.js +18 -0
- package/build/hooks/groups/use_groups_proxy.js.map +1 -0
- package/build/hooks/use_api.d.ts +6 -0
- package/build/hooks/use_api.d.ts.map +1 -1
- package/build/hooks/use_api.js +8 -5
- package/build/hooks/use_api.js.map +1 -1
- package/build/hooks/use_clear_conversation_filters.d.ts.map +1 -1
- package/build/hooks/use_clear_conversation_filters.js +1 -0
- package/build/hooks/use_clear_conversation_filters.js.map +1 -1
- package/build/hooks/use_conversation.d.ts.map +1 -1
- package/build/hooks/use_conversation.js +1 -1
- package/build/hooks/use_conversation.js.map +1 -1
- package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversation_jolt_events.js +3 -2
- package/build/hooks/use_conversation_jolt_events.js.map +1 -1
- package/build/hooks/use_conversations_actions.d.ts +9 -9
- package/build/hooks/use_conversations_actions.d.ts.map +1 -1
- package/build/hooks/use_conversations_actions.js +12 -7
- package/build/hooks/use_conversations_actions.js.map +1 -1
- package/build/hooks/use_conversations_cache.d.ts +1 -3
- package/build/hooks/use_conversations_cache.d.ts.map +1 -1
- package/build/hooks/use_conversations_cache.js +79 -124
- package/build/hooks/use_conversations_cache.js.map +1 -1
- package/build/hooks/use_conversations_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversations_jolt_events.js +47 -20
- package/build/hooks/use_conversations_jolt_events.js.map +1 -1
- package/build/hooks/use_features.d.ts +2 -0
- package/build/hooks/use_features.d.ts.map +1 -1
- package/build/hooks/use_features.js +3 -1
- package/build/hooks/use_features.js.map +1 -1
- package/build/hooks/use_groups.d.ts +6 -0
- package/build/hooks/use_groups.d.ts.map +1 -1
- package/build/hooks/use_groups_groups.d.ts +6 -0
- package/build/hooks/use_groups_groups.d.ts.map +1 -1
- package/build/hooks/use_groups_groups.js +25 -9
- package/build/hooks/use_groups_groups.js.map +1 -1
- package/build/hooks/use_hidden_conversations_count.d.ts +2 -0
- package/build/hooks/use_hidden_conversations_count.d.ts.map +1 -0
- package/build/hooks/use_hidden_conversations_count.js +32 -0
- package/build/hooks/use_hidden_conversations_count.js.map +1 -0
- package/build/hooks/use_hide_conversation.d.ts +108 -0
- package/build/hooks/use_hide_conversation.d.ts.map +1 -0
- package/build/hooks/use_hide_conversation.js +243 -0
- package/build/hooks/use_hide_conversation.js.map +1 -0
- package/build/hooks/use_hide_conversations_enabled.d.ts +2 -0
- package/build/hooks/use_hide_conversations_enabled.d.ts.map +1 -0
- package/build/hooks/use_hide_conversations_enabled.js +18 -0
- package/build/hooks/use_hide_conversations_enabled.js.map +1 -0
- package/build/hooks/use_mark_latest_message_read.d.ts.map +1 -1
- package/build/hooks/use_mark_latest_message_read.js +5 -4
- package/build/hooks/use_mark_latest_message_read.js.map +1 -1
- package/build/hooks/use_new_conversation_from_filter.d.ts.map +1 -1
- package/build/hooks/use_new_conversation_from_filter.js +11 -1
- package/build/hooks/use_new_conversation_from_filter.js.map +1 -1
- package/build/hooks/use_product_analytics.d.ts.map +1 -1
- package/build/hooks/use_product_analytics.js +93 -75
- package/build/hooks/use_product_analytics.js.map +1 -1
- package/build/hooks/use_teams.d.ts +6 -0
- package/build/hooks/use_teams.d.ts.map +1 -1
- package/build/navigation/index.d.ts +5 -0
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +5 -0
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_actions_screen.d.ts +7 -0
- package/build/screens/conversation_actions_screen.d.ts.map +1 -0
- package/build/screens/conversation_actions_screen.js +89 -0
- package/build/screens/conversation_actions_screen.js.map +1 -0
- package/build/screens/conversation_details_screen.d.ts.map +1 -1
- package/build/screens/conversation_details_screen.js +460 -394
- package/build/screens/conversation_details_screen.js.map +1 -1
- package/build/screens/conversation_filters/components/conversation_filters.d.ts.map +1 -1
- package/build/screens/conversation_filters/components/conversation_filters.js +53 -12
- package/build/screens/conversation_filters/components/conversation_filters.js.map +1 -1
- package/build/screens/conversation_filters/components/rows.d.ts +6 -3
- package/build/screens/conversation_filters/components/rows.d.ts.map +1 -1
- package/build/screens/conversation_filters/components/rows.js +99 -62
- package/build/screens/conversation_filters/components/rows.js.map +1 -1
- package/build/screens/conversation_filters/context/conversation_filter_context.d.ts.map +1 -1
- package/build/screens/conversation_filters/context/conversation_filter_context.js +4 -0
- package/build/screens/conversation_filters/context/conversation_filter_context.js.map +1 -1
- package/build/screens/conversation_filters/filter_types.d.ts +1 -0
- package/build/screens/conversation_filters/filter_types.d.ts.map +1 -1
- package/build/screens/conversation_filters/filter_types.js +1 -0
- package/build/screens/conversation_filters/filter_types.js.map +1 -1
- package/build/screens/conversation_filters/hooks/filters.d.ts +12 -0
- package/build/screens/conversation_filters/hooks/filters.d.ts.map +1 -1
- package/build/screens/conversation_filters/screen_props.d.ts +1 -0
- package/build/screens/conversation_filters/screen_props.d.ts.map +1 -1
- package/build/screens/conversation_filters/screen_props.js.map +1 -1
- package/build/screens/conversation_new/components/groups_form.d.ts.map +1 -1
- package/build/screens/conversation_new/components/groups_form.js +96 -93
- package/build/screens/conversation_new/components/groups_form.js.map +1 -1
- package/build/screens/conversations/components/filter_dropdown_list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/filter_dropdown_list_header_component.js +138 -126
- package/build/screens/conversations/components/filter_dropdown_list_header_component.js.map +1 -1
- package/build/screens/conversations/components/list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/list_header_component.js +95 -90
- package/build/screens/conversations/components/list_header_component.js.map +1 -1
- package/build/screens/conversations/components/search_list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/search_list_header_component.js +100 -95
- package/build/screens/conversations/components/search_list_header_component.js.map +1 -1
- package/build/screens/conversations/conversations_screen.d.ts +1 -0
- package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations/conversations_screen.js +47 -21
- package/build/screens/conversations/conversations_screen.js.map +1 -1
- package/build/screens/get_help_screen.d.ts.map +1 -1
- package/build/screens/get_help_screen.js +4 -20
- package/build/screens/get_help_screen.js.map +1 -1
- package/build/screens/index.d.ts +1 -0
- package/build/screens/index.d.ts.map +1 -1
- package/build/screens/index.js +1 -0
- package/build/screens/index.js.map +1 -1
- package/build/types/jolt_events/index.d.ts +2 -0
- package/build/types/jolt_events/index.d.ts.map +1 -1
- package/build/types/jolt_events/index.js.map +1 -1
- package/build/types/jolt_events/person_events.d.ts +9 -0
- package/build/types/jolt_events/person_events.d.ts.map +1 -0
- package/build/types/jolt_events/person_events.js +2 -0
- package/build/types/jolt_events/person_events.js.map +1 -0
- package/build/types/resources/conversation_membership.d.ts +1 -0
- package/build/types/resources/conversation_membership.d.ts.map +1 -1
- package/build/types/resources/conversation_membership.js.map +1 -1
- package/build/types/resources/groups/groups_group_resource.d.ts +1 -1
- package/build/types/resources/groups/groups_group_resource.d.ts.map +1 -1
- package/build/types/resources/groups/groups_group_resource.js.map +1 -1
- package/build/types/resources/groups/groups_membership_resource.d.ts +11 -0
- package/build/types/resources/groups/groups_membership_resource.d.ts.map +1 -0
- package/build/types/resources/groups/groups_membership_resource.js +2 -0
- package/build/types/resources/groups/groups_membership_resource.js.map +1 -0
- package/build/types/resources/groups/index.d.ts +1 -0
- package/build/types/resources/groups/index.d.ts.map +1 -1
- package/build/types/resources/groups/index.js +1 -0
- package/build/types/resources/groups/index.js.map +1 -1
- package/build/utils/jolt/parse_stream_user_event_type.d.ts +3 -0
- package/build/utils/jolt/parse_stream_user_event_type.d.ts.map +1 -0
- package/build/utils/jolt/parse_stream_user_event_type.js +9 -0
- package/build/utils/jolt/parse_stream_user_event_type.js.map +1 -0
- package/build/utils/native_adapters/configuration.d.ts +3 -0
- package/build/utils/native_adapters/configuration.d.ts.map +1 -1
- package/build/utils/native_adapters/configuration.js +3 -0
- package/build/utils/native_adapters/configuration.js.map +1 -1
- package/build/utils/native_adapters/index.d.ts +1 -0
- package/build/utils/native_adapters/index.d.ts.map +1 -1
- package/build/utils/native_adapters/index.js +1 -0
- package/build/utils/native_adapters/index.js.map +1 -1
- package/build/utils/native_adapters/linking.d.ts.map +1 -1
- package/build/utils/native_adapters/linking.js +48 -2
- package/build/utils/native_adapters/linking.js.map +1 -1
- package/build/utils/native_adapters/updates.d.ts +11 -0
- package/build/utils/native_adapters/updates.d.ts.map +1 -0
- package/build/utils/native_adapters/updates.js +8 -0
- package/build/utils/native_adapters/updates.js.map +1 -0
- package/build/utils/product_analytics_token.d.ts +12 -0
- package/build/utils/product_analytics_token.d.ts.map +1 -0
- package/build/utils/product_analytics_token.js +84 -0
- package/build/utils/product_analytics_token.js.map +1 -0
- package/build/utils/request/conversation.d.ts +3 -1
- package/build/utils/request/conversation.d.ts.map +1 -1
- package/build/utils/request/conversation.js +4 -0
- package/build/utils/request/conversation.js.map +1 -1
- package/build/utils/throttled_refresh.d.ts +7 -0
- package/build/utils/throttled_refresh.d.ts.map +1 -0
- package/build/utils/throttled_refresh.js +42 -0
- package/build/utils/throttled_refresh.js.map +1 -0
- package/build/utils/toast_store.d.ts +21 -0
- package/build/utils/toast_store.d.ts.map +1 -0
- package/build/utils/toast_store.js +27 -0
- package/build/utils/toast_store.js.map +1 -0
- package/build/vendor/font_awesome_pro_solid_icons.d.ts +1 -0
- package/build/vendor/font_awesome_pro_solid_icons.d.ts.map +1 -1
- package/build/vendor/font_awesome_pro_solid_icons.js +5 -0
- package/build/vendor/font_awesome_pro_solid_icons.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/hooks/use_group_chat_conversation_payload.test.tsx +31 -0
- package/src/__tests__/screens/conversation_filters/components/conversation_filters.test.tsx +6 -0
- package/src/components/conversations/__tests__/app_update_banner.test.tsx +27 -0
- package/src/components/conversations/__tests__/conversation_actions.test.tsx +77 -2
- package/src/components/conversations/__tests__/conversation_preview.test.tsx +29 -0
- package/src/components/conversations/__tests__/conversations.test.tsx +26 -0
- package/src/components/conversations/__tests__/conversations_blank_state.test.tsx +17 -0
- package/src/components/conversations/app_update_banner.tsx +36 -0
- package/src/components/conversations/conversation_actions.tsx +73 -4
- package/src/components/conversations/conversation_preview.tsx +12 -1
- package/src/components/conversations/conversations.tsx +9 -0
- package/src/components/conversations/conversations_blank_state.tsx +18 -0
- package/src/components/conversations/hidden_indicator.tsx +30 -0
- package/src/components/conversations/hidden_results_footer.tsx +25 -0
- package/src/components/display/__tests__/toast.test.tsx +55 -0
- package/src/components/display/toast.tsx +115 -0
- package/src/components/group_conversation_list.tsx +4 -1
- package/src/components/primitive/banner_primitive.tsx +5 -1
- package/src/contexts/api_provider.tsx +2 -0
- package/src/contexts/chat_context.tsx +2 -58
- package/src/contexts/conversations_context.tsx +8 -1
- package/src/contexts/session_context.tsx +3 -0
- package/src/hooks/__tests__/jolt_refresh_throttling.test.tsx +229 -0
- package/src/hooks/__tests__/use_conversations_jolt_events.test.tsx +1 -0
- package/src/hooks/__tests__/use_conversations_mark_read.test.tsx +38 -12
- package/src/hooks/__tests__/use_hide_conversation.test.tsx +189 -0
- package/src/hooks/__tests__/use_mark_latest_message_read.test.tsx +23 -2
- package/src/hooks/__tests__/use_product_analytics.test.tsx +304 -0
- package/src/hooks/groups/use_group_chat_conversation_payload.ts +30 -12
- package/src/hooks/groups/use_group_members_for_new_conversation.ts +49 -18
- package/src/hooks/groups/use_groups_conversation_create.ts +10 -14
- package/src/hooks/groups/use_groups_proxy.ts +6 -0
- package/src/hooks/use_api.ts +2 -1
- package/src/hooks/use_clear_conversation_filters.ts +1 -0
- package/src/hooks/use_conversation.ts +1 -0
- package/src/hooks/use_conversation_jolt_events.ts +2 -1
- package/src/hooks/use_conversations_actions.ts +7 -4
- package/src/hooks/use_conversations_cache.ts +1 -23
- package/src/hooks/use_conversations_jolt_events.ts +24 -10
- package/src/hooks/use_features.ts +2 -0
- package/src/hooks/use_groups_groups.ts +21 -16
- package/src/hooks/use_hidden_conversations_count.ts +14 -0
- package/src/hooks/use_hide_conversation.ts +128 -0
- package/src/hooks/use_hide_conversations_enabled.ts +7 -0
- package/src/hooks/use_mark_latest_message_read.ts +6 -5
- package/src/hooks/use_new_conversation_from_filter.ts +13 -5
- package/src/hooks/use_product_analytics.ts +74 -41
- package/src/navigation/index.tsx +8 -0
- package/src/screens/__tests__/conversation_actions_screen.test.tsx +79 -0
- package/src/screens/__tests__/conversation_details_screen.test.tsx +49 -1
- package/src/screens/conversation_actions_screen.tsx +53 -0
- package/src/screens/conversation_details_screen.tsx +19 -0
- package/src/screens/conversation_filters/__tests__/conversation_filters.test.tsx +42 -0
- package/src/screens/conversation_filters/components/conversation_filters.tsx +22 -3
- package/src/screens/conversation_filters/components/rows.tsx +44 -10
- package/src/screens/conversation_filters/context/conversation_filter_context.tsx +4 -0
- package/src/screens/conversation_filters/filter_types.ts +1 -0
- package/src/screens/conversation_filters/screen_props.ts +1 -0
- package/src/screens/conversation_new/components/groups_form.tsx +11 -9
- package/src/screens/conversations/__tests__/conversations_screen.test.tsx +3 -3
- package/src/screens/conversations/components/__tests__/filter_dropdown_list_header_component.test.tsx +42 -0
- package/src/screens/conversations/components/__tests__/list_header_component.test.tsx +1 -0
- package/src/screens/conversations/components/filter_dropdown_list_header_component.tsx +21 -5
- package/src/screens/conversations/components/list_header_component.tsx +14 -4
- package/src/screens/conversations/components/search_list_header_component.tsx +14 -4
- package/src/screens/conversations/conversations_screen.tsx +12 -1
- package/src/screens/get_help_screen.tsx +4 -18
- package/src/screens/index.ts +1 -0
- package/src/types/jolt_events/index.ts +2 -0
- package/src/types/jolt_events/person_events.ts +16 -0
- package/src/types/resources/conversation_membership.ts +1 -0
- package/src/types/resources/groups/groups_group_resource.ts +1 -1
- package/src/types/resources/groups/groups_membership_resource.ts +10 -0
- package/src/types/resources/groups/index.ts +1 -0
- package/src/utils/__tests__/throttled_refresh.test.ts +101 -0
- package/src/utils/jolt/__tests__/parse_stream_user_event_type.test.ts +27 -0
- package/src/utils/jolt/parse_stream_user_event_type.ts +16 -0
- package/src/utils/native_adapters/__tests__/linking.test.ts +60 -4
- package/src/utils/native_adapters/configuration.ts +5 -0
- package/src/utils/native_adapters/index.ts +1 -0
- package/src/utils/native_adapters/linking.ts +50 -2
- package/src/utils/native_adapters/updates.ts +16 -0
- package/src/utils/product_analytics_token.ts +120 -0
- package/src/utils/request/conversation.ts +6 -0
- package/src/utils/throttled_refresh.ts +62 -0
- package/src/utils/toast_store.ts +45 -0
- package/src/vendor/font_awesome_pro_solid_icons.ts +12 -0
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import { useApiGet } from '../../../hooks/use_api'
|
|
20
20
|
import { useMarkAllRead } from '../../../hooks/use_conversations_actions'
|
|
21
21
|
import { useCanDisplayGroups } from '../../../hooks/use_groups'
|
|
22
|
+
import { useHideConversationsEnabled } from '../../../hooks/use_hide_conversations_enabled'
|
|
22
23
|
import { useNewConversationFromFilter } from '../../../hooks/use_new_conversation_from_filter'
|
|
23
24
|
import { useSearchEnabled } from '../../../hooks/use_search_enabled'
|
|
24
25
|
import { GraphId, GroupResource } from '../../../types/resources/group_resource'
|
|
@@ -34,6 +35,7 @@ const TRIGGER_CAP_SLACK = 2
|
|
|
34
35
|
const LAYOUT_JITTER = 1
|
|
35
36
|
const ALL_CONVERSATIONS_LABEL = 'All conversations'
|
|
36
37
|
const ARCHIVED_LABEL = 'Archived'
|
|
38
|
+
const HIDDEN_LABEL = 'Hidden'
|
|
37
39
|
|
|
38
40
|
enum FilterTypes {
|
|
39
41
|
All = 'All',
|
|
@@ -63,6 +65,7 @@ export const FilterDropdownListHeaderComponent = () => {
|
|
|
63
65
|
const hasDirectMessages = useHasDirectMessages()
|
|
64
66
|
const canFilterByDMs = directMessagesEligible && hasDirectMessages
|
|
65
67
|
const canBrowseArchived = useCanBrowseArchivedConversations()
|
|
68
|
+
const hideConversationsEnabled = useHideConversationsEnabled()
|
|
66
69
|
const searchEnabled = useSearchEnabled()
|
|
67
70
|
const route = useRoute<RouteProp<ConversationsScreenProps['route']>>()
|
|
68
71
|
const {
|
|
@@ -71,6 +74,7 @@ export const FilterDropdownListHeaderComponent = () => {
|
|
|
71
74
|
group_source_app_name = '',
|
|
72
75
|
show_direct_messages,
|
|
73
76
|
show_archived,
|
|
77
|
+
show_hidden,
|
|
74
78
|
show_unread,
|
|
75
79
|
} = route.params || {}
|
|
76
80
|
const currentPersonCache = useCurrentPersonCache()
|
|
@@ -86,7 +90,7 @@ export const FilterDropdownListHeaderComponent = () => {
|
|
|
86
90
|
)
|
|
87
91
|
|
|
88
92
|
const active: FilterTypes = useMemo(() => {
|
|
89
|
-
if (chat_group_graph_id || show_archived) {
|
|
93
|
+
if (chat_group_graph_id || show_archived || show_hidden) {
|
|
90
94
|
return FilterTypes.More
|
|
91
95
|
} else if (/groups/i.test(group_source_app_name)) {
|
|
92
96
|
return FilterTypes.Groups
|
|
@@ -99,7 +103,14 @@ export const FilterDropdownListHeaderComponent = () => {
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
return FilterTypes.All
|
|
102
|
-
}, [
|
|
106
|
+
}, [
|
|
107
|
+
chat_group_graph_id,
|
|
108
|
+
group_source_app_name,
|
|
109
|
+
show_direct_messages,
|
|
110
|
+
show_archived,
|
|
111
|
+
show_hidden,
|
|
112
|
+
show_unread,
|
|
113
|
+
])
|
|
103
114
|
|
|
104
115
|
const options: FilterDropdownOption[] = useMemo(
|
|
105
116
|
() => [
|
|
@@ -115,10 +126,11 @@ export const FilterDropdownListHeaderComponent = () => {
|
|
|
115
126
|
const triggerLabel = useMemo(() => {
|
|
116
127
|
if (chat_group_graph_id) return group?.name || title || ALL_CONVERSATIONS_LABEL
|
|
117
128
|
if (show_archived) return ARCHIVED_LABEL
|
|
129
|
+
if (show_hidden) return HIDDEN_LABEL
|
|
118
130
|
if (active === FilterTypes.All) return ALL_CONVERSATIONS_LABEL
|
|
119
131
|
|
|
120
132
|
return active
|
|
121
|
-
}, [chat_group_graph_id, group?.name, title, show_archived, active])
|
|
133
|
+
}, [chat_group_graph_id, group?.name, title, show_archived, show_hidden, active])
|
|
122
134
|
|
|
123
135
|
const handleNewConversationNavigation = useCallback(() => {
|
|
124
136
|
if (newConversationFromFilter || entryMode === 'select_type') {
|
|
@@ -158,6 +170,7 @@ export const FilterDropdownListHeaderComponent = () => {
|
|
|
158
170
|
group_source_app_name: undefined,
|
|
159
171
|
show_direct_messages: undefined,
|
|
160
172
|
show_archived: undefined,
|
|
173
|
+
show_hidden: undefined,
|
|
161
174
|
show_unread: undefined,
|
|
162
175
|
...params,
|
|
163
176
|
})
|
|
@@ -187,6 +200,7 @@ export const FilterDropdownListHeaderComponent = () => {
|
|
|
187
200
|
group_source_app_name,
|
|
188
201
|
show_direct_messages,
|
|
189
202
|
show_archived,
|
|
203
|
+
show_hidden,
|
|
190
204
|
show_unread,
|
|
191
205
|
})
|
|
192
206
|
}, [
|
|
@@ -195,6 +209,7 @@ export const FilterDropdownListHeaderComponent = () => {
|
|
|
195
209
|
group_source_app_name,
|
|
196
210
|
show_direct_messages,
|
|
197
211
|
show_archived,
|
|
212
|
+
show_hidden,
|
|
198
213
|
show_unread,
|
|
199
214
|
])
|
|
200
215
|
|
|
@@ -213,7 +228,8 @@ export const FilterDropdownListHeaderComponent = () => {
|
|
|
213
228
|
])
|
|
214
229
|
}, [active, handleMarkAllRead])
|
|
215
230
|
|
|
216
|
-
const showMoreFilters =
|
|
231
|
+
const showMoreFilters =
|
|
232
|
+
canFilterByGroups || canFilterByTeams || canBrowseArchived || hideConversationsEnabled
|
|
217
233
|
|
|
218
234
|
const styles = useStyles()
|
|
219
235
|
|
|
@@ -301,7 +317,7 @@ export const FilterDropdownListHeaderComponent = () => {
|
|
|
301
317
|
)}
|
|
302
318
|
</View>
|
|
303
319
|
</View>
|
|
304
|
-
{!show_archived && (
|
|
320
|
+
{!show_archived && !show_hidden && (
|
|
305
321
|
<View style={styles.markAllReadRow}>
|
|
306
322
|
<TextButton
|
|
307
323
|
onPress={alertMarkAllRead}
|
|
@@ -45,6 +45,7 @@ export const ListHeaderComponent = () => {
|
|
|
45
45
|
group_source_app_name = '',
|
|
46
46
|
show_direct_messages,
|
|
47
47
|
show_archived,
|
|
48
|
+
show_hidden,
|
|
48
49
|
} = route.params || {}
|
|
49
50
|
const currentPersonCache = useCurrentPersonCache()
|
|
50
51
|
const { markAllRead, isPending } = useMarkAllRead()
|
|
@@ -55,7 +56,7 @@ export const ListHeaderComponent = () => {
|
|
|
55
56
|
)
|
|
56
57
|
|
|
57
58
|
const active: FilterTypes = useMemo(() => {
|
|
58
|
-
if (chat_group_graph_id || show_archived) {
|
|
59
|
+
if (chat_group_graph_id || show_archived || show_hidden) {
|
|
59
60
|
return FilterTypes.More
|
|
60
61
|
} else if (/groups/i.test(group_source_app_name)) {
|
|
61
62
|
return FilterTypes.Groups
|
|
@@ -66,7 +67,7 @@ export const ListHeaderComponent = () => {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
return FilterTypes.All
|
|
69
|
-
}, [chat_group_graph_id, group_source_app_name, show_direct_messages, show_archived])
|
|
70
|
+
}, [chat_group_graph_id, group_source_app_name, show_direct_messages, show_archived, show_hidden])
|
|
70
71
|
|
|
71
72
|
const handleNewConversationNavigation = useCallback(() => {
|
|
72
73
|
if (newConversationFromFilter || entryMode === 'select_type') {
|
|
@@ -106,6 +107,7 @@ export const ListHeaderComponent = () => {
|
|
|
106
107
|
group_source_app_name: undefined,
|
|
107
108
|
show_direct_messages: undefined,
|
|
108
109
|
show_archived: undefined,
|
|
110
|
+
show_hidden: undefined,
|
|
109
111
|
...params,
|
|
110
112
|
})
|
|
111
113
|
},
|
|
@@ -122,8 +124,16 @@ export const ListHeaderComponent = () => {
|
|
|
122
124
|
group_source_app_name,
|
|
123
125
|
show_direct_messages,
|
|
124
126
|
show_archived,
|
|
127
|
+
show_hidden,
|
|
125
128
|
})
|
|
126
|
-
}, [
|
|
129
|
+
}, [
|
|
130
|
+
navigation,
|
|
131
|
+
chat_group_graph_id,
|
|
132
|
+
group_source_app_name,
|
|
133
|
+
show_direct_messages,
|
|
134
|
+
show_archived,
|
|
135
|
+
show_hidden,
|
|
136
|
+
])
|
|
127
137
|
|
|
128
138
|
const handleMarkAllRead = useCallback(() => {
|
|
129
139
|
currentPersonCache.update({ unreadCount: 0 })
|
|
@@ -164,7 +174,7 @@ export const ListHeaderComponent = () => {
|
|
|
164
174
|
<Heading numberOfLines={1} variant="h2">
|
|
165
175
|
Conversations
|
|
166
176
|
</Heading>
|
|
167
|
-
{!show_archived && (
|
|
177
|
+
{!show_archived && !show_hidden && (
|
|
168
178
|
<TextButton
|
|
169
179
|
onPress={alertMarkAllRead}
|
|
170
180
|
disabled={isPending}
|
|
@@ -45,6 +45,7 @@ export const SearchListHeaderComponent = () => {
|
|
|
45
45
|
group_source_app_name = '',
|
|
46
46
|
show_direct_messages,
|
|
47
47
|
show_archived,
|
|
48
|
+
show_hidden,
|
|
48
49
|
} = route.params || {}
|
|
49
50
|
const currentPersonCache = useCurrentPersonCache()
|
|
50
51
|
const { markAllRead, isPending } = useMarkAllRead()
|
|
@@ -55,7 +56,7 @@ export const SearchListHeaderComponent = () => {
|
|
|
55
56
|
)
|
|
56
57
|
|
|
57
58
|
const active: FilterTypes = useMemo(() => {
|
|
58
|
-
if (chat_group_graph_id || show_archived) {
|
|
59
|
+
if (chat_group_graph_id || show_archived || show_hidden) {
|
|
59
60
|
return FilterTypes.More
|
|
60
61
|
} else if (/groups/i.test(group_source_app_name)) {
|
|
61
62
|
return FilterTypes.Groups
|
|
@@ -66,7 +67,7 @@ export const SearchListHeaderComponent = () => {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
return FilterTypes.All
|
|
69
|
-
}, [chat_group_graph_id, group_source_app_name, show_direct_messages, show_archived])
|
|
70
|
+
}, [chat_group_graph_id, group_source_app_name, show_direct_messages, show_archived, show_hidden])
|
|
70
71
|
|
|
71
72
|
const handleNewConversationNavigation = useCallback(() => {
|
|
72
73
|
if (newConversationFromFilter || entryMode === 'select_type') {
|
|
@@ -106,6 +107,7 @@ export const SearchListHeaderComponent = () => {
|
|
|
106
107
|
group_source_app_name: undefined,
|
|
107
108
|
show_direct_messages: undefined,
|
|
108
109
|
show_archived: undefined,
|
|
110
|
+
show_hidden: undefined,
|
|
109
111
|
...params,
|
|
110
112
|
})
|
|
111
113
|
},
|
|
@@ -126,8 +128,16 @@ export const SearchListHeaderComponent = () => {
|
|
|
126
128
|
group_source_app_name,
|
|
127
129
|
show_direct_messages,
|
|
128
130
|
show_archived,
|
|
131
|
+
show_hidden,
|
|
129
132
|
})
|
|
130
|
-
}, [
|
|
133
|
+
}, [
|
|
134
|
+
navigation,
|
|
135
|
+
chat_group_graph_id,
|
|
136
|
+
group_source_app_name,
|
|
137
|
+
show_direct_messages,
|
|
138
|
+
show_archived,
|
|
139
|
+
show_hidden,
|
|
140
|
+
])
|
|
131
141
|
|
|
132
142
|
const handleMarkAllRead = useCallback(() => {
|
|
133
143
|
currentPersonCache.update({ unreadCount: 0 })
|
|
@@ -168,7 +178,7 @@ export const SearchListHeaderComponent = () => {
|
|
|
168
178
|
<Heading numberOfLines={1} variant="h2">
|
|
169
179
|
Conversations
|
|
170
180
|
</Heading>
|
|
171
|
-
{!show_archived && (
|
|
181
|
+
{!show_archived && !show_hidden && (
|
|
172
182
|
<TextButton
|
|
173
183
|
onPress={alertMarkAllRead}
|
|
174
184
|
disabled={isPending}
|
|
@@ -2,6 +2,8 @@ import { StaticScreenProps } from '@react-navigation/native'
|
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import { StyleSheet, View } from 'react-native'
|
|
4
4
|
import { Conversations } from '../../components'
|
|
5
|
+
import { AppUpdateBanner } from '../../components/conversations/app_update_banner'
|
|
6
|
+
import { Toast } from '../../components/display/toast'
|
|
5
7
|
import { ConversationsContextProvider } from '../../contexts/conversations_context'
|
|
6
8
|
import { useFilterDropdownEnabled } from '../../hooks/use_filter_dropdown_enabled'
|
|
7
9
|
import { analyticsEvents, usePublishProductAnalyticsEvent } from '../../hooks/use_product_analytics'
|
|
@@ -18,6 +20,7 @@ export type ConversationsScreenProps = StaticScreenProps<{
|
|
|
18
20
|
group_source_app_name?: AppName
|
|
19
21
|
show_direct_messages?: boolean
|
|
20
22
|
show_archived?: boolean
|
|
23
|
+
show_hidden?: boolean
|
|
21
24
|
show_unread?: boolean
|
|
22
25
|
}>
|
|
23
26
|
|
|
@@ -30,8 +33,16 @@ export function ConversationsScreen({ route }: ConversationsScreenProps) {
|
|
|
30
33
|
return (
|
|
31
34
|
<View style={styles.container}>
|
|
32
35
|
<ConversationsContextProvider args={route.params} opts={{ throwOnError: true }}>
|
|
33
|
-
<Conversations
|
|
36
|
+
<Conversations
|
|
37
|
+
ListHeaderComponent={
|
|
38
|
+
<>
|
|
39
|
+
<Header />
|
|
40
|
+
<AppUpdateBanner />
|
|
41
|
+
</>
|
|
42
|
+
}
|
|
43
|
+
/>
|
|
34
44
|
</ConversationsContextProvider>
|
|
45
|
+
<Toast />
|
|
35
46
|
</View>
|
|
36
47
|
)
|
|
37
48
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
2
2
|
import { useCallback, useMemo } from 'react'
|
|
3
|
-
import {
|
|
3
|
+
import { ScrollView, StyleSheet, View } from 'react-native'
|
|
4
4
|
import { Heading, PressableRow, Text, TextInlineButton } from '../components'
|
|
5
5
|
import { useApiGet, useTheme } from '../hooks'
|
|
6
6
|
import { useAppName } from '../hooks/use_app_name'
|
|
7
7
|
import { useOrganization } from '../hooks/use_organization'
|
|
8
8
|
import { ResourceObject } from '../types'
|
|
9
|
-
import {
|
|
9
|
+
import { Linking } from '../utils'
|
|
10
10
|
|
|
11
11
|
type GetHelpScreenRouteProps = {
|
|
12
12
|
type?: 'chat' | 'general'
|
|
@@ -117,27 +117,13 @@ const ContactRow = ({ email, phone }: { email?: string; phone?: string }) => {
|
|
|
117
117
|
export function sendEmail(email: string) {
|
|
118
118
|
if (!email) return
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
Linking.openURL(url).catch(() => {
|
|
123
|
-
Alert.alert('Oops', `Unable to open: ${email}`, [
|
|
124
|
-
{ text: 'Copy to clipboard', onPress: () => Clipboard.setStringAsync(email) },
|
|
125
|
-
{ text: 'OK' },
|
|
126
|
-
])
|
|
127
|
-
})
|
|
120
|
+
Linking.openURL(encodeURI(`mailto:${email}`))
|
|
128
121
|
}
|
|
129
122
|
|
|
130
123
|
export function placePhoneCall(phoneNumber: string) {
|
|
131
124
|
if (!phoneNumber) return
|
|
132
125
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
Linking.openURL(url).catch(() => {
|
|
136
|
-
Alert.alert('Oops', `Unable to open: ${phoneNumber}`, [
|
|
137
|
-
{ text: 'Copy to clipboard', onPress: () => Clipboard.setStringAsync(phoneNumber) },
|
|
138
|
-
{ text: 'OK' },
|
|
139
|
-
])
|
|
140
|
-
})
|
|
126
|
+
Linking.openURL(encodeURI(`tel:${phoneNumber}`))
|
|
141
127
|
}
|
|
142
128
|
|
|
143
129
|
const useStyles = () => {
|
package/src/screens/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from './preferred_app_selection_screen'
|
|
|
8
8
|
export * from './group_notification_settings_screen'
|
|
9
9
|
export * from './conversation_filter_recipients/conversation_filter_recipients_screen'
|
|
10
10
|
export * from './message_actions_screen'
|
|
11
|
+
export * from './conversation_actions_screen'
|
|
11
12
|
export * from './message_report_screen'
|
|
12
13
|
export * from './send_giphy_screen'
|
|
13
14
|
export * from './not_found'
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
MessageDeletedEvent,
|
|
11
11
|
MessageUpdatedEvent,
|
|
12
12
|
} from './message_events'
|
|
13
|
+
import type { StreamUserEventType, StreamUserUpdatedEvent } from './person_events'
|
|
13
14
|
import type { ReactionCreatedEvent, ReactionDeletedEvent } from './reaction_events'
|
|
14
15
|
import type { TypingBroadcastEvent } from './typing_events'
|
|
15
16
|
|
|
@@ -22,6 +23,7 @@ export type JoltMessageEvent = MessageCreatedEvent | MessageUpdatedEvent | Messa
|
|
|
22
23
|
export type JoltReactionEvent = ReactionCreatedEvent | ReactionDeletedEvent
|
|
23
24
|
export type JoltTypingEvent = TypingBroadcastEvent
|
|
24
25
|
export type JoltAttachmentEvent = AttachmentFlaggedEvent
|
|
26
|
+
export type { StreamUserEventType, StreamUserUpdatedEvent }
|
|
25
27
|
|
|
26
28
|
export type CustomJoltEvent =
|
|
27
29
|
| JoltConversationEvent
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'
|
|
2
|
+
|
|
3
|
+
export type StreamUserEventType =
|
|
4
|
+
| 'message.created'
|
|
5
|
+
| 'conversation.mark_read'
|
|
6
|
+
| 'conversation.mark_unread'
|
|
7
|
+
| 'conversation.destroy'
|
|
8
|
+
| 'person.mark_all_read'
|
|
9
|
+
| 'app_grant.synced'
|
|
10
|
+
|
|
11
|
+
export interface StreamUserUpdatedEvent extends CustomMessage {
|
|
12
|
+
event: 'STREAM_USER_UPDATED'
|
|
13
|
+
data: {
|
|
14
|
+
data: string
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -5,6 +5,7 @@ export type NotificationLevelDescription = string
|
|
|
5
5
|
|
|
6
6
|
export interface ConversationMembershipResource extends ResourceObject {
|
|
7
7
|
type: 'ConversationMembership'
|
|
8
|
+
hidden?: boolean
|
|
8
9
|
lastReadMessageSortKey: string
|
|
9
10
|
muted: boolean
|
|
10
11
|
notificationLevel: NotificationLevelValue
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query'
|
|
2
|
+
import { buildTestQueryClient } from '../../__utils__/query_client'
|
|
3
|
+
import {
|
|
4
|
+
cancelThrottledRefreshes,
|
|
5
|
+
REFRESH_THROTTLE_MS,
|
|
6
|
+
throttledRefresh,
|
|
7
|
+
} from '../throttled_refresh'
|
|
8
|
+
|
|
9
|
+
const key = ['/me/conversations/7']
|
|
10
|
+
let queryClient: QueryClient
|
|
11
|
+
let refresh: jest.Mock
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
jest.useFakeTimers()
|
|
15
|
+
queryClient = buildTestQueryClient()
|
|
16
|
+
refresh = jest.fn()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
cancelThrottledRefreshes(queryClient)
|
|
21
|
+
jest.useRealTimers()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const fire = (events = 1) => {
|
|
25
|
+
for (let i = 0; i < events; i++) throttledRefresh(queryClient, key, {}, refresh)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe('throttledRefresh', () => {
|
|
29
|
+
it('runs a lone event immediately and never again', () => {
|
|
30
|
+
fire()
|
|
31
|
+
expect(refresh).toHaveBeenCalledTimes(1)
|
|
32
|
+
|
|
33
|
+
jest.advanceTimersByTime(REFRESH_THROTTLE_MS * 3)
|
|
34
|
+
expect(refresh).toHaveBeenCalledTimes(1)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('collapses a burst into one immediate run and one when the window ends', () => {
|
|
38
|
+
fire(50)
|
|
39
|
+
expect(refresh).toHaveBeenCalledTimes(1)
|
|
40
|
+
|
|
41
|
+
jest.advanceTimersByTime(REFRESH_THROTTLE_MS - 1)
|
|
42
|
+
expect(refresh).toHaveBeenCalledTimes(1)
|
|
43
|
+
|
|
44
|
+
jest.advanceTimersByTime(1)
|
|
45
|
+
expect(refresh).toHaveBeenCalledTimes(2)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('gives an event inside the window opened by a trailing run its own trailing run', () => {
|
|
49
|
+
fire()
|
|
50
|
+
jest.advanceTimersByTime(1000)
|
|
51
|
+
fire()
|
|
52
|
+
jest.advanceTimersByTime(REFRESH_THROTTLE_MS - 1000)
|
|
53
|
+
expect(refresh).toHaveBeenCalledTimes(2)
|
|
54
|
+
|
|
55
|
+
jest.advanceTimersByTime(500)
|
|
56
|
+
fire()
|
|
57
|
+
expect(refresh).toHaveBeenCalledTimes(2)
|
|
58
|
+
|
|
59
|
+
jest.advanceTimersByTime(REFRESH_THROTTLE_MS)
|
|
60
|
+
expect(refresh).toHaveBeenCalledTimes(3)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('counts the same event delivered to several consumers once', () => {
|
|
64
|
+
const event = {}
|
|
65
|
+
const other = jest.fn()
|
|
66
|
+
throttledRefresh(queryClient, key, event, refresh)
|
|
67
|
+
throttledRefresh(queryClient, [...key], event, other)
|
|
68
|
+
|
|
69
|
+
jest.advanceTimersByTime(REFRESH_THROTTLE_MS * 2)
|
|
70
|
+
expect(refresh).toHaveBeenCalledTimes(1)
|
|
71
|
+
expect(other).not.toHaveBeenCalled()
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('shares one window across consumers using the same client and key', () => {
|
|
75
|
+
const other = jest.fn()
|
|
76
|
+
throttledRefresh(queryClient, key, {}, refresh)
|
|
77
|
+
throttledRefresh(queryClient, [...key], {}, other)
|
|
78
|
+
|
|
79
|
+
expect(refresh).toHaveBeenCalledTimes(1)
|
|
80
|
+
expect(other).not.toHaveBeenCalled()
|
|
81
|
+
|
|
82
|
+
jest.advanceTimersByTime(REFRESH_THROTTLE_MS)
|
|
83
|
+
expect(other).toHaveBeenCalledTimes(1)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('keeps separate windows per key and per query client', () => {
|
|
87
|
+
throttledRefresh(queryClient, key, {}, refresh)
|
|
88
|
+
throttledRefresh(queryClient, ['/me'], {}, refresh)
|
|
89
|
+
throttledRefresh(buildTestQueryClient(), key, {}, refresh)
|
|
90
|
+
|
|
91
|
+
expect(refresh).toHaveBeenCalledTimes(3)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('drops pending trailing runs when cancelled', () => {
|
|
95
|
+
fire(2)
|
|
96
|
+
cancelThrottledRefreshes(queryClient)
|
|
97
|
+
|
|
98
|
+
jest.advanceTimersByTime(REFRESH_THROTTLE_MS)
|
|
99
|
+
expect(refresh).toHaveBeenCalledTimes(1)
|
|
100
|
+
})
|
|
101
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { StreamUserUpdatedEvent } from '../../../types/jolt_events'
|
|
2
|
+
import { parseStreamUserEventType } from '../parse_stream_user_event_type'
|
|
3
|
+
|
|
4
|
+
const event = (data: unknown) =>
|
|
5
|
+
({
|
|
6
|
+
event: 'STREAM_USER_UPDATED',
|
|
7
|
+
channel: 'chat.people.1',
|
|
8
|
+
data: { data },
|
|
9
|
+
}) as StreamUserUpdatedEvent
|
|
10
|
+
|
|
11
|
+
describe('parseStreamUserEventType', () => {
|
|
12
|
+
it('reads the event type out of the JSON payload', () => {
|
|
13
|
+
expect(parseStreamUserEventType(event('{"event_type":"message.created"}'))).toBe(
|
|
14
|
+
'message.created'
|
|
15
|
+
)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('treats an empty payload as missing', () => {
|
|
19
|
+
expect(parseStreamUserEventType(event('{}'))).toBeUndefined()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('treats a payload that fails to parse as missing', () => {
|
|
23
|
+
expect(parseStreamUserEventType(event('not json'))).toBeUndefined()
|
|
24
|
+
expect(parseStreamUserEventType(event(undefined))).toBeUndefined()
|
|
25
|
+
expect(parseStreamUserEventType(event('null'))).toBeUndefined()
|
|
26
|
+
})
|
|
27
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { StreamUserEventType, StreamUserUpdatedEvent } from '../../types/jolt_events'
|
|
2
|
+
|
|
3
|
+
interface StreamUserEventData {
|
|
4
|
+
event_type?: StreamUserEventType
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const parseStreamUserEventType = (
|
|
8
|
+
event: StreamUserUpdatedEvent
|
|
9
|
+
): StreamUserEventType | undefined => {
|
|
10
|
+
try {
|
|
11
|
+
const parsed = JSON.parse(event.data.data) as StreamUserEventData | null
|
|
12
|
+
return parsed?.event_type
|
|
13
|
+
} catch {
|
|
14
|
+
return undefined
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,12 +1,68 @@
|
|
|
1
|
+
import { Alert } from 'react-native'
|
|
2
|
+
import { Clipboard, Log } from '../configuration'
|
|
1
3
|
import { LinkingAdapter } from '../linking'
|
|
2
4
|
|
|
5
|
+
type AlertButton = { text?: string; onPress?: () => void }
|
|
6
|
+
|
|
7
|
+
const pressButton = (text: string) => {
|
|
8
|
+
const buttons = (Alert.alert as jest.Mock).mock.calls[0][2] as AlertButton[]
|
|
9
|
+
buttons.find(button => button.text === text)?.onPress?.()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const buildAdapter = (openURL: jest.Mock) =>
|
|
13
|
+
new LinkingAdapter({ openURL, canOpenURL: async () => true })
|
|
14
|
+
|
|
3
15
|
describe('LinkingAdapter', () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const adapter = new LinkingAdapter({ openURL, canOpenURL: async () => true })
|
|
16
|
+
let setStringAsync: jest.SpyInstance
|
|
17
|
+
let reportError: jest.SpyInstance
|
|
7
18
|
|
|
8
|
-
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
jest.spyOn(Alert, 'alert').mockImplementation(() => {})
|
|
21
|
+
setStringAsync = jest.spyOn(Clipboard, 'setStringAsync').mockResolvedValue()
|
|
22
|
+
reportError = jest.spyOn(Log, 'reportError').mockImplementation(() => {})
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
jest.restoreAllMocks()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('forwards the url and options to the host', async () => {
|
|
30
|
+
const openURL = jest.fn().mockResolvedValue(true)
|
|
31
|
+
|
|
32
|
+
await buildAdapter(openURL).openURL('https://example.com', { forceOpenInBrowser: true })
|
|
9
33
|
|
|
10
34
|
expect(openURL).toHaveBeenCalledWith('https://example.com', { forceOpenInBrowser: true })
|
|
35
|
+
expect(Alert.alert).not.toHaveBeenCalled()
|
|
36
|
+
expect(reportError).not.toHaveBeenCalled()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('reports a failed web link instead of alerting', async () => {
|
|
40
|
+
const error = new Error('Unable to open URL')
|
|
41
|
+
const openURL = jest.fn().mockRejectedValue(error)
|
|
42
|
+
|
|
43
|
+
await buildAdapter(openURL).openURL('https://youtu.be/abc')
|
|
44
|
+
|
|
45
|
+
expect(reportError).toHaveBeenCalledWith(error, { extra: { url: 'https://youtu.be/abc' } })
|
|
46
|
+
expect(Alert.alert).not.toHaveBeenCalled()
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it.each([
|
|
50
|
+
['mailto', 'mailto:admin@example.com', 'admin@example.com'],
|
|
51
|
+
['encoded mailto', encodeURI('mailto:first last@example.com'), 'first last@example.com'],
|
|
52
|
+
['tel', 'tel:+1 (555) 555-0100', '+1 (555) 555-0100'],
|
|
53
|
+
])('alerts and offers to copy the bare address for a %s link', async (_name, url, address) => {
|
|
54
|
+
const openURL = jest.fn().mockRejectedValue(new Error('No Activity found'))
|
|
55
|
+
|
|
56
|
+
await buildAdapter(openURL).openURL(url)
|
|
57
|
+
|
|
58
|
+
expect(Alert.alert).toHaveBeenCalledWith(
|
|
59
|
+
'Oops',
|
|
60
|
+
`Unable to open: ${address}`,
|
|
61
|
+
expect.arrayContaining([expect.objectContaining({ text: 'Copy to clipboard' })])
|
|
62
|
+
)
|
|
63
|
+
expect(reportError).not.toHaveBeenCalled()
|
|
64
|
+
|
|
65
|
+
pressButton('Copy to clipboard')
|
|
66
|
+
expect(setStringAsync).toHaveBeenCalledWith(address)
|
|
11
67
|
})
|
|
12
68
|
})
|
|
@@ -9,6 +9,7 @@ import { LinkingAdapter } from './linking'
|
|
|
9
9
|
import { LogAdapter } from './log'
|
|
10
10
|
import { MenuAdapter } from './menu'
|
|
11
11
|
import { StorageAdapter } from './storage_adapter'
|
|
12
|
+
import { UpdatesAdapter } from './updates'
|
|
12
13
|
import { VideoAdapter } from './video'
|
|
13
14
|
|
|
14
15
|
type ChatConfigurations = {
|
|
@@ -21,6 +22,7 @@ type ChatConfigurations = {
|
|
|
21
22
|
linking?: LinkingAdapter
|
|
22
23
|
haptic?: HapticAdapter
|
|
23
24
|
menu?: MenuAdapter
|
|
25
|
+
updates?: UpdatesAdapter
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export class ChatAdapters {
|
|
@@ -34,6 +36,7 @@ export class ChatAdapters {
|
|
|
34
36
|
Linking = configurations.linking || new LinkingAdapter(RNLinking)
|
|
35
37
|
Haptic = configurations.haptic || new HapticAdapter()
|
|
36
38
|
Menu = configurations.menu || new MenuAdapter()
|
|
39
|
+
Updates = configurations.updates || new UpdatesAdapter()
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
|
|
@@ -87,6 +90,8 @@ export let Haptic: HapticAdapter = new HapticAdapter()
|
|
|
87
90
|
|
|
88
91
|
export let Menu: MenuAdapter = new MenuAdapter()
|
|
89
92
|
|
|
93
|
+
export let Updates: UpdatesAdapter = new UpdatesAdapter()
|
|
94
|
+
|
|
90
95
|
export let Storage = new StorageAdapter({
|
|
91
96
|
getItem: AsyncStorage.getItem,
|
|
92
97
|
setItem: AsyncStorage.setItem,
|