@planningcenter/chat-react-native 4.7.1-qa-staging.8 → 4.7.1-qa-1119.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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/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_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/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/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/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/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/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/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 +3 -3
- 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__/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/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/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_mark_latest_message_read.ts +6 -5
- 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/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/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/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/configuration.ts +5 -0
- package/src/utils/native_adapters/index.ts +1 -0
- package/src/utils/native_adapters/updates.ts +16 -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
|
@@ -17,7 +17,7 @@ export const useConversationsMarkRead = ({
|
|
|
17
17
|
const queryClient = useQueryClient()
|
|
18
18
|
const { args } = useConversationsContext()
|
|
19
19
|
const currentPersonCache = useCurrentPersonCache()
|
|
20
|
-
const { updateInAllLists, invalidateAllLists
|
|
20
|
+
const { updateInAllLists, invalidateAllLists } = useConversationsCache(args)
|
|
21
21
|
const conversationQueryKey = getRequestQueryKey(
|
|
22
22
|
getConversationRequestArgs({ conversation_id: conversation.id })
|
|
23
23
|
)
|
|
@@ -48,13 +48,16 @@ export const useConversationsMarkRead = ({
|
|
|
48
48
|
mutationFn: async (read: boolean) => {
|
|
49
49
|
const action = read ? 'mark_read' : 'mark_unread'
|
|
50
50
|
|
|
51
|
-
return apiClient.chat.post({
|
|
51
|
+
return apiClient.chat.post<ApiResource<ConversationResource>>({
|
|
52
52
|
url: `/me/conversations/${conversation.id}/${action}`,
|
|
53
53
|
data: { data: { type: '', attributes: {} }, fields: { Conversation: 'unread_count,id' } },
|
|
54
54
|
})
|
|
55
55
|
},
|
|
56
|
-
onSuccess:
|
|
57
|
-
|
|
56
|
+
onSuccess: response => {
|
|
57
|
+
const unreadCount = response.data?.unreadCount
|
|
58
|
+
if (unreadCount === undefined) return
|
|
59
|
+
|
|
60
|
+
updateInAllLists(conversation.id, { unreadCount })
|
|
58
61
|
},
|
|
59
62
|
onError: () => {
|
|
60
63
|
Alert.alert('Oops', 'Something went wrong updating this conversation, please try again')
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { InfiniteData, useQueryClient } from '@tanstack/react-query'
|
|
1
|
+
import { InfiniteData, QueryKey, useQueryClient } from '@tanstack/react-query'
|
|
2
2
|
import { ApiCollection, ConversationResource } from '../types'
|
|
3
3
|
import {
|
|
4
4
|
deleteRecordInPagesData,
|
|
5
|
-
updateRecordInPagesData,
|
|
6
5
|
updateAllRecordsInPagesData,
|
|
7
6
|
updateOrCreateRecordInPagesData,
|
|
8
7
|
} from '../utils'
|
|
@@ -11,6 +10,7 @@ import { useApiClient } from './use_api_client'
|
|
|
11
10
|
import { getRequestQueryKey } from './use_suspense_api'
|
|
12
11
|
|
|
13
12
|
type QueryData = InfiniteData<ApiCollection<ConversationResource>>
|
|
13
|
+
export type ConversationListsSnapshot = Array<[QueryKey, QueryData | undefined]>
|
|
14
14
|
|
|
15
15
|
export function useConversationsCache(args?: Partial<ConversationRequestArgs>) {
|
|
16
16
|
const apiClient = useApiClient()
|
|
@@ -44,20 +44,6 @@ export function useConversationsCache(args?: Partial<ConversationRequestArgs>) {
|
|
|
44
44
|
)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const updateOnly = async (conversation: ConversationResource) => {
|
|
48
|
-
if (!conversation.id) return
|
|
49
|
-
|
|
50
|
-
queryClient.setQueryData<QueryData>(conversationQueryKey, prev =>
|
|
51
|
-
updateRecordInPagesData({
|
|
52
|
-
data: prev,
|
|
53
|
-
record: conversation,
|
|
54
|
-
processRecord: (record, current) => {
|
|
55
|
-
return { ...current, ...record }
|
|
56
|
-
},
|
|
57
|
-
})
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
47
|
const updateAll = async (update: Partial<ConversationResource>) => {
|
|
62
48
|
queryClient.setQueryData<QueryData>(conversationQueryKey, prev =>
|
|
63
49
|
updateAllRecordsInPagesData({
|
|
@@ -78,8 +64,32 @@ export function useConversationsCache(args?: Partial<ConversationRequestArgs>) {
|
|
|
78
64
|
})
|
|
79
65
|
}
|
|
80
66
|
|
|
81
|
-
const
|
|
82
|
-
|
|
67
|
+
const listsQueryKey = (filter?: string) =>
|
|
68
|
+
filter ? [conversationsRequestArgs.url, { filter }] : [conversationsRequestArgs.url]
|
|
69
|
+
|
|
70
|
+
const invalidateAllLists = ({ filter }: { filter?: string } = {}) =>
|
|
71
|
+
queryClient.invalidateQueries({ queryKey: listsQueryKey(filter) })
|
|
72
|
+
|
|
73
|
+
const cancelAllLists = () => queryClient.cancelQueries({ queryKey: listsQueryKey() })
|
|
74
|
+
|
|
75
|
+
const snapshotAllLists = (): ConversationListsSnapshot =>
|
|
76
|
+
queryClient.getQueriesData<QueryData>({ queryKey: listsQueryKey() })
|
|
77
|
+
|
|
78
|
+
const restoreLists = (lists: ConversationListsSnapshot) =>
|
|
79
|
+
lists.forEach(([queryKey, data]) => queryClient.setQueryData<QueryData>(queryKey, data))
|
|
80
|
+
|
|
81
|
+
const removeFromAllLists = (ids: number[], { filter }: { filter?: string } = {}) =>
|
|
82
|
+
queryClient.setQueriesData<QueryData>({ queryKey: listsQueryKey(filter) }, prev => {
|
|
83
|
+
if (!prev?.pages) return prev
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
...prev,
|
|
87
|
+
pages: prev.pages.map(page => ({
|
|
88
|
+
...page,
|
|
89
|
+
data: page.data.filter(({ id }) => !ids.includes(id)),
|
|
90
|
+
})),
|
|
91
|
+
}
|
|
92
|
+
})
|
|
83
93
|
|
|
84
94
|
const handleConversationDestroy = ({ id }: { id: number }) => {
|
|
85
95
|
if (!id) return
|
|
@@ -92,13 +102,6 @@ export function useConversationsCache(args?: Partial<ConversationRequestArgs>) {
|
|
|
92
102
|
)
|
|
93
103
|
}
|
|
94
104
|
|
|
95
|
-
const fetchAndUpdate = async ({ id }: { id: number }) => {
|
|
96
|
-
const conversation = await fetchConversation(id).catch(() => undefined)
|
|
97
|
-
if (!conversation) return
|
|
98
|
-
|
|
99
|
-
updateOnly(conversation)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
105
|
const fetchAndSync = async ({ id }: { id: number }) => {
|
|
103
106
|
let conversation: ConversationResource | undefined
|
|
104
107
|
try {
|
|
@@ -115,12 +118,16 @@ export function useConversationsCache(args?: Partial<ConversationRequestArgs>) {
|
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
return {
|
|
121
|
+
cancelAllLists,
|
|
122
|
+
queryKey: conversationQueryKey,
|
|
118
123
|
create: updateOrCreate,
|
|
119
124
|
destroy: handleConversationDestroy,
|
|
120
125
|
fetchSync: fetchAndSync,
|
|
121
|
-
fetchUpdate: fetchAndUpdate,
|
|
122
126
|
invalidate: () => queryClient.invalidateQueries({ queryKey: conversationQueryKey }),
|
|
123
127
|
invalidateAllLists,
|
|
128
|
+
removeFromAllLists,
|
|
129
|
+
restoreLists,
|
|
130
|
+
snapshotAllLists,
|
|
124
131
|
update: updateOrCreate,
|
|
125
132
|
updateAll,
|
|
126
133
|
updateInAllLists,
|
|
@@ -1,37 +1,48 @@
|
|
|
1
|
+
import { useQueryClient } from '@tanstack/react-query'
|
|
1
2
|
import { useConversationsContext } from '../contexts/conversations_context'
|
|
2
3
|
import { CurrentPersonResource } from '../types'
|
|
3
|
-
import { JoltConversationEvent } from '../types/jolt_events'
|
|
4
|
+
import { JoltConversationEvent, StreamUserUpdatedEvent } from '../types/jolt_events'
|
|
5
|
+
import { parseStreamUserEventType } from '../utils/jolt/parse_stream_user_event_type'
|
|
4
6
|
import { completeMessageCreationConversationTracking } from '../utils/performance_tracking'
|
|
7
|
+
import { throttledRefresh } from '../utils/throttled_refresh'
|
|
5
8
|
import { useApiGet } from './use_api'
|
|
6
9
|
import { useApiClient } from './use_api_client'
|
|
7
10
|
import { useConversationsCache } from './use_conversations_cache'
|
|
8
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
currentPersonQueryKey,
|
|
13
|
+
currentPersonRequestArgs,
|
|
14
|
+
useCurrentPersonCache,
|
|
15
|
+
} from './use_current_person'
|
|
9
16
|
import { useJoltChannel, useJoltEvent } from './use_jolt'
|
|
10
17
|
|
|
11
18
|
const useCurrentPerson = () => {
|
|
12
19
|
return useApiGet<CurrentPersonResource>(currentPersonRequestArgs)
|
|
13
20
|
}
|
|
14
21
|
|
|
22
|
+
const refreshesCurrentPerson = (event: StreamUserUpdatedEvent) => {
|
|
23
|
+
const eventType = parseStreamUserEventType(event)
|
|
24
|
+
return eventType === undefined || eventType === 'app_grant.synced'
|
|
25
|
+
}
|
|
26
|
+
|
|
15
27
|
export function useConversationsJoltEvents() {
|
|
16
28
|
const { data: currentPerson } = useCurrentPerson()
|
|
17
29
|
const { args } = useConversationsContext()
|
|
18
30
|
const cache = useConversationsCache(args)
|
|
19
31
|
const currentPersonCache = useCurrentPersonCache()
|
|
20
32
|
const apiClient = useApiClient()
|
|
33
|
+
const queryClient = useQueryClient()
|
|
21
34
|
const enabled = currentPerson?.id ? true : false
|
|
22
35
|
const joltChannel = useJoltChannel(`chat.people.${currentPerson?.id}`, enabled)
|
|
23
36
|
|
|
24
37
|
useJoltEvent(joltChannel, 'conversation.updated', (e: JoltConversationEvent) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
e.data.data.last_message_author_id === currentPerson?.id
|
|
28
|
-
) {
|
|
38
|
+
const { id, last_message_idempotent_key, last_message_author_id } = e.data.data
|
|
39
|
+
if (last_message_idempotent_key && last_message_author_id === currentPerson?.id) {
|
|
29
40
|
completeMessageCreationConversationTracking({
|
|
30
41
|
apiClient,
|
|
31
|
-
idempotentKey:
|
|
42
|
+
idempotentKey: last_message_idempotent_key,
|
|
32
43
|
})
|
|
33
44
|
}
|
|
34
|
-
cache.
|
|
45
|
+
throttledRefresh(queryClient, [...cache.queryKey, id], e, () => cache.fetchSync({ id }))
|
|
35
46
|
})
|
|
36
47
|
useJoltEvent(joltChannel, 'conversation.created', (e: JoltConversationEvent) =>
|
|
37
48
|
cache.fetchSync({ id: e.data.data.id })
|
|
@@ -40,6 +51,9 @@ export function useConversationsJoltEvents() {
|
|
|
40
51
|
cache.destroy({ id: e.data.data.id })
|
|
41
52
|
)
|
|
42
53
|
|
|
43
|
-
useJoltEvent(joltChannel, 'STREAM_USER_UPDATED',
|
|
44
|
-
|
|
54
|
+
useJoltEvent(joltChannel, 'STREAM_USER_UPDATED', (e: StreamUserUpdatedEvent) => {
|
|
55
|
+
if (!refreshesCurrentPerson(e)) return
|
|
56
|
+
|
|
57
|
+
throttledRefresh(queryClient, currentPersonQueryKey, e, currentPersonCache.invalidate)
|
|
58
|
+
})
|
|
45
59
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { throttle } from 'lodash'
|
|
2
2
|
import { useEffect, useMemo, useRef } from 'react'
|
|
3
3
|
import { ConversationResource, MessageResource } from '../types'
|
|
4
|
+
import { REFRESH_THROTTLE_MS } from '../utils/throttled_refresh'
|
|
4
5
|
import { useAppState } from './use_app_state'
|
|
5
6
|
import { useConversationsMarkRead } from './use_conversations_actions'
|
|
6
7
|
|
|
@@ -13,8 +14,8 @@ interface Props {
|
|
|
13
14
|
export function useMarkLatestMessageRead({ conversation, enabled = true }: Props) {
|
|
14
15
|
const firedOnce = useRef<boolean>(false)
|
|
15
16
|
const { markRead } = useConversationsMarkRead({ conversation })
|
|
16
|
-
const
|
|
17
|
-
() =>
|
|
17
|
+
const throttledMarkRead = useMemo(
|
|
18
|
+
() => throttle(markRead, REFRESH_THROTTLE_MS, { leading: true, trailing: true }),
|
|
18
19
|
[markRead]
|
|
19
20
|
)
|
|
20
21
|
const unreadCount = conversation.unreadCount
|
|
@@ -30,6 +31,6 @@ export function useMarkLatestMessageRead({ conversation, enabled = true }: Props
|
|
|
30
31
|
|
|
31
32
|
firedOnce.current = true
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
}, [
|
|
34
|
+
throttledMarkRead(true)
|
|
35
|
+
}, [throttledMarkRead, isActive, shouldMarkRead, unreadReaction])
|
|
35
36
|
}
|
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
|
}
|