@planningcenter/chat-react-native 4.8.0-rc.0 → 4.8.0-rc.10
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/bulk_conversation_actions_bar.d.ts +2 -0
- package/build/components/conversations/bulk_conversation_actions_bar.d.ts.map +1 -0
- package/build/components/conversations/bulk_conversation_actions_bar.js +215 -0
- package/build/components/conversations/bulk_conversation_actions_bar.js.map +1 -0
- package/build/components/conversations/conversation_actions.d.ts +2 -1
- package/build/components/conversations/conversation_actions.d.ts.map +1 -1
- package/build/components/conversations/conversation_actions.js +173 -130
- 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 +168 -110
- 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 +50 -48
- package/build/components/conversations/conversations.js.map +1 -1
- package/build/components/display/checkbox.d.ts +8 -0
- package/build/components/display/checkbox.d.ts.map +1 -0
- package/build/components/display/checkbox.js +87 -0
- package/build/components/display/checkbox.js.map +1 -0
- package/build/components/display/icon.d.ts +3 -1
- package/build/components/display/icon.d.ts.map +1 -1
- package/build/components/display/icon.js +2 -0
- package/build/components/display/icon.js.map +1 -1
- package/build/components/display/index.d.ts +1 -0
- package/build/components/display/index.d.ts.map +1 -1
- package/build/components/display/index.js +1 -0
- package/build/components/display/index.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 +5 -0
- package/build/contexts/conversations_context.d.ts.map +1 -1
- package/build/contexts/conversations_context.js +121 -32
- package/build/contexts/conversations_context.js.map +1 -1
- package/build/contexts/session_context.d.ts +0 -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 +27 -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_bulk_conversation_actions.d.ts +8 -0
- package/build/hooks/use_bulk_conversation_actions.d.ts.map +1 -0
- package/build/hooks/use_bulk_conversation_actions.js +309 -0
- package/build/hooks/use_bulk_conversation_actions.js.map +1 -0
- 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 +15 -5
- package/build/hooks/use_conversations_cache.d.ts.map +1 -1
- package/build/hooks/use_conversations_cache.js +170 -122
- 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 +1 -0
- package/build/hooks/use_features.d.ts.map +1 -1
- package/build/hooks/use_features.js +1 -0
- package/build/hooks/use_features.js.map +1 -1
- 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_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/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +5 -7
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_actions_screen.d.ts +2 -0
- package/build/screens/conversation_actions_screen.d.ts.map +1 -1
- package/build/screens/conversation_actions_screen.js +380 -46
- package/build/screens/conversation_actions_screen.js.map +1 -1
- package/build/screens/conversation_filter_recipients/components/checkbox_row.d.ts.map +1 -1
- package/build/screens/conversation_filter_recipients/components/checkbox_row.js +9 -64
- package/build/screens/conversation_filter_recipients/components/checkbox_row.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/conversations_screen.d.ts +5 -0
- package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations/conversations_screen.js +156 -31
- 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/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/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/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/package.json +2 -2
- package/src/__tests__/contexts/session_context.tsx +19 -39
- package/src/__tests__/hooks/useTheme.tsx +0 -7
- package/src/__tests__/hooks/use_async_storage.test.tsx +1 -87
- package/src/__tests__/hooks/use_attachment_uploader.test.tsx +0 -11
- package/src/__tests__/hooks/use_font_scale.test.ts +0 -25
- package/src/__tests__/hooks/use_group_chat_conversation_payload.test.tsx +31 -0
- package/src/__tests__/utils/cache/page_mutations.ts +3 -68
- package/src/__tests__/utils/client.ts +6 -15
- package/src/__tests__/utils/native_adapters/configuration.ts +15 -50
- package/src/__tests__/utils/parse_simple_markdown.ts +0 -6
- package/src/__tests__/utils/session.ts +0 -11
- package/src/__tests__/utils/theme.ts +0 -17
- package/src/components/conversations/__tests__/bulk_conversation_actions_bar.test.tsx +95 -0
- package/src/components/conversations/__tests__/conversation_actions.test.tsx +35 -3
- package/src/components/conversations/__tests__/conversation_preview.test.tsx +69 -3
- package/src/components/conversations/__tests__/conversations.test.tsx +4 -1
- package/src/components/conversations/bulk_conversation_actions_bar.tsx +140 -0
- package/src/components/conversations/conversation_actions.tsx +17 -9
- package/src/components/conversations/conversation_preview.tsx +20 -2
- package/src/components/conversations/conversations.tsx +2 -1
- package/src/components/display/__tests__/filter_dropdown.test.tsx +1 -19
- package/src/components/display/__tests__/icon_tile.test.tsx +24 -7
- package/src/components/display/checkbox.tsx +47 -0
- package/src/components/display/icon.tsx +3 -0
- package/src/components/display/index.ts +1 -0
- package/src/components/page/__tests__/component_error_boundary.test.tsx +0 -12
- package/src/contexts/__tests__/conversations_context.test.tsx +86 -0
- package/src/contexts/api_provider.tsx +2 -0
- package/src/contexts/chat_context.tsx +2 -58
- package/src/contexts/conversations_context.tsx +69 -2
- package/src/contexts/session_context.tsx +3 -1
- package/src/hooks/__tests__/jolt_refresh_throttling.test.tsx +194 -0
- package/src/hooks/__tests__/use_bulk_conversation_actions.test.tsx +119 -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 +15 -3
- 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_bulk_conversation_actions.ts +173 -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 +33 -26
- package/src/hooks/use_conversations_jolt_events.ts +24 -10
- package/src/hooks/use_features.ts +1 -0
- package/src/hooks/use_groups_groups.ts +21 -16
- 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 -8
- package/src/screens/__tests__/conversation_actions_screen.test.tsx +48 -6
- package/src/screens/__tests__/conversation_details_screen.test.tsx +0 -19
- package/src/screens/avatar_picker/__tests__/avatar_picker_state.test.ts +0 -14
- package/src/screens/conversation_actions_screen.tsx +145 -12
- package/src/screens/conversation_filter_recipients/components/checkbox_row.tsx +3 -35
- package/src/screens/conversation_new/components/groups_form.tsx +11 -9
- package/src/screens/conversations/__tests__/conversations_screen.test.tsx +35 -9
- package/src/screens/conversations/components/__tests__/filter_dropdown_list_header_component.test.tsx +0 -8
- package/src/screens/conversations/components/__tests__/search_list_header_component.test.tsx +0 -10
- package/src/screens/conversations/conversations_screen.tsx +67 -3
- package/src/screens/get_help_screen.tsx +4 -18
- package/src/screens/search/components/__tests__/search_results_list.test.tsx +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/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__/attachment_kind.test.ts +0 -4
- package/src/utils/__tests__/convert_attachments_for_create.test.ts +0 -28
- package/src/utils/__tests__/is_input_editable.test.ts +1 -2
- package/src/utils/__tests__/message_text.test.ts +0 -5
- package/src/utils/__tests__/session_manager.test.ts +0 -83
- package/src/utils/__tests__/sha_256.test.ts +0 -34
- package/src/utils/__tests__/throttled_refresh.test.ts +101 -0
- package/src/utils/__tests__/uri.test.ts +51 -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/throttled_refresh.ts +62 -0
- package/src/__tests__/event-polyfill.test.ts +0 -313
- package/src/__tests__/index.tsx +0 -5
- package/src/__tests__/jest.ts +0 -11
- package/src/__tests__/utils/uri.ts +0 -65
- package/src/components/display/__tests__/version_footer.test.tsx +0 -48
- package/src/screens/search/components/__tests__/search_blank_states.test.tsx +0 -20
- package/src/utils/__tests__/membership_sync_info_text.test.ts +0 -15
|
@@ -2,6 +2,7 @@ import { useMemo } from 'react'
|
|
|
2
2
|
import { GroupResource, GraphId } from '../types/resources/group_resource'
|
|
3
3
|
import { GroupsGroupResource } from '../types/resources/groups/groups_group_resource'
|
|
4
4
|
import { destructureChatGroupGraphId } from '../utils'
|
|
5
|
+
import { useGroupsProxy } from './groups/use_groups_proxy'
|
|
5
6
|
import { useApiGet } from './use_api'
|
|
6
7
|
import { useNewConversationEntry } from './use_new_conversation_entry'
|
|
7
8
|
|
|
@@ -22,6 +23,7 @@ export function useNewConversationFromFilter(
|
|
|
22
23
|
): NewConversationFromFilter | undefined {
|
|
23
24
|
const { sourceAppName, sourceType, sourceId } = destructureChatGroupGraphId(chatGroupGraphId)
|
|
24
25
|
const entryMode = useNewConversationEntry()
|
|
26
|
+
const proxied = useGroupsProxy()
|
|
25
27
|
const isGroupsGroup = sourceAppName === 'Groups' && sourceType === 'Group'
|
|
26
28
|
const isServicesTeam = sourceAppName === 'Services' && sourceType === 'Team'
|
|
27
29
|
|
|
@@ -31,11 +33,17 @@ export function useNewConversationFromFilter(
|
|
|
31
33
|
)
|
|
32
34
|
|
|
33
35
|
const { data: groupsGroup } = useApiGet<GroupsGroupResource>(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
proxied
|
|
37
|
+
? {
|
|
38
|
+
url: `/me/groups_groups/${sourceId}`,
|
|
39
|
+
data: { fields: { GroupsGroup: ['can_create_conversation'] } },
|
|
40
|
+
app: 'chat',
|
|
41
|
+
}
|
|
42
|
+
: {
|
|
43
|
+
url: `/me/groups/${sourceId}`,
|
|
44
|
+
data: { fields: { Group: ['can_create_conversation'] } },
|
|
45
|
+
app: 'groups',
|
|
46
|
+
},
|
|
39
47
|
{ enabled: isGroupsGroup && !!sourceId }
|
|
40
48
|
)
|
|
41
49
|
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isCancelledError, useQueryClient } from '@tanstack/react-query'
|
|
2
|
+
import { useCallback, useEffect, useRef } from 'react'
|
|
2
3
|
import { useChatContext } from '../contexts/chat_context'
|
|
3
4
|
import { ProductAnalyticsConfig } from '../types/product_analytics'
|
|
4
5
|
import { AnalyticsMetadataResource } from '../types/resources/analytics_metadata'
|
|
5
6
|
import { keysToSnakeCase } from '../utils/client/utils'
|
|
7
|
+
import { Log } from '../utils/native_adapters/configuration'
|
|
8
|
+
import { fetchProductAnalyticsConfig } from '../utils/product_analytics_token'
|
|
9
|
+
import { isResponseLike, ResponseError } from '../utils/response_error'
|
|
6
10
|
import { SHA256, enc } from '../utils/sha_256'
|
|
7
11
|
|
|
8
12
|
export interface EventMetadata {
|
|
@@ -27,6 +31,46 @@ function contentSha256(payload: string): string {
|
|
|
27
31
|
return SHA256(payload).toString(enc.Hex)
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
type AnalyticsStage = 'prepare' | 'send'
|
|
35
|
+
|
|
36
|
+
const REPORT_TAGS = {
|
|
37
|
+
team: 'chat',
|
|
38
|
+
package: 'chat-react-native',
|
|
39
|
+
feature: 'product-analytics',
|
|
40
|
+
} as const
|
|
41
|
+
|
|
42
|
+
const isNetworkFailure = (error: unknown) =>
|
|
43
|
+
error instanceof TypeError && /network/i.test(error.message)
|
|
44
|
+
|
|
45
|
+
// HTTP failures from the API client are already reported by instrumentedFetch,
|
|
46
|
+
// network failures are expected on flaky connections, and queries are cancelled
|
|
47
|
+
// whenever the session changes. Anything else is a bug worth seeing in Sentry.
|
|
48
|
+
const isExpectedFailure = (error: unknown) =>
|
|
49
|
+
isResponseLike(error) ||
|
|
50
|
+
error instanceof ResponseError ||
|
|
51
|
+
isCancelledError(error) ||
|
|
52
|
+
isNetworkFailure(error)
|
|
53
|
+
|
|
54
|
+
function reportAnalyticsError(error: unknown, stage: AnalyticsStage) {
|
|
55
|
+
if (__DEV__) {
|
|
56
|
+
console.warn(`Product Analytics ${stage} failed:`, error)
|
|
57
|
+
}
|
|
58
|
+
if (isExpectedFailure(error)) return
|
|
59
|
+
|
|
60
|
+
const reported = error instanceof Error ? error : new Error(String(error))
|
|
61
|
+
Log.reportError(reported, { tags: { ...REPORT_TAGS, 'analytics.stage': stage } })
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// The events endpoint is outside the chat API, so it isn't instrumented.
|
|
65
|
+
// A rejected batch here usually means the stored token is no longer accepted.
|
|
66
|
+
function reportRejectedEvents(response: Response) {
|
|
67
|
+
const error = new Error(`HTTP ${response.status} POST product analytics events`)
|
|
68
|
+
error.name = `HTTPError${response.status}`
|
|
69
|
+
Log.reportError(error, {
|
|
70
|
+
tags: { ...REPORT_TAGS, 'analytics.stage': 'send', 'http.status': String(response.status) },
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
30
74
|
function sendEvents(events: AnalyticsEvent[], config: ProductAnalyticsConfig): Promise<Response[]> {
|
|
31
75
|
// Split into chunks of 10 and make parallel requests
|
|
32
76
|
const chunks: AnalyticsEvent[][] = []
|
|
@@ -37,7 +81,7 @@ function sendEvents(events: AnalyticsEvent[], config: ProductAnalyticsConfig): P
|
|
|
37
81
|
return Promise.all(
|
|
38
82
|
chunks.map(async chunk => {
|
|
39
83
|
const payload = JSON.stringify({ events: chunk })
|
|
40
|
-
|
|
84
|
+
const response = await fetch(config.endpoint, {
|
|
41
85
|
method: 'POST',
|
|
42
86
|
headers: {
|
|
43
87
|
'Content-Type': 'application/json; charset=utf-8',
|
|
@@ -46,56 +90,45 @@ function sendEvents(events: AnalyticsEvent[], config: ProductAnalyticsConfig): P
|
|
|
46
90
|
},
|
|
47
91
|
body: payload,
|
|
48
92
|
})
|
|
93
|
+
if (!response.ok) reportRejectedEvents(response)
|
|
94
|
+
return response
|
|
49
95
|
})
|
|
50
96
|
).catch(error => {
|
|
51
|
-
|
|
52
|
-
console.warn('Product Analytics request failed:', error)
|
|
53
|
-
}
|
|
97
|
+
reportAnalyticsError(error, 'send')
|
|
54
98
|
return [] as Response[]
|
|
55
99
|
})
|
|
56
100
|
}
|
|
57
101
|
|
|
58
102
|
export const useProductAnalytics = () => {
|
|
59
|
-
const {
|
|
60
|
-
|
|
61
|
-
const snakeCasedBaseMeta = useMemo(
|
|
62
|
-
() => keysToSnakeCase(productAnalyticsConfig?.metadata || {}),
|
|
63
|
-
[productAnalyticsConfig?.metadata]
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
const publishEvent = useCallback(
|
|
67
|
-
(name: AnalyticsEventName, meta: EventMetadata = {}): Promise<Response[]> => {
|
|
68
|
-
if (!productAnalyticsConfig) {
|
|
69
|
-
if (__DEV__) {
|
|
70
|
-
console.warn('Product Analytics not available')
|
|
71
|
-
}
|
|
72
|
-
return Promise.resolve([])
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const mergedMeta = { ...snakeCasedBaseMeta, ...meta } as EventMetadata
|
|
76
|
-
|
|
77
|
-
return sendEvents([{ name, meta: mergedMeta }], productAnalyticsConfig)
|
|
78
|
-
},
|
|
79
|
-
[productAnalyticsConfig, snakeCasedBaseMeta]
|
|
80
|
-
)
|
|
103
|
+
const { session } = useChatContext()
|
|
104
|
+
const queryClient = useQueryClient()
|
|
81
105
|
|
|
82
106
|
const publishEvents = useCallback(
|
|
83
107
|
(events: Array<{ name: AnalyticsEventName; meta?: EventMetadata }>): Promise<Response[]> => {
|
|
84
|
-
if (!
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
108
|
+
if (!session.isAuthenticated) return Promise.resolve([])
|
|
109
|
+
|
|
110
|
+
return fetchProductAnalyticsConfig(queryClient, session)
|
|
111
|
+
.then(config => {
|
|
112
|
+
const baseMeta = keysToSnakeCase(config.metadata || {})
|
|
113
|
+
const eventsWithMeta = events.map(event => ({
|
|
114
|
+
name: event.name,
|
|
115
|
+
meta: { ...baseMeta, ...event.meta } as EventMetadata,
|
|
116
|
+
}))
|
|
117
|
+
|
|
118
|
+
return sendEvents(eventsWithMeta, config)
|
|
119
|
+
})
|
|
120
|
+
.catch(error => {
|
|
121
|
+
reportAnalyticsError(error, 'prepare')
|
|
122
|
+
return [] as Response[]
|
|
123
|
+
})
|
|
97
124
|
},
|
|
98
|
-
[
|
|
125
|
+
[queryClient, session]
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
const publishEvent = useCallback(
|
|
129
|
+
(name: AnalyticsEventName, meta: EventMetadata = {}): Promise<Response[]> =>
|
|
130
|
+
publishEvents([{ name, meta }]),
|
|
131
|
+
[publishEvents]
|
|
99
132
|
)
|
|
100
133
|
|
|
101
134
|
return { publishEvent, publishEvents }
|
package/src/navigation/index.tsx
CHANGED
|
@@ -60,7 +60,10 @@ import {
|
|
|
60
60
|
ConversationSelectTypeScreen,
|
|
61
61
|
ConversationSelectTypeScreenOptions,
|
|
62
62
|
} from '../screens/conversation_select_type_screen'
|
|
63
|
-
import {
|
|
63
|
+
import {
|
|
64
|
+
ConversationsScreen,
|
|
65
|
+
conversationsScreenOptions,
|
|
66
|
+
} from '../screens/conversations/conversations_screen'
|
|
64
67
|
import { GetHelpScreen } from '../screens/get_help_screen'
|
|
65
68
|
import {
|
|
66
69
|
GroupNotificationLevelSelectScreen,
|
|
@@ -181,13 +184,10 @@ export const ChatStack = createNativeStackNavigator({
|
|
|
181
184
|
Conversations: {
|
|
182
185
|
screen: ConversationsScreen,
|
|
183
186
|
options: ({ route, navigation }) =>
|
|
184
|
-
|
|
185
|
-
{
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
},
|
|
189
|
-
withRightClose({ onPress: navigation.goBack })
|
|
190
|
-
),
|
|
187
|
+
conversationsScreenOptions({
|
|
188
|
+
title: (route.params as { title?: string })?.title,
|
|
189
|
+
onClose: navigation.goBack,
|
|
190
|
+
}),
|
|
191
191
|
},
|
|
192
192
|
ConversationFilters: {
|
|
193
193
|
screen: ConversationFiltersScreen,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { DefaultTheme, ThemeProvider } from '@react-navigation/native'
|
|
1
|
+
import { DefaultTheme, StackActions, ThemeProvider } from '@react-navigation/native'
|
|
2
2
|
import { fireEvent, render } from '@testing-library/react-native'
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
5
5
|
import type { ConversationResource } from '../../types'
|
|
6
6
|
import { ConversationActionsScreen } from '../conversation_actions_screen'
|
|
7
7
|
|
|
8
|
-
const mockNavigation = { goBack: jest.fn() }
|
|
8
|
+
const mockNavigation = { goBack: jest.fn(), dispatch: jest.fn(), navigate: jest.fn() }
|
|
9
9
|
jest.mock('@react-navigation/native', () => ({
|
|
10
10
|
...jest.requireActual('@react-navigation/native'),
|
|
11
11
|
useNavigation: () => mockNavigation,
|
|
@@ -15,9 +15,20 @@ jest.mock('@react-navigation/elements', () => ({
|
|
|
15
15
|
useHeaderHeight: () => 0,
|
|
16
16
|
}))
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
let mockConversation = { type: 'Conversation', id: 7, title: 'Youth Group' } as ConversationResource
|
|
19
|
+
const mockSetMuted = jest.fn()
|
|
19
20
|
jest.mock('../../hooks/use_conversation', () => ({
|
|
20
|
-
useConversation: () => ({ data:
|
|
21
|
+
useConversation: () => ({ data: mockConversation }),
|
|
22
|
+
useConversationMute: () => ({ muted: false, setMuted: mockSetMuted, isPending: false }),
|
|
23
|
+
}))
|
|
24
|
+
|
|
25
|
+
const mockMarkRead = jest.fn()
|
|
26
|
+
jest.mock('../../hooks/use_conversations_actions', () => ({
|
|
27
|
+
useConversationsMarkRead: () => ({ read: true, markRead: mockMarkRead, isPending: false }),
|
|
28
|
+
}))
|
|
29
|
+
jest.mock('../../components/display', () => ({
|
|
30
|
+
...jest.requireActual('../../components/display'),
|
|
31
|
+
ConversationAvatar: () => null,
|
|
21
32
|
}))
|
|
22
33
|
|
|
23
34
|
let mockHidden = false
|
|
@@ -36,11 +47,11 @@ const safeAreaMetrics = {
|
|
|
36
47
|
insets: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
37
48
|
}
|
|
38
49
|
|
|
39
|
-
const renderScreen = () =>
|
|
50
|
+
const renderScreen = (params: { read?: boolean; muted?: boolean } = {}) =>
|
|
40
51
|
render(
|
|
41
52
|
<SafeAreaProvider initialMetrics={safeAreaMetrics}>
|
|
42
53
|
<ThemeProvider value={DefaultTheme}>
|
|
43
|
-
<ConversationActionsScreen route={{ params: { conversation_id: 7 } }} />
|
|
54
|
+
<ConversationActionsScreen route={{ params: { conversation_id: 7, ...params } }} />
|
|
44
55
|
</ThemeProvider>
|
|
45
56
|
</SafeAreaProvider>
|
|
46
57
|
)
|
|
@@ -49,6 +60,7 @@ describe('ConversationActionsScreen', () => {
|
|
|
49
60
|
beforeEach(() => {
|
|
50
61
|
mockHidden = false
|
|
51
62
|
mockHideEnabled = true
|
|
63
|
+
mockConversation = { type: 'Conversation', id: 7, title: 'Youth Group' } as ConversationResource
|
|
52
64
|
jest.clearAllMocks()
|
|
53
65
|
})
|
|
54
66
|
|
|
@@ -57,6 +69,17 @@ describe('ConversationActionsScreen', () => {
|
|
|
57
69
|
const { queryByText } = renderScreen()
|
|
58
70
|
|
|
59
71
|
expect(queryByText('Hide conversation')).toBeNull()
|
|
72
|
+
expect(queryByText('Select conversations')).toBeNull()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('asks the conversation list to enter select mode with this conversation', () => {
|
|
76
|
+
const { getByText } = renderScreen()
|
|
77
|
+
|
|
78
|
+
fireEvent.press(getByText('Select conversations'))
|
|
79
|
+
|
|
80
|
+
expect(mockNavigation.dispatch).toHaveBeenCalledWith(
|
|
81
|
+
StackActions.popTo('Conversations', { select_conversation_id: 7 }, { merge: true })
|
|
82
|
+
)
|
|
60
83
|
})
|
|
61
84
|
|
|
62
85
|
it('hides the conversation and closes the sheet', () => {
|
|
@@ -76,4 +99,23 @@ describe('ConversationActionsScreen', () => {
|
|
|
76
99
|
|
|
77
100
|
expect(mockSetHidden).toHaveBeenCalledWith(false)
|
|
78
101
|
})
|
|
102
|
+
|
|
103
|
+
it('toggles read and silenced from the state the list row passed in', () => {
|
|
104
|
+
const { getByText } = renderScreen({ read: false, muted: true })
|
|
105
|
+
|
|
106
|
+
fireEvent.press(getByText('Mark as read'))
|
|
107
|
+
fireEvent.press(getByText('Enable'))
|
|
108
|
+
|
|
109
|
+
expect(mockMarkRead).toHaveBeenCalledWith(true)
|
|
110
|
+
expect(mockSetMuted).toHaveBeenCalledWith(false)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
it('offers neither silence nor hide on an archived conversation', () => {
|
|
114
|
+
mockConversation = { ...mockConversation, disabled: true, disabledReason: 'archived' }
|
|
115
|
+
const { queryByText, getByText } = renderScreen()
|
|
116
|
+
|
|
117
|
+
expect(queryByText('Silence')).toBeNull()
|
|
118
|
+
expect(queryByText('Hide conversation')).toBeNull()
|
|
119
|
+
expect(getByText('Select conversations')).toBeTruthy()
|
|
120
|
+
})
|
|
79
121
|
})
|
|
@@ -257,16 +257,6 @@ describe('ConversationDetailsScreen archive', () => {
|
|
|
257
257
|
expect(queryByText('Archive conversation…')).toBeNull()
|
|
258
258
|
})
|
|
259
259
|
|
|
260
|
-
it.each(['QA_MOBILE_manual_archiving', 'ROLLOUT_MOBILE_manual_archiving'])(
|
|
261
|
-
'offers archiving with only %s on',
|
|
262
|
-
flag => {
|
|
263
|
-
mockEnabledFeatures = [flag]
|
|
264
|
-
const { getByText } = renderScreen()
|
|
265
|
-
|
|
266
|
-
expect(getByText('Archive conversation…')).toBeTruthy()
|
|
267
|
-
}
|
|
268
|
-
)
|
|
269
|
-
|
|
270
260
|
it('hides archiving when neither mobile flag is on', () => {
|
|
271
261
|
mockEnabledFeatures = ['ROLLOUT_WEB_manual_archiving']
|
|
272
262
|
const { queryByText } = renderScreen()
|
|
@@ -299,15 +289,6 @@ describe('ConversationDetailsScreen archive', () => {
|
|
|
299
289
|
expect(mockNavigation.goBack).not.toHaveBeenCalled()
|
|
300
290
|
expect(mockNavigation.navigate).not.toHaveBeenCalled()
|
|
301
291
|
})
|
|
302
|
-
|
|
303
|
-
it('does nothing when the confirmation is cancelled', () => {
|
|
304
|
-
const { getByText } = renderScreen()
|
|
305
|
-
fireEvent.press(getByText('Archive conversation…'))
|
|
306
|
-
|
|
307
|
-
alertButton('Cancel')?.onPress?.()
|
|
308
|
-
|
|
309
|
-
expect(mockArchive).not.toHaveBeenCalled()
|
|
310
|
-
})
|
|
311
292
|
})
|
|
312
293
|
|
|
313
294
|
describe('ConversationDetailsScreen hide', () => {
|
|
@@ -10,20 +10,6 @@ import {
|
|
|
10
10
|
|
|
11
11
|
const emptyState = initEmptyAvatarPickerState()
|
|
12
12
|
|
|
13
|
-
describe('initEmptyAvatarPickerState', () => {
|
|
14
|
-
it('starts clean', () => {
|
|
15
|
-
expect(emptyState).toMatchObject({
|
|
16
|
-
activeTab: 'icon',
|
|
17
|
-
selectedType: null,
|
|
18
|
-
selectedKey: null,
|
|
19
|
-
selectedColor: DEFAULT_AVATAR_COLOR_KEY,
|
|
20
|
-
imagePreviewUri: null,
|
|
21
|
-
imageAsset: null,
|
|
22
|
-
isDirty: false,
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
|
|
27
13
|
describe('initAvatarPickerState', () => {
|
|
28
14
|
it('seeds from icon avatar', () => {
|
|
29
15
|
const conversation = {
|
|
@@ -1,39 +1,150 @@
|
|
|
1
|
-
import { StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
1
|
+
import { StackActions, StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import { StyleSheet } from 'react-native'
|
|
3
|
+
import { StyleSheet, View } from 'react-native'
|
|
4
|
+
import { ConversationAvatar, Heading, Text } from '../components/display'
|
|
4
5
|
import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'
|
|
5
|
-
import {
|
|
6
|
+
import { useTheme } from '../hooks'
|
|
7
|
+
import { useConversation, useConversationMute } from '../hooks/use_conversation'
|
|
8
|
+
import { useConversationsMarkRead } from '../hooks/use_conversations_actions'
|
|
6
9
|
import { useHideConversation } from '../hooks/use_hide_conversation'
|
|
7
10
|
import { useHideConversationsEnabled } from '../hooks/use_hide_conversations_enabled'
|
|
11
|
+
import { isArchivedConversation, MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../utils'
|
|
8
12
|
|
|
9
13
|
export const ConversationActionsScreenOptions = getFormSheetScreenOptions({
|
|
10
14
|
headerTitle: 'Conversation actions',
|
|
15
|
+
sheetAllowedDetents: 'fitToContents',
|
|
11
16
|
})
|
|
12
17
|
|
|
13
18
|
export type ConversationActionsScreenProps = StaticScreenProps<{
|
|
14
19
|
conversation_id: number
|
|
20
|
+
read?: boolean
|
|
21
|
+
muted?: boolean
|
|
15
22
|
}>
|
|
16
23
|
|
|
17
24
|
export function ConversationActionsScreen({ route }: ConversationActionsScreenProps) {
|
|
18
25
|
const navigation = useNavigation()
|
|
19
26
|
const styles = useStyles()
|
|
20
|
-
const {
|
|
21
|
-
const {
|
|
27
|
+
const { conversation_id } = route.params
|
|
28
|
+
const { data: conversation } = useConversation({ conversation_id })
|
|
29
|
+
const { hidden, setHidden, isPending: isHiddenPending } = useHideConversation({ conversation })
|
|
30
|
+
const markReadState = useConversationsMarkRead({ conversation })
|
|
31
|
+
const muteState = useConversationMute({ conversation_id })
|
|
22
32
|
const hideConversationsEnabled = useHideConversationsEnabled()
|
|
23
33
|
|
|
34
|
+
const read = route.params.read ?? markReadState.read
|
|
35
|
+
const muted = route.params.muted ?? muteState.muted
|
|
36
|
+
const archived = isArchivedConversation(conversation)
|
|
37
|
+
const emptyConversation = conversation.lastMessageCreatedAt === null
|
|
38
|
+
const subtitle = conversation.badges?.[0]?.text
|
|
39
|
+
|
|
40
|
+
const navigateAfterDismiss = (navigate: () => void) => {
|
|
41
|
+
navigation.goBack()
|
|
42
|
+
requestAnimationFrame(navigate)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const handleOpenPress = () =>
|
|
46
|
+
navigateAfterDismiss(() =>
|
|
47
|
+
navigation.navigate('Conversation', {
|
|
48
|
+
conversation_id,
|
|
49
|
+
title: conversation.title ?? undefined,
|
|
50
|
+
badge: conversation.badges?.[0],
|
|
51
|
+
deleted: conversation.deleted,
|
|
52
|
+
muted,
|
|
53
|
+
})
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const handleDetailsPress = () =>
|
|
57
|
+
navigateAfterDismiss(() => navigation.navigate('ConversationDetails', { conversation_id }))
|
|
58
|
+
|
|
59
|
+
const handleMarkReadPress = () => {
|
|
60
|
+
markReadState.markRead(!read)
|
|
61
|
+
navigation.goBack()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const handleMutePress = () => {
|
|
65
|
+
muteState.setMuted(!muted)
|
|
66
|
+
navigation.goBack()
|
|
67
|
+
}
|
|
68
|
+
|
|
24
69
|
const handleHidePress = () => {
|
|
25
70
|
setHidden(!hidden)
|
|
26
71
|
navigation.goBack()
|
|
27
72
|
}
|
|
28
73
|
|
|
74
|
+
const handleSelectPress = () => {
|
|
75
|
+
navigation.dispatch(
|
|
76
|
+
StackActions.popTo(
|
|
77
|
+
'Conversations',
|
|
78
|
+
{ select_conversation_id: conversation_id },
|
|
79
|
+
{ merge: true }
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!hideConversationsEnabled) return <FormSheet.Root fitToContents>{null}</FormSheet.Root>
|
|
85
|
+
|
|
29
86
|
return (
|
|
30
|
-
<FormSheet.Root
|
|
31
|
-
|
|
87
|
+
<FormSheet.Root fitToContents>
|
|
88
|
+
<FormSheet.Header>
|
|
89
|
+
<View style={styles.header}>
|
|
90
|
+
<ConversationAvatar conversation={conversation} size="md" showFallback />
|
|
91
|
+
<View style={styles.headerText}>
|
|
92
|
+
<Heading
|
|
93
|
+
variant="h3"
|
|
94
|
+
numberOfLines={1}
|
|
95
|
+
maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}
|
|
96
|
+
>
|
|
97
|
+
{conversation.title}
|
|
98
|
+
</Heading>
|
|
99
|
+
{!!subtitle && (
|
|
100
|
+
<Text
|
|
101
|
+
variant="tertiary"
|
|
102
|
+
numberOfLines={1}
|
|
103
|
+
maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}
|
|
104
|
+
>
|
|
105
|
+
{subtitle}
|
|
106
|
+
</Text>
|
|
107
|
+
)}
|
|
108
|
+
</View>
|
|
109
|
+
</View>
|
|
110
|
+
</FormSheet.Header>
|
|
111
|
+
<FormSheet.Action
|
|
112
|
+
onPress={handleOpenPress}
|
|
113
|
+
title="Open conversation"
|
|
114
|
+
iconName="general.textMessage"
|
|
115
|
+
/>
|
|
116
|
+
<FormSheet.Action
|
|
117
|
+
onPress={handleDetailsPress}
|
|
118
|
+
title="Conversation details"
|
|
119
|
+
iconName="general.cog"
|
|
120
|
+
/>
|
|
121
|
+
{!emptyConversation && (
|
|
122
|
+
<FormSheet.Action
|
|
123
|
+
onPress={handleMarkReadPress}
|
|
124
|
+
title={read ? 'Mark as unread' : 'Mark as read'}
|
|
125
|
+
iconName={read ? 'checkIns.checkPending' : 'checkIns.check'}
|
|
126
|
+
disabled={markReadState.isPending}
|
|
127
|
+
/>
|
|
128
|
+
)}
|
|
129
|
+
{!archived && (
|
|
130
|
+
<FormSheet.Action
|
|
131
|
+
onPress={handleMutePress}
|
|
132
|
+
title={muted ? 'Enable' : 'Silence'}
|
|
133
|
+
iconName={muted ? 'general.bell' : 'general.bellMuted'}
|
|
134
|
+
disabled={muteState.isPending}
|
|
135
|
+
accessibilityHint={
|
|
136
|
+
muted
|
|
137
|
+
? 'Turns notifications for this conversation back on.'
|
|
138
|
+
: 'Turns off notifications for this conversation.'
|
|
139
|
+
}
|
|
140
|
+
/>
|
|
141
|
+
)}
|
|
142
|
+
{!archived && (
|
|
32
143
|
<FormSheet.Action
|
|
33
144
|
onPress={handleHidePress}
|
|
34
145
|
title={hidden ? 'Unhide conversation' : 'Hide conversation'}
|
|
35
146
|
iconName={hidden ? 'general.showEye' : 'general.hideEye'}
|
|
36
|
-
disabled={
|
|
147
|
+
disabled={isHiddenPending}
|
|
37
148
|
accessibilityHint={
|
|
38
149
|
hidden
|
|
39
150
|
? 'Shows this conversation in your conversation list again.'
|
|
@@ -41,13 +152,35 @@ export function ConversationActionsScreen({ route }: ConversationActionsScreenPr
|
|
|
41
152
|
}
|
|
42
153
|
/>
|
|
43
154
|
)}
|
|
155
|
+
<View style={styles.divider} />
|
|
156
|
+
<FormSheet.Action
|
|
157
|
+
onPress={handleSelectPress}
|
|
158
|
+
title="Select conversations"
|
|
159
|
+
iconName="general.check"
|
|
160
|
+
accessibilityHint="Selects this conversation and lets you choose more to hide, silence, or mark read."
|
|
161
|
+
/>
|
|
44
162
|
</FormSheet.Root>
|
|
45
163
|
)
|
|
46
164
|
}
|
|
47
165
|
|
|
48
|
-
const useStyles = () =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
166
|
+
const useStyles = () => {
|
|
167
|
+
const { colors } = useTheme()
|
|
168
|
+
|
|
169
|
+
return StyleSheet.create({
|
|
170
|
+
header: {
|
|
171
|
+
flex: 1,
|
|
172
|
+
flexDirection: 'row',
|
|
173
|
+
alignItems: 'center',
|
|
174
|
+
gap: 12,
|
|
175
|
+
},
|
|
176
|
+
headerText: {
|
|
177
|
+
flex: 1,
|
|
178
|
+
},
|
|
179
|
+
divider: {
|
|
180
|
+
height: 1,
|
|
181
|
+
marginHorizontal: 16,
|
|
182
|
+
marginVertical: 4,
|
|
183
|
+
backgroundColor: colors.borderColorDefaultBase,
|
|
52
184
|
},
|
|
53
185
|
})
|
|
186
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type RouteProp, useRoute } from '@react-navigation/native'
|
|
2
|
-
import { Pressable,
|
|
3
|
-
import {
|
|
2
|
+
import { Pressable, StyleSheet, type ViewStyle } from 'react-native'
|
|
3
|
+
import { Checkbox, Text } from '../../../components'
|
|
4
4
|
import { useTheme } from '../../../hooks'
|
|
5
|
-
import { tokens } from '../../../vendor/tapestry/tokens'
|
|
6
5
|
import { ConversationFilterRecipientsScreenProps, SetTeamFilters, TeamProps } from '../types'
|
|
7
6
|
|
|
8
7
|
interface TeamRowProps {
|
|
@@ -43,7 +42,7 @@ export const CheckboxRow = ({
|
|
|
43
42
|
accessibilityLabelledBy={accessibilityLabelledBy}
|
|
44
43
|
accessibilityLabel={`${teamName} team`}
|
|
45
44
|
>
|
|
46
|
-
<
|
|
45
|
+
<Checkbox checked={checked} />
|
|
47
46
|
<Text style={styles.label} numberOfLines={2}>
|
|
48
47
|
{teamName}
|
|
49
48
|
</Text>
|
|
@@ -51,28 +50,9 @@ export const CheckboxRow = ({
|
|
|
51
50
|
)
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
function CheckboxIcon({ checked }: { checked: boolean }) {
|
|
55
|
-
const styles = useStyles()
|
|
56
|
-
const checkedStyle = checked ? styles.checkedContainer : styles.uncheckedContainer
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<View style={checkedStyle}>
|
|
60
|
-
{checked && <Icon name="general.thickCheckmark" style={styles.checkedIcon} />}
|
|
61
|
-
</View>
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
53
|
const useStyles = () => {
|
|
66
54
|
const { colors } = useTheme()
|
|
67
55
|
|
|
68
|
-
const baseCheckboxStyles: ViewStyle = {
|
|
69
|
-
width: 20,
|
|
70
|
-
height: 20,
|
|
71
|
-
borderRadius: 40,
|
|
72
|
-
alignItems: 'center',
|
|
73
|
-
justifyContent: 'center',
|
|
74
|
-
}
|
|
75
|
-
|
|
76
56
|
return StyleSheet.create({
|
|
77
57
|
checkboxRow: {
|
|
78
58
|
flexDirection: 'row',
|
|
@@ -89,17 +69,5 @@ const useStyles = () => {
|
|
|
89
69
|
label: {
|
|
90
70
|
flex: 1,
|
|
91
71
|
},
|
|
92
|
-
checkedContainer: {
|
|
93
|
-
...baseCheckboxStyles,
|
|
94
|
-
backgroundColor: colors.statusSuccessIcon,
|
|
95
|
-
},
|
|
96
|
-
uncheckedContainer: {
|
|
97
|
-
...baseCheckboxStyles,
|
|
98
|
-
borderWidth: 2,
|
|
99
|
-
borderColor: colors.borderColorDefaultDarker,
|
|
100
|
-
},
|
|
101
|
-
checkedIcon: {
|
|
102
|
-
color: tokens.colorNeutral100White,
|
|
103
|
-
},
|
|
104
72
|
})
|
|
105
73
|
}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
useGroupMembersForNewConversation,
|
|
13
13
|
} from '../../../hooks/groups/use_group_members_for_new_conversation'
|
|
14
14
|
import { useGroupsConversationCreate } from '../../../hooks/groups/use_groups_conversation_create'
|
|
15
|
+
import { useGroupsProxy } from '../../../hooks/groups/use_groups_proxy'
|
|
15
16
|
import {
|
|
16
17
|
type AvatarUpdatePayload,
|
|
17
18
|
patchConversationAvatar,
|
|
@@ -50,15 +51,16 @@ export const GroupsForm = ({ groupId, chat_group_graph_id, avatarSelection }: Gr
|
|
|
50
51
|
genderValue,
|
|
51
52
|
isFetching: genderFetching,
|
|
52
53
|
} = useMyGender()
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
const groupsProxied = useGroupsProxy()
|
|
55
|
+
const { data: group } = useSuspenseGet<GroupsGroupResource>(
|
|
56
|
+
groupsProxied
|
|
57
|
+
? {
|
|
58
|
+
url: `/me/groups_groups/${groupId}`,
|
|
59
|
+
data: { fields: { GroupsGroup: ['name', 'memberships_count'] } },
|
|
60
|
+
app: 'chat',
|
|
61
|
+
}
|
|
62
|
+
: { url: `/me/groups/${groupId}`, data: { fields: { Group: [] } }, app: 'groups' }
|
|
63
|
+
)
|
|
62
64
|
|
|
63
65
|
const activeGenderId = genderFilterEnabled ? genderId : null
|
|
64
66
|
const activeGenderValue = genderFilterEnabled ? genderValue : null
|