@planningcenter/chat-react-native 3.2.0-rc.1 → 3.2.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/conversation/message_form.d.ts +2 -2
- package/build/components/conversation/message_form.d.ts.map +1 -1
- package/build/components/conversation/message_form.js +95 -41
- package/build/components/conversation/message_form.js.map +1 -1
- package/build/components/conversation/message_reaction.d.ts +2 -2
- package/build/components/conversations/action_toggle_button.d.ts +21 -0
- package/build/components/conversations/action_toggle_button.d.ts.map +1 -0
- package/build/components/conversations/action_toggle_button.js +48 -0
- package/build/components/conversations/action_toggle_button.js.map +1 -0
- package/build/components/conversations/conversation_actions.d.ts +10 -0
- package/build/components/conversations/conversation_actions.d.ts.map +1 -0
- package/build/components/conversations/conversation_actions.js +84 -0
- package/build/components/conversations/conversation_actions.js.map +1 -0
- package/build/components/conversations/conversation_preview.d.ts +2 -1
- package/build/components/conversations/conversation_preview.d.ts.map +1 -1
- package/build/components/conversations/conversation_preview.js +27 -9
- package/build/components/conversations/conversation_preview.js.map +1 -1
- package/build/components/conversations/conversations.d.ts +2 -3
- package/build/components/conversations/conversations.d.ts.map +1 -1
- package/build/components/conversations/conversations.js +5 -11
- package/build/components/conversations/conversations.js.map +1 -1
- package/build/components/conversations/mute_indicator.d.ts +5 -0
- package/build/components/conversations/mute_indicator.d.ts.map +1 -0
- package/build/components/conversations/mute_indicator.js +19 -0
- package/build/components/conversations/mute_indicator.js.map +1 -0
- package/build/components/conversations/unread_count_badge.d.ts +2 -1
- package/build/components/conversations/unread_count_badge.d.ts.map +1 -1
- package/build/components/conversations/unread_count_badge.js +9 -1
- package/build/components/conversations/unread_count_badge.js.map +1 -1
- package/build/components/display/action_button.js +1 -2
- package/build/components/display/action_button.js.map +1 -1
- package/build/components/display/badge.d.ts +5 -4
- package/build/components/display/badge.d.ts.map +1 -1
- package/build/components/display/badge.js +5 -2
- package/build/components/display/badge.js.map +1 -1
- package/build/components/display/button.d.ts +3 -2
- package/build/components/display/button.d.ts.map +1 -1
- package/build/components/display/button.js.map +1 -1
- package/build/components/display/icon.d.ts +14 -1
- package/build/components/display/icon.d.ts.map +1 -1
- package/build/components/display/icon.js +9 -0
- package/build/components/display/icon.js.map +1 -1
- package/build/components/display/icon_button.d.ts +2 -2
- package/build/components/display/icon_button.d.ts.map +1 -1
- package/build/components/display/icon_button.js.map +1 -1
- package/build/components/display/person.d.ts +3 -1
- package/build/components/display/person.d.ts.map +1 -1
- package/build/components/display/person.js +2 -2
- package/build/components/display/person.js.map +1 -1
- package/build/components/display/text.js.map +1 -1
- package/build/components/display/toggle_button.d.ts +3 -2
- package/build/components/display/toggle_button.d.ts.map +1 -1
- package/build/components/display/toggle_button.js.map +1 -1
- package/build/components/display/utils/button_colors.d.ts +3 -3
- package/build/components/display/utils/button_colors.d.ts.map +1 -1
- package/build/components/display/utils/button_colors.js +1 -1
- package/build/components/display/utils/button_colors.js.map +1 -1
- package/build/components/page/error_boundary.d.ts +1 -1
- package/build/components/primitive/avatar_primitive.d.ts.map +1 -1
- package/build/components/primitive/avatar_primitive.js +3 -2
- package/build/components/primitive/avatar_primitive.js.map +1 -1
- package/build/components/primitive/banner_primitive.d.ts +2 -1
- package/build/components/primitive/banner_primitive.d.ts.map +1 -1
- package/build/components/primitive/banner_primitive.js +0 -1
- package/build/components/primitive/banner_primitive.js.map +1 -1
- package/build/contexts/api_provider.js.map +1 -1
- package/build/contexts/chat_context.d.ts +2 -0
- package/build/contexts/chat_context.d.ts.map +1 -1
- package/build/contexts/chat_context.js +6 -1
- package/build/contexts/chat_context.js.map +1 -1
- package/build/contexts/conversations_context.d.ts +14 -0
- package/build/contexts/conversations_context.d.ts.map +1 -0
- package/build/contexts/conversations_context.js +38 -0
- package/build/contexts/conversations_context.js.map +1 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +214 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.js +50 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.js.map +1 -0
- package/build/hooks/use_conversation.d.ts +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_conversations.d.ts +6 -32
- package/build/hooks/use_conversations.d.ts.map +1 -1
- package/build/hooks/use_conversations.js +15 -14
- package/build/hooks/use_conversations.js.map +1 -1
- package/build/hooks/use_conversations_actions.d.ts +221 -0
- package/build/hooks/use_conversations_actions.d.ts.map +1 -0
- package/build/hooks/use_conversations_actions.js +93 -0
- package/build/hooks/use_conversations_actions.js.map +1 -0
- package/build/hooks/use_conversations_cache.d.ts +18 -0
- package/build/hooks/use_conversations_cache.d.ts.map +1 -0
- package/build/hooks/{use_conversation_jolt_events.js → use_conversations_cache.js} +27 -17
- package/build/hooks/use_conversations_cache.js.map +1 -0
- package/build/hooks/use_conversations_jolt_events.d.ts +3 -0
- package/build/hooks/use_conversations_jolt_events.d.ts.map +1 -0
- package/build/hooks/use_conversations_jolt_events.js +12 -0
- package/build/hooks/use_conversations_jolt_events.js.map +1 -0
- package/build/hooks/use_create_android_ripple_color.d.ts +1 -1
- package/build/hooks/use_create_android_ripple_color.d.ts.map +1 -1
- package/build/hooks/use_giphy.d.ts +9 -0
- package/build/hooks/use_giphy.d.ts.map +1 -0
- package/build/hooks/use_giphy.js +63 -0
- package/build/hooks/use_giphy.js.map +1 -0
- package/build/hooks/use_jolt.d.ts.map +1 -1
- package/build/hooks/use_jolt.js +39 -10
- package/build/hooks/use_jolt.js.map +1 -1
- package/build/hooks/use_message_create.d.ts +11 -0
- package/build/hooks/use_message_create.d.ts.map +1 -0
- package/build/hooks/use_message_create.js +35 -0
- package/build/hooks/use_message_create.js.map +1 -0
- package/build/navigation/index.d.ts +23 -6
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +25 -8
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.d.ts.map +1 -0
- package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.js.map +1 -0
- package/build/screens/conversation_filters/components/conversation_filters.js.map +1 -1
- package/build/screens/conversation_filters/components/rows.d.ts +2 -1
- package/build/screens/conversation_filters/components/rows.d.ts.map +1 -1
- package/build/screens/conversation_filters/components/rows.js +19 -14
- package/build/screens/conversation_filters/components/rows.js.map +1 -1
- package/build/screens/conversation_filters/hooks/filters.js +1 -1
- package/build/screens/conversation_filters/hooks/filters.js.map +1 -1
- package/build/screens/conversation_new/components/form_list.d.ts +12 -0
- package/build/screens/conversation_new/components/form_list.d.ts.map +1 -0
- package/build/screens/conversation_new/components/form_list.js +42 -0
- package/build/screens/conversation_new/components/form_list.js.map +1 -0
- package/build/screens/conversation_new/components/groups_form.d.ts +7 -0
- package/build/screens/conversation_new/components/groups_form.d.ts.map +1 -0
- package/build/screens/conversation_new/components/groups_form.js +128 -0
- package/build/screens/conversation_new/components/groups_form.js.map +1 -0
- package/build/screens/conversation_new/components/member_error_card.d.ts +5 -0
- package/build/screens/conversation_new/components/member_error_card.d.ts.map +1 -0
- package/build/screens/conversation_new/components/member_error_card.js +17 -0
- package/build/screens/conversation_new/components/member_error_card.js.map +1 -0
- package/build/screens/conversation_new/components/source_app_error_card.d.ts +2 -0
- package/build/screens/conversation_new/components/source_app_error_card.d.ts.map +1 -0
- package/build/screens/conversation_new/components/source_app_error_card.js +16 -0
- package/build/screens/conversation_new/components/source_app_error_card.js.map +1 -0
- package/build/screens/conversation_new/components/team_form.d.ts +8 -0
- package/build/screens/conversation_new/components/team_form.d.ts.map +1 -0
- package/build/screens/conversation_new/components/team_form.js +11 -0
- package/build/screens/conversation_new/components/team_form.js.map +1 -0
- package/build/screens/conversation_new/conversation_new_screen.d.ts +12 -0
- package/build/screens/conversation_new/conversation_new_screen.d.ts.map +1 -0
- package/build/screens/conversation_new/conversation_new_screen.js +16 -0
- package/build/screens/conversation_new/conversation_new_screen.js.map +1 -0
- package/build/screens/conversation_new/utils/fake_member_data.d.ts +3 -0
- package/build/screens/conversation_new/utils/fake_member_data.d.ts.map +1 -0
- package/build/screens/conversation_new/utils/fake_member_data.js +129 -0
- package/build/screens/conversation_new/utils/fake_member_data.js.map +1 -0
- package/build/screens/conversation_screen.d.ts +1 -0
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +1 -1
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.d.ts.map +1 -0
- package/build/screens/{create → conversation_select_recipients}/conversation_select_recipients_screen.js +6 -5
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.js.map +1 -0
- package/build/screens/conversations/components/chat_group_badge.js +1 -1
- package/build/screens/conversations/components/chat_group_badge.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 +6 -2
- package/build/screens/conversations/components/list_header_component.js.map +1 -1
- package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations/conversations_screen.js +6 -13
- package/build/screens/conversations/conversations_screen.js.map +1 -1
- package/build/screens/design_system_screen.js +1 -0
- package/build/screens/design_system_screen.js.map +1 -1
- package/build/screens/message_actions_screen.d.ts +2 -2
- package/build/screens/message_actions_screen.d.ts.map +1 -1
- package/build/screens/message_actions_screen.js +1 -1
- package/build/screens/message_actions_screen.js.map +1 -1
- package/build/screens/send_giphy_screen.d.ts +10 -0
- package/build/screens/send_giphy_screen.d.ts.map +1 -0
- package/build/screens/send_giphy_screen.js +98 -0
- package/build/screens/send_giphy_screen.js.map +1 -0
- package/build/types/resources/groups/groups_group_resource.d.ts +1 -1
- package/build/types/resources/groups/groups_group_resource.js.map +1 -1
- package/build/types/resources/groups/groups_member_resource_with_person.d.ts +14 -0
- package/build/types/resources/groups/groups_member_resource_with_person.d.ts.map +1 -0
- package/build/types/resources/groups/groups_member_resource_with_person.js +2 -0
- package/build/types/resources/groups/groups_member_resource_with_person.js.map +1 -0
- package/build/types/resources/member.d.ts +0 -10
- package/build/types/resources/member.d.ts.map +1 -1
- package/build/types/resources/member.js.map +1 -1
- package/build/utils/cache/page_mutations.d.ts +18 -0
- package/build/utils/cache/page_mutations.d.ts.map +1 -1
- package/build/utils/cache/page_mutations.js +13 -0
- package/build/utils/cache/page_mutations.js.map +1 -1
- package/build/utils/client/client.d.ts +2 -2
- package/build/utils/client/client.d.ts.map +1 -1
- package/build/utils/client/client.js +12 -4
- package/build/utils/client/client.js.map +1 -1
- package/build/utils/client/request_helpers.d.ts +15 -8
- package/build/utils/client/request_helpers.d.ts.map +1 -1
- package/build/utils/client/request_helpers.js +2 -1
- package/build/utils/client/request_helpers.js.map +1 -1
- package/build/utils/client/transform_request_data.d.ts +11 -6
- package/build/utils/client/transform_request_data.d.ts.map +1 -1
- package/build/utils/client/transform_request_data.js +1 -1
- package/build/utils/client/transform_request_data.js.map +1 -1
- package/build/utils/client/transform_response.d.ts +1 -1
- package/build/utils/client/transform_response.d.ts.map +1 -1
- package/build/utils/client/transform_response.js +2 -0
- package/build/utils/client/transform_response.js.map +1 -1
- package/build/utils/client/utils.d.ts +3 -3
- package/build/utils/client/utils.d.ts.map +1 -1
- package/build/utils/client/utils.js +6 -6
- package/build/utils/client/utils.js.map +1 -1
- package/build/utils/date.d.ts.map +1 -1
- package/build/utils/date.js +1 -0
- package/build/utils/date.js.map +1 -1
- package/build/utils/deepCamelCaseKeys.d.ts.map +1 -1
- package/build/utils/deepCamelCaseKeys.js +3 -1
- package/build/utils/deepCamelCaseKeys.js.map +1 -1
- package/build/utils/parse_simple_markdown.d.ts +1 -1
- package/build/utils/parse_simple_markdown.d.ts.map +1 -1
- package/build/utils/parse_simple_markdown.js +2 -1
- package/build/utils/parse_simple_markdown.js.map +1 -1
- package/build/utils/request/conversation.d.ts +1 -3
- package/build/utils/request/conversation.d.ts.map +1 -1
- package/build/utils/request/conversation.js +37 -30
- package/build/utils/request/conversation.js.map +1 -1
- package/build/utils/space.js.map +1 -1
- package/build/utils/uri.d.ts +2 -2
- package/build/utils/uri.d.ts.map +1 -1
- package/build/utils/uri.js +2 -2
- package/build/utils/uri.js.map +1 -1
- package/build/vendor/tapestry/alias_tokens_color_map.d.ts +8 -0
- package/build/vendor/tapestry/alias_tokens_color_map.d.ts.map +1 -1
- package/build/vendor/tapestry/alias_tokens_color_map.js +8 -0
- package/build/vendor/tapestry/alias_tokens_color_map.js.map +1 -1
- package/build/vendor/tapestry/tokens.d.ts +2 -0
- package/build/vendor/tapestry/tokens.d.ts.map +1 -1
- package/build/vendor/tapestry/tokens.js +2 -0
- package/build/vendor/tapestry/tokens.js.map +1 -1
- package/package.json +8 -6
- package/src/__tests__/utils/cache/page_mutations.ts +49 -15
- package/src/components/conversation/message_form.tsx +127 -58
- package/src/components/conversations/action_toggle_button.tsx +84 -0
- package/src/components/conversations/conversation_actions.tsx +146 -0
- package/src/components/conversations/conversation_preview.tsx +46 -16
- package/src/components/conversations/conversations.tsx +13 -18
- package/src/components/conversations/mute_indicator.tsx +21 -0
- package/src/components/conversations/unread_count_badge.tsx +8 -1
- package/src/components/display/action_button.tsx +1 -2
- package/src/components/display/badge.tsx +12 -8
- package/src/components/display/button.tsx +3 -3
- package/src/components/display/icon.tsx +16 -3
- package/src/components/display/icon_button.tsx +2 -2
- package/src/components/display/person.tsx +4 -3
- package/src/components/display/text.tsx +1 -1
- package/src/components/display/toggle_button.tsx +3 -3
- package/src/components/display/utils/button_colors.ts +8 -3
- package/src/components/primitive/avatar_primitive.tsx +5 -3
- package/src/components/primitive/banner_primitive.tsx +2 -3
- package/src/contexts/api_provider.tsx +1 -1
- package/src/contexts/chat_context.tsx +8 -1
- package/src/contexts/conversations_context.tsx +69 -0
- package/src/hooks/groups/use_group_members_for_new_conversation.ts +57 -0
- package/src/hooks/use_conversation.ts +5 -5
- package/src/hooks/use_conversations.ts +34 -16
- package/src/hooks/use_conversations_actions.ts +108 -0
- package/src/hooks/{use_conversation_jolt_events.ts → use_conversations_cache.ts} +35 -20
- package/src/hooks/use_conversations_jolt_events.ts +21 -0
- package/src/hooks/use_giphy.ts +97 -0
- package/src/hooks/use_jolt.ts +53 -12
- package/src/hooks/use_message_create.ts +55 -0
- package/src/navigation/index.tsx +31 -8
- package/src/screens/conversation_filters/components/conversation_filters.tsx +1 -1
- package/src/screens/conversation_filters/components/rows.tsx +44 -14
- package/src/screens/conversation_filters/hooks/filters.ts +1 -1
- package/src/screens/conversation_new/components/form_list.tsx +67 -0
- package/src/screens/conversation_new/components/groups_form.tsx +191 -0
- package/src/screens/conversation_new/components/member_error_card.tsx +20 -0
- package/src/screens/conversation_new/components/source_app_error_card.tsx +24 -0
- package/src/screens/conversation_new/components/team_form.tsx +18 -0
- package/src/screens/conversation_new/conversation_new_screen.tsx +26 -0
- package/src/screens/conversation_new/utils/fake_member_data.ts +130 -0
- package/src/screens/conversation_screen.tsx +2 -1
- package/src/screens/{create → conversation_select_recipients}/conversation_select_recipients_screen.tsx +6 -5
- package/src/screens/conversations/components/chat_group_badge.tsx +1 -1
- package/src/screens/conversations/components/list_header_component.tsx +7 -2
- package/src/screens/conversations/conversations_screen.tsx +6 -19
- package/src/screens/design_system_screen.tsx +1 -0
- package/src/screens/message_actions_screen.tsx +4 -4
- package/src/screens/send_giphy_screen.tsx +155 -0
- package/src/types/resources/groups/groups_group_resource.ts +1 -1
- package/src/types/resources/groups/groups_member_resource_with_person.ts +13 -0
- package/src/types/resources/member.ts +0 -11
- package/src/utils/cache/page_mutations.ts +22 -0
- package/src/utils/client/client.ts +15 -7
- package/src/utils/client/request_helpers.ts +15 -6
- package/src/utils/client/transform_request_data.ts +13 -4
- package/src/utils/client/transform_response.ts +3 -0
- package/src/utils/client/types.d.ts +2 -1
- package/src/utils/client/utils.ts +13 -12
- package/src/utils/date.ts +1 -0
- package/src/utils/deepCamelCaseKeys.ts +3 -2
- package/src/utils/parse_simple_markdown.ts +3 -1
- package/src/utils/request/conversation.ts +39 -34
- package/src/utils/space.ts +1 -1
- package/src/utils/uri.ts +2 -2
- package/src/vendor/tapestry/alias_tokens_color_map.ts +12 -0
- package/src/vendor/tapestry/tokens.ts +2 -0
- package/build/hooks/use_conversation_jolt_events.d.ts +0 -2
- package/build/hooks/use_conversation_jolt_events.d.ts.map +0 -1
- package/build/hooks/use_conversation_jolt_events.js.map +0 -1
- package/build/screens/create/conversation_create_screen.d.ts +0 -9
- package/build/screens/create/conversation_create_screen.d.ts.map +0 -1
- package/build/screens/create/conversation_create_screen.js +0 -123
- package/build/screens/create/conversation_create_screen.js.map +0 -1
- package/build/screens/create/conversation_filter_recipients_screen.d.ts.map +0 -1
- package/build/screens/create/conversation_filter_recipients_screen.js.map +0 -1
- package/build/screens/create/conversation_select_recipients_screen.d.ts.map +0 -1
- package/build/screens/create/conversation_select_recipients_screen.js.map +0 -1
- package/src/screens/create/conversation_create_screen.tsx +0 -148
- /package/build/screens/{create → conversation_filter_recipients}/conversation_filter_recipients_screen.d.ts +0 -0
- /package/build/screens/{create → conversation_filter_recipients}/conversation_filter_recipients_screen.js +0 -0
- /package/build/screens/{create → conversation_select_recipients}/conversation_select_recipients_screen.d.ts +0 -0
- /package/src/screens/{create → conversation_filter_recipients}/conversation_filter_recipients_screen.tsx +0 -0
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { StyleSheet, View } from 'react-native'
|
|
3
3
|
import { ConversationResource } from '../../types'
|
|
4
4
|
import { AvatarGroup, Heading, Text, Badge } from '../display'
|
|
5
5
|
import { formatDatePreview } from '../../utils/date'
|
|
6
6
|
import { useTheme } from '../../hooks'
|
|
7
7
|
import { UnreadCountBadge } from './unread_count_badge'
|
|
8
|
+
import { ConversationActions } from './conversation_actions'
|
|
9
|
+
import { MuteIndicator } from './mute_indicator'
|
|
8
10
|
|
|
9
11
|
interface ConversationPreviewProps {
|
|
10
12
|
conversation: ConversationResource
|
|
11
13
|
onPress: () => void
|
|
14
|
+
showBadges?: boolean
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
export const ConversationPreview = ({
|
|
17
|
+
export const ConversationPreview = ({
|
|
18
|
+
conversation,
|
|
19
|
+
onPress,
|
|
20
|
+
showBadges = true,
|
|
21
|
+
}: ConversationPreviewProps) => {
|
|
15
22
|
const styles = useStyles()
|
|
16
23
|
const {
|
|
17
24
|
lastMessageAuthorName,
|
|
@@ -21,9 +28,11 @@ export const ConversationPreview = ({ conversation, onPress }: ConversationPrevi
|
|
|
21
28
|
title,
|
|
22
29
|
unreadCount,
|
|
23
30
|
badges,
|
|
31
|
+
muted,
|
|
24
32
|
} = conversation
|
|
33
|
+
|
|
25
34
|
return (
|
|
26
|
-
<
|
|
35
|
+
<ConversationActions conversation={conversation} style={styles.previewRow} onPress={onPress}>
|
|
27
36
|
<AvatarGroup size="lg" sourceUris={previewAvatarUrls || []} />
|
|
28
37
|
<View style={styles.conversationBody}>
|
|
29
38
|
<Heading numberOfLines={1} variant="h3" style={styles.title}>
|
|
@@ -32,23 +41,38 @@ export const ConversationPreview = ({ conversation, onPress }: ConversationPrevi
|
|
|
32
41
|
<Text variant="tertiary" numberOfLines={2}>
|
|
33
42
|
{lastMessageAuthorName}: {lastMessageTextPreview}
|
|
34
43
|
</Text>
|
|
35
|
-
<
|
|
36
|
-
{badges?.map(badge => (
|
|
37
|
-
<Badge
|
|
38
|
-
key={badge.text}
|
|
39
|
-
variant="meta"
|
|
40
|
-
productLogoName={badge.appName}
|
|
41
|
-
label={badge.pcoResourceType}
|
|
42
|
-
metaLabel={badge.text || ''}
|
|
43
|
-
/>
|
|
44
|
-
))}
|
|
45
|
-
</View>
|
|
44
|
+
<ConversationBadges visible={showBadges} badges={badges} />
|
|
46
45
|
</View>
|
|
47
46
|
<View style={styles.metaContainer}>
|
|
48
47
|
<Text variant="tertiary">{formatDatePreview(lastMessageCreatedAt)}</Text>
|
|
49
|
-
<
|
|
48
|
+
<View style={styles.statusContainer}>
|
|
49
|
+
<UnreadCountBadge count={unreadCount} showDot={muted} />
|
|
50
|
+
<MuteIndicator muted={muted} />
|
|
51
|
+
</View>
|
|
50
52
|
</View>
|
|
51
|
-
</
|
|
53
|
+
</ConversationActions>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const ConversationBadges = ({ visible, badges }: { visible: boolean; badges?: any[] }) => {
|
|
58
|
+
const styles = useStyles()
|
|
59
|
+
|
|
60
|
+
if (!visible || !badges || badges.length === 0) {
|
|
61
|
+
return null
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<View style={styles.badges}>
|
|
66
|
+
{badges.map(badge => (
|
|
67
|
+
<Badge
|
|
68
|
+
key={badge.text}
|
|
69
|
+
variant="meta"
|
|
70
|
+
productLogoName={badge.appName}
|
|
71
|
+
label={badge.pcoResourceType}
|
|
72
|
+
metaLabel={badge.text || ''}
|
|
73
|
+
/>
|
|
74
|
+
))}
|
|
75
|
+
</View>
|
|
52
76
|
)
|
|
53
77
|
}
|
|
54
78
|
|
|
@@ -75,10 +99,16 @@ const useStyles = () => {
|
|
|
75
99
|
},
|
|
76
100
|
metaContainer: {
|
|
77
101
|
rowGap: 4,
|
|
102
|
+
alignItems: 'flex-end',
|
|
78
103
|
},
|
|
79
104
|
badges: {
|
|
80
105
|
marginTop: 4,
|
|
81
106
|
alignItems: 'flex-start',
|
|
82
107
|
},
|
|
108
|
+
statusContainer: {
|
|
109
|
+
flexDirection: 'row',
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
gap: 4,
|
|
112
|
+
},
|
|
83
113
|
})
|
|
84
114
|
}
|
|
@@ -2,14 +2,12 @@ import { useNavigation } from '@react-navigation/native'
|
|
|
2
2
|
import { FlashList } from '@shopify/flash-list'
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import { StyleSheet, View } from 'react-native'
|
|
5
|
+
import { useConversationsContext } from '../../contexts/conversations_context'
|
|
5
6
|
import { useTheme } from '../../hooks'
|
|
6
|
-
import { useConversationsJoltEvents } from '../../hooks/use_conversation_jolt_events'
|
|
7
|
-
import { useConversations } from '../../hooks/use_conversations'
|
|
8
7
|
import { Text } from '../display'
|
|
9
|
-
import { ConversationRequestArgs } from '../../utils/request/conversation'
|
|
10
8
|
import { ConversationPreview } from './conversation_preview'
|
|
11
9
|
|
|
12
|
-
interface ConversationsProps
|
|
10
|
+
interface ConversationsProps {
|
|
13
11
|
ListHeaderComponent?:
|
|
14
12
|
| React.ComponentType<any>
|
|
15
13
|
| React.ReactElement<any, string | React.JSXElementConstructor<any>>
|
|
@@ -17,24 +15,20 @@ interface ConversationsProps extends Partial<ConversationRequestArgs> {
|
|
|
17
15
|
| undefined
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
export const Conversations = ({
|
|
21
|
-
ListHeaderComponent,
|
|
22
|
-
filter,
|
|
23
|
-
group,
|
|
24
|
-
gids,
|
|
25
|
-
group_source_app_name,
|
|
26
|
-
}: ConversationsProps) => {
|
|
18
|
+
export const Conversations = ({ ListHeaderComponent }: ConversationsProps) => {
|
|
27
19
|
const styles = useStyles()
|
|
28
20
|
|
|
29
|
-
const {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
const {
|
|
22
|
+
conversations,
|
|
23
|
+
fetchNextPage,
|
|
24
|
+
refetch,
|
|
25
|
+
isRefetching,
|
|
26
|
+
isFetched,
|
|
27
|
+
args: { chat_group_graph_id },
|
|
28
|
+
} = useConversationsContext()
|
|
35
29
|
const navigation = useNavigation()
|
|
36
30
|
|
|
37
|
-
|
|
31
|
+
const showBadges = !chat_group_graph_id
|
|
38
32
|
|
|
39
33
|
return (
|
|
40
34
|
<View style={styles.container}>
|
|
@@ -54,6 +48,7 @@ export const Conversations = ({
|
|
|
54
48
|
<ConversationPreview
|
|
55
49
|
conversation={item}
|
|
56
50
|
onPress={() => navigation.navigate('Conversation', { conversation_id: item.id })}
|
|
51
|
+
showBadges={showBadges}
|
|
57
52
|
/>
|
|
58
53
|
)}
|
|
59
54
|
onEndReached={() => fetchNextPage()}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet } from 'react-native'
|
|
3
|
+
import { Icon } from '../display'
|
|
4
|
+
import { useTheme } from '../../hooks'
|
|
5
|
+
|
|
6
|
+
export const MuteIndicator = ({ muted }: { muted: boolean }) => {
|
|
7
|
+
const styles = useStyles()
|
|
8
|
+
|
|
9
|
+
if (!muted) return null
|
|
10
|
+
|
|
11
|
+
return <Icon name="general.bellMuted" size={16} style={styles.mutedIcon} />
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const useStyles = () => {
|
|
15
|
+
const { colors } = useTheme()
|
|
16
|
+
return StyleSheet.create({
|
|
17
|
+
mutedIcon: {
|
|
18
|
+
color: colors.iconColorDefaultDim,
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
}
|
|
@@ -4,11 +4,12 @@ import { Text } from '../display'
|
|
|
4
4
|
import { useTheme } from '../../hooks'
|
|
5
5
|
import { platformFontWeightBold } from '../../utils'
|
|
6
6
|
|
|
7
|
-
export const UnreadCountBadge = ({ count }: { count: number }) => {
|
|
7
|
+
export const UnreadCountBadge = ({ count, showDot }: { count: number; showDot: boolean }) => {
|
|
8
8
|
const styles = useStyles()
|
|
9
9
|
const displayCount = count > 99 ? '99+' : count
|
|
10
10
|
|
|
11
11
|
if (count === 0) return null
|
|
12
|
+
if (showDot) return <View style={styles.dot} />
|
|
12
13
|
|
|
13
14
|
return (
|
|
14
15
|
<View style={styles.badge}>
|
|
@@ -34,5 +35,11 @@ const useStyles = () => {
|
|
|
34
35
|
fontWeight: platformFontWeightBold,
|
|
35
36
|
color: 'white',
|
|
36
37
|
},
|
|
38
|
+
dot: {
|
|
39
|
+
width: 8,
|
|
40
|
+
height: 8,
|
|
41
|
+
borderRadius: 8,
|
|
42
|
+
backgroundColor: colors.fillColorInteractionDefault,
|
|
43
|
+
},
|
|
37
44
|
})
|
|
38
45
|
}
|
|
@@ -32,7 +32,7 @@ export const ActionButton = ({
|
|
|
32
32
|
return (
|
|
33
33
|
<Animated.View style={styles.container}>
|
|
34
34
|
{Boolean(infoText) && (
|
|
35
|
-
<Text style={styles.infoText} variant="
|
|
35
|
+
<Text style={styles.infoText} variant="footnote">
|
|
36
36
|
{infoText}
|
|
37
37
|
</Text>
|
|
38
38
|
)}
|
|
@@ -56,7 +56,6 @@ const useStyles = () => {
|
|
|
56
56
|
},
|
|
57
57
|
infoText: {
|
|
58
58
|
textAlign: 'center',
|
|
59
|
-
color: colors.textColorDefaultSecondary,
|
|
60
59
|
},
|
|
61
60
|
})
|
|
62
61
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { JSX } from 'react'
|
|
2
2
|
import type { TextStyle, ViewProps, ViewStyle } from 'react-native'
|
|
3
3
|
import { Pressable, StyleSheet, View } from 'react-native'
|
|
4
4
|
import Svg, { Defs, LinearGradient, Path, Stop } from 'react-native-svg'
|
|
5
5
|
import { useFontScale, useTheme } from '../../hooks'
|
|
6
6
|
import { platformFontWeightMedium, space } from '../../utils'
|
|
7
7
|
import { tokens } from '../../vendor/tapestry/tokens'
|
|
8
|
-
import { Icon } from './icon'
|
|
8
|
+
import { Icon, IconString } from './icon'
|
|
9
9
|
import { Text } from './text'
|
|
10
10
|
import { useStatusColorAppearanceMap, type StatusAppearanceUnion } from './utils/status_colors'
|
|
11
11
|
|
|
@@ -37,11 +37,14 @@ type VariantStyles = Record<
|
|
|
37
37
|
>
|
|
38
38
|
|
|
39
39
|
type ProductLogoName = 'Groups' | 'Services' | 'groups' | 'services'
|
|
40
|
+
type ProductLogoComponent = ({ logoSize }: { logoSize: number }) => JSX.Element
|
|
40
41
|
|
|
41
|
-
const PRODUCT_LOGO_COMPONENT_MAP = {
|
|
42
|
+
const PRODUCT_LOGO_COMPONENT_MAP: Record<ProductLogoName, ProductLogoComponent> = {
|
|
43
|
+
Groups: GroupsLogo,
|
|
42
44
|
groups: GroupsLogo,
|
|
43
45
|
services: ServicesIcon,
|
|
44
|
-
|
|
46
|
+
Services: ServicesIcon,
|
|
47
|
+
}
|
|
45
48
|
|
|
46
49
|
// =================================
|
|
47
50
|
// ====== Component ================
|
|
@@ -71,11 +74,11 @@ interface BadgeProps {
|
|
|
71
74
|
/**
|
|
72
75
|
* Shows an icon of the user choice to the left of the text.
|
|
73
76
|
*/
|
|
74
|
-
iconName?:
|
|
77
|
+
iconName?: IconString
|
|
75
78
|
/**
|
|
76
79
|
* Shows an icon of the user choice to the right of the text.
|
|
77
80
|
*/
|
|
78
|
-
iconNameRight?:
|
|
81
|
+
iconNameRight?: IconString
|
|
79
82
|
/**
|
|
80
83
|
* Styles badge wrapper.
|
|
81
84
|
*/
|
|
@@ -109,7 +112,7 @@ export function Badge({
|
|
|
109
112
|
const hasMetaLabel = Boolean(metaLabel)
|
|
110
113
|
|
|
111
114
|
const showLogo = showBadgeProductLogo && productLogoName
|
|
112
|
-
const ProductLogoSvg = showLogo && PRODUCT_LOGO_COMPONENT_MAP[productLogoName
|
|
115
|
+
const ProductLogoSvg = showLogo && PRODUCT_LOGO_COMPONENT_MAP[productLogoName]
|
|
113
116
|
const badgeLabel = isMetaSubtle && hasMetaLabel ? `${label}:` : label
|
|
114
117
|
|
|
115
118
|
return (
|
|
@@ -117,7 +120,7 @@ export function Badge({
|
|
|
117
120
|
<View style={styles.badge}>
|
|
118
121
|
{showLogo && ProductLogoSvg && <ProductLogoSvg logoSize={styles.logo.fontSize} />}
|
|
119
122
|
{iconName && <Icon name={iconName} style={styles.icon} />}
|
|
120
|
-
<Text variant="footnote" style={styles.label}>
|
|
123
|
+
<Text variant="footnote" style={styles.label} numberOfLines={1}>
|
|
121
124
|
{badgeLabel}
|
|
122
125
|
</Text>
|
|
123
126
|
{iconNameRight && <Icon name={iconNameRight} style={styles.iconRight} />}
|
|
@@ -238,6 +241,7 @@ const useStyles = ({
|
|
|
238
241
|
fontWeight: variantStylesMap[variant].fontWeight,
|
|
239
242
|
fontSize: badgeFontSize,
|
|
240
243
|
lineHeight: 15 * fontScale,
|
|
244
|
+
flexShrink: 1,
|
|
241
245
|
},
|
|
242
246
|
metaLabel: {
|
|
243
247
|
paddingHorizontal: variantStylesMap[variant].paddingHorizontal,
|
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import { Pressable, StyleSheet, Text, View } from 'react-native'
|
|
3
3
|
import type { PressableProps, ViewStyle } from 'react-native'
|
|
4
4
|
import LinearGradient from 'react-native-linear-gradient'
|
|
5
|
-
import { Icon } from './icon'
|
|
5
|
+
import { Icon, IconString } from './icon'
|
|
6
6
|
import { useTheme, useFontScale, useCreateAndroidRippleColor } from '../../hooks'
|
|
7
7
|
import { tokens } from '../../vendor/tapestry/tokens'
|
|
8
8
|
import { platformFontWeightBold, platformPressedOpacityStyle } from '../../utils'
|
|
@@ -74,11 +74,11 @@ export interface ButtonProps extends PressableProps {
|
|
|
74
74
|
/**
|
|
75
75
|
* Generates an icon to the left of the button text
|
|
76
76
|
*/
|
|
77
|
-
iconNameLeft?:
|
|
77
|
+
iconNameLeft?: IconString
|
|
78
78
|
/**
|
|
79
79
|
* Generates an icon to the right of the button text
|
|
80
80
|
*/
|
|
81
|
-
iconNameRight?:
|
|
81
|
+
iconNameRight?: IconString
|
|
82
82
|
/**
|
|
83
83
|
* Disables the button and replaces its content with a spinner
|
|
84
84
|
*/
|
|
@@ -4,14 +4,24 @@ import type { ColorValue, StyleProp, ViewStyle } from 'react-native'
|
|
|
4
4
|
import { SvgXml } from 'react-native-svg'
|
|
5
5
|
import type { XmlProps } from 'react-native-svg'
|
|
6
6
|
import { useFontScale, useTheme } from '../../hooks'
|
|
7
|
+
|
|
8
|
+
// @ts-ignore
|
|
7
9
|
import * as api from '@planningcenter/icons/paths/api'
|
|
10
|
+
// @ts-ignore
|
|
8
11
|
import * as brand from '@planningcenter/icons/paths/brand'
|
|
12
|
+
// @ts-ignore
|
|
9
13
|
import * as calendar from '@planningcenter/icons/paths/calendar'
|
|
14
|
+
// @ts-ignore
|
|
10
15
|
import * as churchCenter from '@planningcenter/icons/paths/church-center'
|
|
16
|
+
// @ts-ignore
|
|
11
17
|
import * as general from '@planningcenter/icons/paths/general'
|
|
18
|
+
// @ts-ignore
|
|
12
19
|
import * as groups from '@planningcenter/icons/paths/groups'
|
|
20
|
+
// @ts-ignore
|
|
13
21
|
import * as logomark from '@planningcenter/icons/paths/logomark'
|
|
22
|
+
// @ts-ignore
|
|
14
23
|
import * as people from '@planningcenter/icons/paths/people'
|
|
24
|
+
// @ts-ignore
|
|
15
25
|
import * as services from '@planningcenter/icons/paths/services'
|
|
16
26
|
|
|
17
27
|
// =================================
|
|
@@ -37,6 +47,9 @@ type IconStyle = ViewStyle & {
|
|
|
37
47
|
color?: string
|
|
38
48
|
}
|
|
39
49
|
|
|
50
|
+
export type IconSetName = keyof typeof ICONS
|
|
51
|
+
export type IconString = `${IconSetName}.${(typeof ICONS)[IconSetName]}`
|
|
52
|
+
|
|
40
53
|
// =================================
|
|
41
54
|
// ====== Component ================
|
|
42
55
|
// =================================
|
|
@@ -46,7 +59,7 @@ export interface IconProps extends Omit<XmlProps, 'xml' | 'fontSize'> {
|
|
|
46
59
|
* Made up of the set.iconName.
|
|
47
60
|
* Example: "general.textMessage"
|
|
48
61
|
*/
|
|
49
|
-
name:
|
|
62
|
+
name: IconString
|
|
50
63
|
/**
|
|
51
64
|
* This sets a static size for the icon.
|
|
52
65
|
* Providing a fontSize style will allow the icon to scale with the device's text a11y size.
|
|
@@ -112,10 +125,10 @@ const useGetIconSize = (size?: number, style?: IconStyle, maxFontSizeMultiplier?
|
|
|
112
125
|
return size || FALLBACK_SIZE
|
|
113
126
|
}
|
|
114
127
|
|
|
115
|
-
const getIconPath = (name:
|
|
128
|
+
const getIconPath = (name: IconString): string => {
|
|
116
129
|
const [setName, iconName] = name.split('.')
|
|
117
130
|
|
|
118
|
-
return ICONS[setName]?.[iconName]
|
|
131
|
+
return ICONS[setName as IconSetName]?.[iconName]
|
|
119
132
|
}
|
|
120
133
|
|
|
121
134
|
// =================================
|
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import { Pressable, StyleSheet } from 'react-native'
|
|
3
3
|
import type { PressableProps, ViewStyle } from 'react-native'
|
|
4
4
|
import { Icon } from './icon'
|
|
5
|
-
import type { IconProps } from './icon'
|
|
5
|
+
import type { IconProps, IconString } from './icon'
|
|
6
6
|
import { useTheme, useFontScale, useCreateAndroidRippleColor } from '../../hooks'
|
|
7
7
|
import { platformPressedOpacityStyle } from '../../utils'
|
|
8
8
|
import { Spinner } from './spinner'
|
|
@@ -67,7 +67,7 @@ interface IconButtonProps extends PressableProps {
|
|
|
67
67
|
/**
|
|
68
68
|
* Generates an icon from `@planningcenter/icons`
|
|
69
69
|
*/
|
|
70
|
-
name:
|
|
70
|
+
name: IconString
|
|
71
71
|
/**
|
|
72
72
|
* Changes the overall size of the button and its contents
|
|
73
73
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { StyleSheet, View } from 'react-native'
|
|
2
|
+
import { StyleSheet, View, type ViewStyle } from 'react-native'
|
|
3
3
|
import { platformFontWeightMedium } from '../../utils/styles'
|
|
4
4
|
import { MemberResource } from '../../types'
|
|
5
5
|
import { Avatar } from './avatar'
|
|
@@ -13,13 +13,14 @@ import { space } from '../../utils'
|
|
|
13
13
|
|
|
14
14
|
interface PersonProps {
|
|
15
15
|
person: MemberResource
|
|
16
|
+
style?: ViewStyle
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export function Person({ person }: PersonProps) {
|
|
19
|
+
export function Person({ person, style }: PersonProps) {
|
|
19
20
|
const styles = useStyles()
|
|
20
21
|
|
|
21
22
|
return (
|
|
22
|
-
<View style={styles.wrapper}>
|
|
23
|
+
<View style={[styles.wrapper, style]}>
|
|
23
24
|
<Avatar sourceUri={person.avatar} />
|
|
24
25
|
<View style={styles.content}>
|
|
25
26
|
<Text style={styles.name}>{person.name}</Text>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useTheme } from '../../hooks'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import {
|
|
3
|
+
import { StyleSheet, Text as ReactNativeText } from 'react-native'
|
|
4
4
|
import type { TextStyle, TextProps as ReactNativeTextProps } from 'react-native'
|
|
5
5
|
import { tokens } from '../../vendor/tapestry/tokens'
|
|
6
6
|
|
|
@@ -5,7 +5,7 @@ import { Text } from './text'
|
|
|
5
5
|
import { useTheme, useFontScale, useCreateAndroidRippleColor } from '../../hooks'
|
|
6
6
|
import { platformFontWeightBold, platformPressedOpacityStyle } from '../../utils'
|
|
7
7
|
import colorFunction from 'color'
|
|
8
|
-
import { Icon } from './icon'
|
|
8
|
+
import { Icon, IconString } from './icon'
|
|
9
9
|
import { tokens } from '../../vendor/tapestry/tokens'
|
|
10
10
|
|
|
11
11
|
// =================================
|
|
@@ -28,11 +28,11 @@ export interface ToggleButtonProps extends PressableProps {
|
|
|
28
28
|
/**
|
|
29
29
|
* Generates an icon to the left of the button text
|
|
30
30
|
*/
|
|
31
|
-
iconNameLeft?:
|
|
31
|
+
iconNameLeft?: IconString
|
|
32
32
|
/**
|
|
33
33
|
* Generates an icon to the right of the button text
|
|
34
34
|
*/
|
|
35
|
-
iconNameRight?:
|
|
35
|
+
iconNameRight?: IconString
|
|
36
36
|
/**
|
|
37
37
|
* Specifies the maximum size a font can reach when allowFontScaling is enabled.
|
|
38
38
|
*/
|
|
@@ -89,12 +89,17 @@ function useGradientColorMap(): GradientColorMap {
|
|
|
89
89
|
// ====== Functions ================
|
|
90
90
|
// =================================
|
|
91
91
|
|
|
92
|
-
interface GetColorKeyArgs {
|
|
92
|
+
interface GetColorKeyArgs<T> {
|
|
93
93
|
disabled: boolean | null
|
|
94
94
|
loading?: boolean
|
|
95
|
-
appearance:
|
|
95
|
+
appearance: T
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
|
|
98
|
+
function getColorKey<T extends ButtonAppearanceUnion | IconButtonAppearanceUnion>({
|
|
99
|
+
disabled,
|
|
100
|
+
loading,
|
|
101
|
+
appearance,
|
|
102
|
+
}: GetColorKeyArgs<T>) {
|
|
98
103
|
if (disabled || loading) return 'disabled'
|
|
99
104
|
return appearance
|
|
100
105
|
}
|
|
@@ -168,10 +168,11 @@ interface AvatarGroupProps {
|
|
|
168
168
|
sourceUris: string[]
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
type AvatarIndex = 0 | 1 | 2 | 3
|
|
171
172
|
function AvatarGroup({ sourceUris }: AvatarGroupProps) {
|
|
172
173
|
const styles = useStyles()
|
|
173
174
|
const { setAllImagesLoaded } = useAvatarContext()
|
|
174
|
-
const [loadingStatus, setLoadingStatus] = useState({
|
|
175
|
+
const [loadingStatus, setLoadingStatus] = useState<Record<AvatarIndex, boolean>>({
|
|
175
176
|
0: false,
|
|
176
177
|
1: false,
|
|
177
178
|
2: false,
|
|
@@ -180,7 +181,7 @@ function AvatarGroup({ sourceUris }: AvatarGroupProps) {
|
|
|
180
181
|
const displayUris = sourceUris.slice(0, 4)
|
|
181
182
|
const hasDisplayUris = displayUris.length > 0
|
|
182
183
|
|
|
183
|
-
const handleImageLoaded = index => {
|
|
184
|
+
const handleImageLoaded = (index: AvatarIndex) => {
|
|
184
185
|
setLoadingStatus(prev => ({
|
|
185
186
|
...prev,
|
|
186
187
|
[index]: true,
|
|
@@ -189,7 +190,8 @@ function AvatarGroup({ sourceUris }: AvatarGroupProps) {
|
|
|
189
190
|
|
|
190
191
|
useEffect(() => {
|
|
191
192
|
const allImagesLoaded =
|
|
192
|
-
hasDisplayUris &&
|
|
193
|
+
hasDisplayUris &&
|
|
194
|
+
displayUris.every((_, index) => loadingStatus[index as AvatarIndex] === true)
|
|
193
195
|
|
|
194
196
|
setAllImagesLoaded(allImagesLoaded)
|
|
195
197
|
}, [displayUris, hasDisplayUris, loadingStatus, setAllImagesLoaded])
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from '../../utils'
|
|
13
13
|
import { tokens } from '../../vendor/tapestry/tokens'
|
|
14
14
|
import { useCreateAndroidRippleColor, useFontScale } from '../../hooks'
|
|
15
|
-
import { Icon } from '../display/icon'
|
|
15
|
+
import { Icon, IconString } from '../display/icon'
|
|
16
16
|
import { Heading } from '../display/heading'
|
|
17
17
|
import { Text } from '../display/text'
|
|
18
18
|
import { TextInlineButton } from '../display/text_inline_button'
|
|
@@ -161,7 +161,7 @@ BannerContent.displayName = 'Banner.Content'
|
|
|
161
161
|
// ========================================
|
|
162
162
|
|
|
163
163
|
interface BannerStatusIconProps {
|
|
164
|
-
iconName?:
|
|
164
|
+
iconName?: IconString
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
function BannerStatusIcon({ iconName }: BannerStatusIconProps) {
|
|
@@ -271,7 +271,6 @@ const useStyles = ({ appearance = 'neutral' }: Styles = {}) => {
|
|
|
271
271
|
padding: space(1.5),
|
|
272
272
|
gap: space(1),
|
|
273
273
|
borderRadius: tokens.borderRadiusMd,
|
|
274
|
-
flex: 1,
|
|
275
274
|
},
|
|
276
275
|
content: {
|
|
277
276
|
gap: space(0.5),
|
|
@@ -48,7 +48,7 @@ function useSessionChanged(value: Pick<ChatContextValue, 'token' | 'env'>): bool
|
|
|
48
48
|
return Boolean(prevToken && newToken !== prevToken) || Boolean(prevEnv && newEnv !== prevEnv)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
function usePrevious<T>(value) {
|
|
51
|
+
function usePrevious<T>(value: T): T {
|
|
52
52
|
const ref = useRef<T>(value)
|
|
53
53
|
|
|
54
54
|
useEffect(() => {
|
|
@@ -11,6 +11,7 @@ export type ChatContextValue = {
|
|
|
11
11
|
theme: ChatTheme
|
|
12
12
|
env?: ENV
|
|
13
13
|
session: Session
|
|
14
|
+
giphyApiKey?: string
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export interface ChatProviderProps extends Omit<ChatContextValue, 'client' | 'theme' | 'session'> {
|
|
@@ -23,10 +24,11 @@ export const ChatContext = createContext<ChatContextValue>({
|
|
|
23
24
|
env: undefined,
|
|
24
25
|
onUnauthorizedResponse: () => {},
|
|
25
26
|
session: new Session(),
|
|
27
|
+
giphyApiKey: undefined,
|
|
26
28
|
})
|
|
27
29
|
|
|
28
30
|
export function ChatProvider({ children, value }: { children: any; value: ChatProviderProps }) {
|
|
29
|
-
const { env, token, onUnauthorizedResponse } = value
|
|
31
|
+
const { env, token, onUnauthorizedResponse, giphyApiKey } = value
|
|
30
32
|
const theme = useCreateChatTheme(value.theme || {})
|
|
31
33
|
const session = useMemo(() => new Session({ token, env }), [env, token])
|
|
32
34
|
|
|
@@ -36,6 +38,7 @@ export function ChatProvider({ children, value }: { children: any; value: ChatPr
|
|
|
36
38
|
onUnauthorizedResponse,
|
|
37
39
|
session,
|
|
38
40
|
theme,
|
|
41
|
+
giphyApiKey,
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
return <ChatContext.Provider value={contextValue}>{children}</ChatContext.Provider>
|
|
@@ -46,6 +49,10 @@ export interface CreateChatThemeProps {
|
|
|
46
49
|
colorScheme?: ColorSchemeName
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
export const useChatContext = () => {
|
|
53
|
+
return React.useContext(ChatContext)
|
|
54
|
+
}
|
|
55
|
+
|
|
49
56
|
export const useCreateChatTheme = ({
|
|
50
57
|
theme: customTheme = {},
|
|
51
58
|
colorScheme: appColorScheme,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { createContext, PropsWithChildren, useContext, useMemo, useState } from 'react'
|
|
2
|
+
import { ConversationFiltersParams } from '../screens/conversation_filters/screen_props'
|
|
3
|
+
import { useConversations, UseConversationsValue } from '../hooks/use_conversations'
|
|
4
|
+
import {
|
|
5
|
+
FetchNextPageOptions,
|
|
6
|
+
InfiniteQueryObserverResult,
|
|
7
|
+
InfiniteData,
|
|
8
|
+
} from '@tanstack/react-query'
|
|
9
|
+
import { ApiCollection, ConversationResource } from '../types'
|
|
10
|
+
import { useConversationsJoltEvents } from '../hooks/use_conversations_jolt_events'
|
|
11
|
+
|
|
12
|
+
interface ConversationsContextValue extends UseConversationsValue {
|
|
13
|
+
activeConversationId?: number
|
|
14
|
+
setActiveConversationId: (_id: number) => void
|
|
15
|
+
args: ConversationFiltersParams
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const defaultQueryValue: UseConversationsValue = {
|
|
19
|
+
conversations: [],
|
|
20
|
+
refetch: () => Promise.resolve(null),
|
|
21
|
+
error: null,
|
|
22
|
+
isError: false,
|
|
23
|
+
fetchNextPage,
|
|
24
|
+
hasNextPage: false,
|
|
25
|
+
isFetching: false,
|
|
26
|
+
isFetched: false,
|
|
27
|
+
isRefetching: false,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const ConversationsContext = createContext<ConversationsContextValue>({
|
|
31
|
+
args: {},
|
|
32
|
+
activeConversationId: undefined,
|
|
33
|
+
setActiveConversationId: () => {},
|
|
34
|
+
...defaultQueryValue,
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export const ConversationsContextProvider = ({
|
|
38
|
+
children,
|
|
39
|
+
args,
|
|
40
|
+
}: PropsWithChildren<{ args: ConversationFiltersParams }>) => {
|
|
41
|
+
const [activeConversationId, setActiveConversationId] = useState<number | undefined>()
|
|
42
|
+
const { chat_group_graph_id, group_source_app_name } = args
|
|
43
|
+
|
|
44
|
+
const query = useConversations({ chat_group_graph_id, group_source_app_name })
|
|
45
|
+
|
|
46
|
+
const value = useMemo(
|
|
47
|
+
() => ({
|
|
48
|
+
args,
|
|
49
|
+
activeConversationId,
|
|
50
|
+
setActiveConversationId,
|
|
51
|
+
...query,
|
|
52
|
+
}),
|
|
53
|
+
[args, activeConversationId, query]
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
useConversationsJoltEvents(args)
|
|
57
|
+
|
|
58
|
+
return <ConversationsContext.Provider value={value}>{children}</ConversationsContext.Provider>
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function fetchNextPage(
|
|
62
|
+
_options?: FetchNextPageOptions
|
|
63
|
+
): Promise<
|
|
64
|
+
InfiniteQueryObserverResult<InfiniteData<ApiCollection<ConversationResource>, unknown>, Response>
|
|
65
|
+
> {
|
|
66
|
+
throw new Error('Function not implemented.')
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const useConversationsContext = () => useContext(ConversationsContext)
|