@planningcenter/chat-react-native 3.1.0-rc.9 → 3.2.0-rc.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/conversation/attachments/attachment_card.d.ts +9 -0
- package/build/components/conversation/attachments/attachment_card.d.ts.map +1 -0
- package/build/components/conversation/attachments/attachment_card.js +35 -0
- package/build/components/conversation/attachments/attachment_card.js.map +1 -0
- package/build/components/conversation/attachments/audio_attachment.d.ts +6 -0
- package/build/components/conversation/attachments/audio_attachment.d.ts.map +1 -0
- package/build/components/conversation/attachments/audio_attachment.js +84 -0
- package/build/components/conversation/attachments/audio_attachment.js.map +1 -0
- package/build/components/conversation/attachments/constants.d.ts +3 -0
- package/build/components/conversation/attachments/constants.d.ts.map +1 -0
- package/build/components/conversation/attachments/constants.js +4 -0
- package/build/components/conversation/attachments/constants.js.map +1 -0
- package/build/components/conversation/attachments/download_attachment_button.d.ts +9 -0
- package/build/components/conversation/attachments/download_attachment_button.d.ts.map +1 -0
- package/build/components/conversation/attachments/download_attachment_button.js +29 -0
- package/build/components/conversation/attachments/download_attachment_button.js.map +1 -0
- package/build/components/conversation/attachments/expanded_link.d.ts +5 -0
- package/build/components/conversation/attachments/expanded_link.d.ts.map +1 -0
- package/build/components/conversation/attachments/expanded_link.js +44 -0
- package/build/components/conversation/attachments/expanded_link.js.map +1 -0
- package/build/components/conversation/attachments/generic_file_attachment.d.ts +7 -0
- package/build/components/conversation/attachments/generic_file_attachment.d.ts.map +1 -0
- package/build/components/conversation/attachments/generic_file_attachment.js +63 -0
- package/build/components/conversation/attachments/generic_file_attachment.js.map +1 -0
- package/build/components/conversation/attachments/giphy_attachment.d.ts +6 -0
- package/build/components/conversation/attachments/giphy_attachment.d.ts.map +1 -0
- package/build/components/conversation/attachments/giphy_attachment.js +42 -0
- package/build/components/conversation/attachments/giphy_attachment.js.map +1 -0
- package/build/components/conversation/attachments/image_attachment.d.ts +5 -0
- package/build/components/conversation/attachments/image_attachment.d.ts.map +1 -0
- package/build/components/conversation/attachments/image_attachment.js +24 -0
- package/build/components/conversation/attachments/image_attachment.js.map +1 -0
- package/build/components/conversation/attachments/video_attachment.d.ts +6 -0
- package/build/components/conversation/attachments/video_attachment.d.ts.map +1 -0
- package/build/components/conversation/attachments/video_attachment.js +64 -0
- package/build/components/conversation/attachments/video_attachment.js.map +1 -0
- package/build/components/conversation/message.d.ts +1 -1
- package/build/components/conversation/message.d.ts.map +1 -1
- package/build/components/conversation/message.js +13 -7
- package/build/components/conversation/message.js.map +1 -1
- package/build/components/conversation/message_attachments.d.ts +6 -0
- package/build/components/conversation/message_attachments.d.ts.map +1 -0
- package/build/components/conversation/message_attachments.js +52 -0
- package/build/components/conversation/message_attachments.js.map +1 -0
- package/build/components/conversation/message_markdown.d.ts +7 -0
- package/build/components/conversation/message_markdown.d.ts.map +1 -0
- package/build/components/conversation/message_markdown.js +38 -0
- package/build/components/conversation/message_markdown.js.map +1 -0
- package/build/components/conversations/conversation_preview.d.ts +9 -0
- package/build/components/conversations/conversation_preview.d.ts.map +1 -0
- package/build/components/conversations/conversation_preview.js +58 -0
- package/build/components/conversations/conversation_preview.js.map +1 -0
- package/build/components/conversations/conversations.d.ts +8 -0
- package/build/components/conversations/conversations.d.ts.map +1 -0
- package/build/components/conversations/conversations.js +40 -0
- package/build/components/conversations/conversations.js.map +1 -0
- package/build/components/conversations/unread_count_badge.d.ts +5 -0
- package/build/components/conversations/unread_count_badge.d.ts.map +1 -0
- package/build/components/conversations/unread_count_badge.js +33 -0
- package/build/components/conversations/unread_count_badge.js.map +1 -0
- package/build/components/display/badge.d.ts +9 -1
- package/build/components/display/badge.d.ts.map +1 -1
- package/build/components/display/badge.js +22 -10
- package/build/components/display/badge.js.map +1 -1
- package/build/components/display/button.d.ts +1 -1
- package/build/components/display/button.d.ts.map +1 -1
- package/build/components/display/button.js.map +1 -1
- package/build/components/display/child_notice.js +2 -2
- package/build/components/display/child_notice.js.map +1 -1
- package/build/components/display/icon.d.ts.map +1 -1
- package/build/components/display/icon.js +10 -8
- package/build/components/display/icon.js.map +1 -1
- package/build/components/display/text.js +2 -8
- package/build/components/display/text.js.map +1 -1
- package/build/components/index.d.ts +1 -1
- package/build/components/index.d.ts.map +1 -1
- package/build/components/index.js +1 -1
- package/build/components/index.js.map +1 -1
- package/build/components/page/error_boundary.d.ts +1 -1
- package/build/hooks/use_api.d.ts +6 -4
- package/build/hooks/use_api.d.ts.map +1 -1
- package/build/hooks/use_api.js +5 -2
- package/build/hooks/use_api.js.map +1 -1
- package/build/hooks/use_api_client.d.ts +1 -2
- package/build/hooks/use_api_client.d.ts.map +1 -1
- package/build/hooks/use_api_client.js.map +1 -1
- package/build/hooks/use_conversation.d.ts +76 -0
- package/build/hooks/use_conversation.d.ts.map +1 -1
- package/build/hooks/use_conversation.js +47 -3
- package/build/hooks/use_conversation.js.map +1 -1
- package/build/hooks/use_conversation_jolt_events.js +1 -1
- package/build/hooks/use_conversation_jolt_events.js.map +1 -1
- package/build/hooks/use_conversation_messages_jolt_events.js +1 -1
- package/build/hooks/use_conversation_messages_jolt_events.js.map +1 -1
- package/build/hooks/use_conversations.d.ts +2 -3
- package/build/hooks/use_conversations.d.ts.map +1 -1
- package/build/hooks/use_conversations.js +3 -29
- package/build/hooks/use_conversations.js.map +1 -1
- package/build/hooks/use_groups.d.ts +214 -0
- package/build/hooks/use_groups.d.ts.map +1 -0
- package/build/hooks/use_groups.js +22 -0
- package/build/hooks/use_groups.js.map +1 -0
- package/build/hooks/use_groups_groups.d.ts +208 -0
- package/build/hooks/use_groups_groups.d.ts.map +1 -0
- package/build/hooks/use_groups_groups.js +18 -0
- package/build/hooks/use_groups_groups.js.map +1 -0
- package/build/hooks/use_services_team.d.ts +4 -0
- package/build/hooks/use_services_team.d.ts.map +1 -0
- package/build/hooks/use_services_team.js +22 -0
- package/build/hooks/use_services_team.js.map +1 -0
- package/build/hooks/use_suspense_api.d.ts +2 -1
- package/build/hooks/use_suspense_api.d.ts.map +1 -1
- package/build/hooks/use_suspense_api.js +2 -1
- package/build/hooks/use_suspense_api.js.map +1 -1
- package/build/hooks/use_teams.d.ts +208 -0
- package/build/hooks/use_teams.d.ts.map +1 -0
- package/build/hooks/use_teams.js +22 -0
- package/build/hooks/use_teams.js.map +1 -0
- package/build/navigation/index.d.ts +4 -0
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +5 -0
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_details_screen.d.ts.map +1 -1
- package/build/screens/conversation_details_screen.js +139 -59
- package/build/screens/conversation_details_screen.js.map +1 -1
- package/build/screens/conversation_filters/components/conversation_filters.d.ts +3 -0
- package/build/screens/conversation_filters/components/conversation_filters.d.ts.map +1 -0
- package/build/screens/conversation_filters/components/conversation_filters.js +173 -0
- package/build/screens/conversation_filters/components/conversation_filters.js.map +1 -0
- package/build/screens/conversation_filters/components/rows.d.ts +31 -0
- package/build/screens/conversation_filters/components/rows.d.ts.map +1 -0
- package/build/screens/conversation_filters/components/rows.js +111 -0
- package/build/screens/conversation_filters/components/rows.js.map +1 -0
- package/build/screens/conversation_filters/context/conversation_filter_context.d.ts +23 -0
- package/build/screens/conversation_filters/context/conversation_filter_context.d.ts.map +1 -0
- package/build/screens/conversation_filters/context/conversation_filter_context.js +51 -0
- package/build/screens/conversation_filters/context/conversation_filter_context.js.map +1 -0
- package/build/screens/conversation_filters/filter_types.d.ts +7 -0
- package/build/screens/conversation_filters/filter_types.d.ts.map +1 -0
- package/build/screens/conversation_filters/filter_types.js +8 -0
- package/build/screens/conversation_filters/filter_types.js.map +1 -0
- package/build/screens/conversation_filters/group_filters.d.ts +6 -0
- package/build/screens/conversation_filters/group_filters.d.ts.map +1 -0
- package/build/screens/conversation_filters/group_filters.js +15 -0
- package/build/screens/conversation_filters/group_filters.js.map +1 -0
- package/build/screens/conversation_filters/hooks/filters.d.ts +415 -0
- package/build/screens/conversation_filters/hooks/filters.d.ts.map +1 -0
- package/build/screens/conversation_filters/hooks/filters.js +41 -0
- package/build/screens/conversation_filters/hooks/filters.js.map +1 -0
- package/build/screens/conversation_filters/screen_props.d.ts +13 -0
- package/build/screens/conversation_filters/screen_props.d.ts.map +1 -0
- package/build/screens/conversation_filters/screen_props.js +2 -0
- package/build/screens/conversation_filters/screen_props.js.map +1 -0
- package/build/screens/conversation_filters/team_filters.d.ts +6 -0
- package/build/screens/conversation_filters/team_filters.d.ts.map +1 -0
- package/build/screens/conversation_filters/team_filters.js +15 -0
- package/build/screens/conversation_filters/team_filters.js.map +1 -0
- package/build/screens/conversation_filters_screen.d.ts +6 -0
- package/build/screens/conversation_filters_screen.d.ts.map +1 -0
- package/build/screens/conversation_filters_screen.js +125 -0
- package/build/screens/conversation_filters_screen.js.map +1 -0
- package/build/screens/conversation_screen.js +10 -4
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/conversations_screen.d.ts +4 -2
- package/build/screens/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations_screen.js +139 -11
- package/build/screens/conversations_screen.js.map +1 -1
- package/build/screens/create/conversation_select_recipients_screen.d.ts.map +1 -1
- package/build/screens/create/conversation_select_recipients_screen.js +3 -11
- package/build/screens/create/conversation_select_recipients_screen.js.map +1 -1
- package/build/types/resources/group_resource.d.ts +4 -2
- package/build/types/resources/group_resource.d.ts.map +1 -1
- package/build/types/resources/group_resource.js.map +1 -1
- package/build/types/resources/index.d.ts +1 -0
- package/build/types/resources/index.d.ts.map +1 -1
- package/build/types/resources/index.js +1 -0
- package/build/types/resources/index.js.map +1 -1
- package/build/types/resources/member_ability.d.ts +1 -0
- package/build/types/resources/member_ability.d.ts.map +1 -1
- package/build/types/resources/member_ability.js.map +1 -1
- package/build/types/resources/services/index.d.ts +2 -0
- package/build/types/resources/services/index.d.ts.map +1 -0
- package/build/types/resources/services/index.js +2 -0
- package/build/types/resources/services/index.js.map +1 -0
- package/build/types/resources/services/team_resource.d.ts +48 -0
- package/build/types/resources/services/team_resource.d.ts.map +1 -0
- package/build/types/resources/services/team_resource.js +7 -0
- package/build/types/resources/services/team_resource.js.map +1 -0
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +1 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/native_adapters/audio.d.ts +13 -0
- package/build/utils/native_adapters/audio.d.ts.map +1 -0
- package/build/utils/native_adapters/audio.js +7 -0
- package/build/utils/native_adapters/audio.js.map +1 -0
- package/build/utils/native_adapters/configuration.d.ts +7 -1
- package/build/utils/native_adapters/configuration.d.ts.map +1 -1
- package/build/utils/native_adapters/configuration.js +17 -1
- package/build/utils/native_adapters/configuration.js.map +1 -1
- package/build/utils/native_adapters/index.d.ts +2 -0
- package/build/utils/native_adapters/index.d.ts.map +1 -1
- package/build/utils/native_adapters/index.js +2 -0
- package/build/utils/native_adapters/index.js.map +1 -1
- package/build/utils/native_adapters/video.d.ts +25 -0
- package/build/utils/native_adapters/video.d.ts.map +1 -0
- package/build/utils/native_adapters/video.js +7 -0
- package/build/utils/native_adapters/video.js.map +1 -0
- package/build/utils/parse_simple_markdown.d.ts +7 -0
- package/build/utils/parse_simple_markdown.d.ts.map +1 -0
- package/build/utils/parse_simple_markdown.js +32 -0
- package/build/utils/parse_simple_markdown.js.map +1 -0
- package/build/utils/pluralize.d.ts +2 -0
- package/build/utils/pluralize.d.ts.map +1 -0
- package/build/utils/pluralize.js +10 -0
- package/build/utils/pluralize.js.map +1 -0
- package/build/utils/request/conversation.d.ts +10 -0
- package/build/utils/request/conversation.d.ts.map +1 -0
- package/build/utils/request/conversation.js +32 -0
- package/build/utils/request/conversation.js.map +1 -0
- package/build/utils/request/messages.d.ts +15 -0
- package/build/utils/request/messages.d.ts.map +1 -0
- package/build/utils/request/messages.js +22 -0
- package/build/utils/request/messages.js.map +1 -0
- package/build/utils/theme.d.ts +1 -1
- package/build/utils/theme.d.ts.map +1 -1
- package/build/utils/theme.js +1 -1
- package/build/utils/theme.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/utils/parse_simple_markdown.ts +93 -0
- package/src/__tests__/utils/pluralize.tsx +17 -0
- package/src/components/conversation/attachments/attachment_card.tsx +46 -0
- package/src/components/conversation/attachments/audio_attachment.tsx +102 -0
- package/src/components/conversation/attachments/constants.ts +5 -0
- package/src/components/conversation/attachments/download_attachment_button.tsx +46 -0
- package/src/components/conversation/attachments/expanded_link.tsx +54 -0
- package/src/components/conversation/attachments/generic_file_attachment.tsx +75 -0
- package/src/components/conversation/attachments/giphy_attachment.tsx +56 -0
- package/src/components/conversation/attachments/image_attachment.tsx +31 -0
- package/src/components/conversation/attachments/video_attachment.tsx +92 -0
- package/src/components/conversation/message.tsx +15 -6
- package/src/components/conversation/message_attachments.tsx +61 -0
- package/src/components/conversation/message_markdown.tsx +52 -0
- package/src/components/conversations/conversation_preview.tsx +84 -0
- package/src/components/conversations/conversations.tsx +79 -0
- package/src/components/conversations/unread_count_badge.tsx +38 -0
- package/src/components/display/badge.tsx +41 -10
- package/src/components/display/button.tsx +1 -1
- package/src/components/display/child_notice.tsx +2 -2
- package/src/components/display/icon.tsx +10 -8
- package/src/components/display/text.tsx +1 -7
- package/src/components/index.tsx +1 -1
- package/src/hooks/use_api.ts +11 -10
- package/src/hooks/use_api_client.ts +1 -1
- package/src/hooks/use_conversation.ts +51 -3
- package/src/hooks/use_conversation_jolt_events.ts +1 -1
- package/src/hooks/use_conversation_messages_jolt_events.ts +1 -1
- package/src/hooks/use_conversations.ts +3 -31
- package/src/hooks/use_groups.ts +31 -0
- package/src/hooks/use_groups_groups.ts +20 -0
- package/src/hooks/use_services_team.ts +30 -0
- package/src/hooks/use_suspense_api.ts +4 -4
- package/src/hooks/use_teams.ts +25 -0
- package/src/navigation/index.tsx +8 -0
- package/src/screens/conversation_details_screen.tsx +224 -111
- package/src/screens/conversation_filters/components/conversation_filters.tsx +233 -0
- package/src/screens/conversation_filters/components/rows.tsx +164 -0
- package/src/screens/conversation_filters/context/conversation_filter_context.tsx +65 -0
- package/src/screens/conversation_filters/filter_types.ts +6 -0
- package/src/screens/conversation_filters/group_filters.tsx +31 -0
- package/src/screens/conversation_filters/hooks/filters.ts +68 -0
- package/src/screens/conversation_filters/screen_props.ts +15 -0
- package/src/screens/conversation_filters/team_filters.tsx +31 -0
- package/src/screens/conversation_filters_screen.tsx +152 -0
- package/src/screens/conversation_screen.tsx +16 -4
- package/src/screens/conversations_screen.tsx +210 -13
- package/src/screens/create/conversation_select_recipients_screen.tsx +3 -11
- package/src/types/resources/group_resource.ts +5 -2
- package/src/types/resources/index.ts +1 -0
- package/src/types/resources/member_ability.ts +1 -0
- package/src/types/resources/services/index.ts +1 -0
- package/src/types/resources/services/team_resource.ts +60 -0
- package/src/utils/client/types.d.ts +2 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/native_adapters/audio.ts +15 -0
- package/src/utils/native_adapters/configuration.ts +24 -1
- package/src/utils/native_adapters/index.ts +2 -0
- package/src/utils/native_adapters/video.ts +30 -0
- package/src/utils/parse_simple_markdown.ts +40 -0
- package/src/utils/pluralize.ts +11 -0
- package/src/utils/request/conversation.ts +46 -0
- package/src/utils/request/messages.ts +21 -0
- package/src/utils/theme.ts +2 -2
- package/build/components/conversations.d.ts +0 -3
- package/build/components/conversations.d.ts.map +0 -1
- package/build/components/conversations.js +0 -100
- package/build/components/conversations.js.map +0 -1
- package/src/components/conversations.tsx +0 -144
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Supports bold, italic, and links
|
|
2
|
+
export const parseSimpleMarkdown = input => {
|
|
3
|
+
const parts: MarkdownPart[] = []
|
|
4
|
+
|
|
5
|
+
const pattern = /(\*\*|__)(.+?)\1|(?<!\*)\*(.+?)\*|(?<!_)_(.+?)_|(https?:\/\/[^\s]+)/g
|
|
6
|
+
let lastIndex = 0
|
|
7
|
+
|
|
8
|
+
input.replace(pattern, (match, bold, boldText, italic1, italic2, url, offset) => {
|
|
9
|
+
if (offset > lastIndex) {
|
|
10
|
+
parts.push({ type: 'text', content: input.slice(lastIndex, offset) })
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (bold) {
|
|
14
|
+
parts.push({ type: 'bold', content: boldText })
|
|
15
|
+
} else if (italic1 || italic2) {
|
|
16
|
+
parts.push({ type: 'italic', content: italic1 || italic2 })
|
|
17
|
+
} else if (url) {
|
|
18
|
+
const urlMatch = url.match(/^(https?:\/\/[^\s]+)([.,;!?]+)$/)
|
|
19
|
+
const urlContent = urlMatch ? urlMatch[1] : url
|
|
20
|
+
parts.push({ type: 'link', content: urlContent })
|
|
21
|
+
const punctuation = urlMatch ? urlMatch[2] : ''
|
|
22
|
+
if (punctuation) {
|
|
23
|
+
parts.push({ type: 'text', content: punctuation })
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
lastIndex = offset + match.length
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
if (lastIndex < input.length) {
|
|
31
|
+
parts.push({ type: 'text', content: input.slice(lastIndex) })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return parts
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface MarkdownPart {
|
|
38
|
+
type: 'text' | 'bold' | 'italic' | 'link'
|
|
39
|
+
content: string
|
|
40
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const irregularInflections: Record<string, string> = { person: 'people' }
|
|
2
|
+
|
|
3
|
+
export function pluralize(count: number, singularWord: string, includeCount = true) {
|
|
4
|
+
const plural = count !== 1
|
|
5
|
+
const pluralWord = irregularInflections[singularWord] || `${singularWord}s`
|
|
6
|
+
|
|
7
|
+
return [
|
|
8
|
+
includeCount ? `${count.toLocaleString()} ` : '',
|
|
9
|
+
plural ? pluralWord : singularWord,
|
|
10
|
+
].join('')
|
|
11
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { GetRequest } from '../client/types'
|
|
2
|
+
|
|
3
|
+
export interface ConversationRequestArgs {
|
|
4
|
+
filter: string
|
|
5
|
+
gids: string
|
|
6
|
+
group: string
|
|
7
|
+
chat_group_graph_id?: string
|
|
8
|
+
group_source_app_name?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const getConversationsRequestArgs = ({
|
|
12
|
+
filter,
|
|
13
|
+
gids,
|
|
14
|
+
group,
|
|
15
|
+
group_source_app_name,
|
|
16
|
+
}: Partial<ConversationRequestArgs> = {}): GetRequest => ({
|
|
17
|
+
url: '/me/conversations',
|
|
18
|
+
data: {
|
|
19
|
+
perPage: 20,
|
|
20
|
+
order: '-last_message',
|
|
21
|
+
filter,
|
|
22
|
+
group,
|
|
23
|
+
gids,
|
|
24
|
+
group_source_app_name,
|
|
25
|
+
fields: {
|
|
26
|
+
Conversation: [
|
|
27
|
+
'created_at',
|
|
28
|
+
'badges',
|
|
29
|
+
'groups',
|
|
30
|
+
'last_message_author_id',
|
|
31
|
+
'last_message_author_name',
|
|
32
|
+
'last_message_created_at',
|
|
33
|
+
'last_message_text_preview',
|
|
34
|
+
'preview_avatar_urls',
|
|
35
|
+
'member_ability',
|
|
36
|
+
'muted',
|
|
37
|
+
'replies_disabled',
|
|
38
|
+
'title',
|
|
39
|
+
'unread_count',
|
|
40
|
+
'updated_at',
|
|
41
|
+
],
|
|
42
|
+
ConversationBadge: ['app_name', 'pco_resource_type', 'text'],
|
|
43
|
+
},
|
|
44
|
+
include: ['badges'],
|
|
45
|
+
},
|
|
46
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const getMessagesRequestArgs = ({ conversation_id }: { conversation_id: number }) => ({
|
|
2
|
+
url: `/me/conversations/${conversation_id}/messages`,
|
|
3
|
+
data: {
|
|
4
|
+
perPage: 25,
|
|
5
|
+
fields: {
|
|
6
|
+
Message: [
|
|
7
|
+
'text',
|
|
8
|
+
'text_edited_at',
|
|
9
|
+
'mine',
|
|
10
|
+
'attachments',
|
|
11
|
+
'created_at',
|
|
12
|
+
'deleted_at',
|
|
13
|
+
'author',
|
|
14
|
+
'reaction_counts',
|
|
15
|
+
],
|
|
16
|
+
Person: ['name', 'avatar'],
|
|
17
|
+
ReactionCount: ['value', 'count', 'mine', 'message_id', 'author_ids'],
|
|
18
|
+
},
|
|
19
|
+
include: ['author', 'reaction_counts'],
|
|
20
|
+
},
|
|
21
|
+
})
|
package/src/utils/theme.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface DefaultTheme {
|
|
|
27
27
|
button: {
|
|
28
28
|
borderRadius: number
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
showBadgeProductLogo: boolean
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export const defaultTheme = (colorScheme: ColorSchemeName): ChatTheme => {
|
|
@@ -43,7 +43,7 @@ export const defaultTheme = (colorScheme: ColorSchemeName): ChatTheme => {
|
|
|
43
43
|
button: {
|
|
44
44
|
borderRadius: 40,
|
|
45
45
|
},
|
|
46
|
-
|
|
46
|
+
showBadgeProductLogo: true, // Overrides visibility of the product logo in `src/display/badge.tsx`
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../src/components/conversations.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAUtC,eAAO,MAAM,aAAa,yBAwEzB,CAAA"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { useNavigation } from '@react-navigation/native';
|
|
2
|
-
import { FlashList } from '@shopify/flash-list';
|
|
3
|
-
import React, { useMemo } from 'react';
|
|
4
|
-
import { Pressable, StyleSheet, View } from 'react-native';
|
|
5
|
-
import { useTheme } from '../hooks';
|
|
6
|
-
import { useConversationsJoltEvents } from '../hooks/use_conversation_jolt_events';
|
|
7
|
-
import { useConversations } from '../hooks/use_conversations';
|
|
8
|
-
import { formatDatePreview } from '../utils/date';
|
|
9
|
-
import { AvatarGroup, Badge, Heading, Text, TextButton } from './display';
|
|
10
|
-
import { ActionButton } from './display/action_button';
|
|
11
|
-
import { useCanCreateConversations } from '../hooks/use_chat_permissions';
|
|
12
|
-
export const Conversations = () => {
|
|
13
|
-
const styles = useStyles();
|
|
14
|
-
const { conversations, fetchNextPage, refetch, isRefetching } = useConversations();
|
|
15
|
-
const canCreateConversations = useCanCreateConversations();
|
|
16
|
-
// TODO: Filter using the API
|
|
17
|
-
const nonEmptyConversations = useMemo(() => conversations.filter(c => c.lastMessageTextPreview) || [], [conversations]);
|
|
18
|
-
const navigation = useNavigation();
|
|
19
|
-
useConversationsJoltEvents();
|
|
20
|
-
return (<View style={styles.container}>
|
|
21
|
-
<FlashList data={nonEmptyConversations} estimatedItemSize={97} contentContainerStyle={styles.contentContainer} onRefresh={refetch} refreshing={isRefetching} ListHeaderComponent={<View style={styles.header}>
|
|
22
|
-
<Heading numberOfLines={1} variant="h2">
|
|
23
|
-
Conversations
|
|
24
|
-
</Heading>
|
|
25
|
-
<TextButton>Mark all read</TextButton>
|
|
26
|
-
</View>} ListEmptyComponent={<Text>No conversations found</Text>} renderItem={({ item }) => (<Pressable style={styles.conversation} onPress={() => navigation.navigate('Conversation', { conversation_id: item.id })}>
|
|
27
|
-
<AvatarGroup size="lg" sourceUris={item.previewAvatarUrls || []}/>
|
|
28
|
-
<View style={styles.conversationBody}>
|
|
29
|
-
<Heading numberOfLines={1} variant="h3" style={styles.conversationTitle}>
|
|
30
|
-
{item.title}
|
|
31
|
-
</Heading>
|
|
32
|
-
<Text style={styles.listItem} numberOfLines={2}>
|
|
33
|
-
{item.lastMessageAuthorName}: {item.lastMessageTextPreview}
|
|
34
|
-
</Text>
|
|
35
|
-
<View style={styles.conversationBadges}>
|
|
36
|
-
{item.badges?.map(badge => (<Badge key={badge.text} variant="meta" productLogoName={badge.appName} label={badge.pcoResourceType} metaLabel={badge.text || ''}/>))}
|
|
37
|
-
</View>
|
|
38
|
-
</View>
|
|
39
|
-
<View style={styles.conversationExtra}>
|
|
40
|
-
<Text variant="secondary">{formatDatePreview(item.lastMessageCreatedAt)}</Text>
|
|
41
|
-
<UnreadCountBadge count={item.unreadCount}/>
|
|
42
|
-
</View>
|
|
43
|
-
</Pressable>)} onEndReached={() => fetchNextPage()}/>
|
|
44
|
-
<ActionButton visible={canCreateConversations} title="New conversation" onPress={() => navigation.navigate('Create')}/>
|
|
45
|
-
</View>);
|
|
46
|
-
};
|
|
47
|
-
const UnreadCountBadge = ({ count }) => {
|
|
48
|
-
const styles = useStyles();
|
|
49
|
-
const displayCount = count > 99 ? '99+' : count;
|
|
50
|
-
if (count === 0)
|
|
51
|
-
return null;
|
|
52
|
-
return (<Text variant="tertiary" style={styles.unreadCountBadge}>
|
|
53
|
-
{displayCount}
|
|
54
|
-
</Text>);
|
|
55
|
-
};
|
|
56
|
-
const useStyles = () => {
|
|
57
|
-
const { colors } = useTheme();
|
|
58
|
-
return StyleSheet.create({
|
|
59
|
-
header: {
|
|
60
|
-
flexDirection: 'row',
|
|
61
|
-
justifyContent: 'space-between',
|
|
62
|
-
paddingTop: 8,
|
|
63
|
-
paddingBottom: 8,
|
|
64
|
-
paddingHorizontal: 16,
|
|
65
|
-
},
|
|
66
|
-
container: { flex: 1 },
|
|
67
|
-
contentContainer: { paddingVertical: 16 },
|
|
68
|
-
listItem: { color: colors.fillColorNeutral020 },
|
|
69
|
-
conversation: {
|
|
70
|
-
flexDirection: 'row',
|
|
71
|
-
gap: 8,
|
|
72
|
-
borderBottomWidth: 1,
|
|
73
|
-
borderBottomColor: colors.fillColorNeutral060,
|
|
74
|
-
paddingTop: 4,
|
|
75
|
-
paddingBottom: 12,
|
|
76
|
-
paddingHorizontal: 16,
|
|
77
|
-
},
|
|
78
|
-
conversationTitle: {},
|
|
79
|
-
conversationBody: {
|
|
80
|
-
flex: 1,
|
|
81
|
-
rowGap: 2,
|
|
82
|
-
},
|
|
83
|
-
conversationExtra: {
|
|
84
|
-
rowGap: 2,
|
|
85
|
-
},
|
|
86
|
-
conversationBadges: {
|
|
87
|
-
marginTop: 4,
|
|
88
|
-
alignItems: 'flex-start',
|
|
89
|
-
},
|
|
90
|
-
unreadCountBadge: {
|
|
91
|
-
alignSelf: 'flex-end',
|
|
92
|
-
backgroundColor: colors.interaction,
|
|
93
|
-
paddingVertical: 0,
|
|
94
|
-
paddingHorizontal: 10,
|
|
95
|
-
borderRadius: 24,
|
|
96
|
-
color: 'white',
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
//# sourceMappingURL=conversations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversations.js","sourceRoot":"","sources":["../../src/components/conversations.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAA;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAA;AAEzE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAE1B,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,gBAAgB,EAAE,CAAA;IAClF,MAA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,EAAE,eAAe,EAAE,EAAE,EAAE;QACzC,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,mBAAmB,EAAE;QAC/C,YAAY,EAAE;YACZ,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;YACN,iBAAiB,EAAE,CAAC;YACpB,iBAAiB,EAAE,MAAM,CAAC,mBAAmB;YAC7C,UAAU,EAAE,CAAC;YACb,aAAa,EAAE,EAAE;YACjB,iBAAiB,EAAE,EAAE;SACtB;QACD,iBAAiB,EAAE,EAAE;QACrB,gBAAgB,EAAE;YAChB,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,CAAC;SACV;QACD,iBAAiB,EAAE;YACjB,MAAM,EAAE,CAAC;SACV;QACD,kBAAkB,EAAE;YAClB,SAAS,EAAE,CAAC;YACZ,UAAU,EAAE,YAAY;SACzB;QACD,gBAAgB,EAAE;YAChB,SAAS,EAAE,UAAU;YACrB,eAAe,EAAE,MAAM,CAAC,WAAW;YACnC,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,EAAE;YACrB,YAAY,EAAE,EAAE;YAChB,KAAK,EAAE,OAAO;SACf;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useNavigation } from '@react-navigation/native'\nimport { FlashList } from '@shopify/flash-list'\nimport React, { useMemo } from 'react'\nimport { Pressable, StyleSheet, View } from 'react-native'\nimport { useTheme } from '../hooks'\nimport { useConversationsJoltEvents } from '../hooks/use_conversation_jolt_events'\nimport { useConversations } from '../hooks/use_conversations'\nimport { formatDatePreview } from '../utils/date'\nimport { AvatarGroup, Badge, Heading, Text, TextButton } from './display'\nimport { ActionButton } from './display/action_button'\nimport { useCanCreateConversations } from '../hooks/use_chat_permissions'\n\nexport const Conversations = () => {\n const styles = useStyles()\n\n const { conversations, fetchNextPage, refetch, isRefetching } = useConversations()\n const canCreateConversations = useCanCreateConversations()\n\n // TODO: Filter using the API\n const nonEmptyConversations = useMemo(\n () => conversations.filter(c => c.lastMessageTextPreview) || [],\n [conversations]\n )\n const navigation = useNavigation()\n\n useConversationsJoltEvents()\n\n return (\n <View style={styles.container}>\n <FlashList\n data={nonEmptyConversations}\n estimatedItemSize={97}\n contentContainerStyle={styles.contentContainer}\n onRefresh={refetch}\n refreshing={isRefetching}\n ListHeaderComponent={\n <View style={styles.header}>\n <Heading numberOfLines={1} variant=\"h2\">\n Conversations\n </Heading>\n <TextButton>Mark all read</TextButton>\n </View>\n }\n ListEmptyComponent={<Text>No conversations found</Text>}\n renderItem={({ item }) => (\n <Pressable\n style={styles.conversation}\n onPress={() => navigation.navigate('Conversation', { conversation_id: item.id })}\n >\n <AvatarGroup size=\"lg\" sourceUris={item.previewAvatarUrls || []} />\n <View style={styles.conversationBody}>\n <Heading numberOfLines={1} variant=\"h3\" style={styles.conversationTitle}>\n {item.title}\n </Heading>\n <Text style={styles.listItem} numberOfLines={2}>\n {item.lastMessageAuthorName}: {item.lastMessageTextPreview}\n </Text>\n <View style={styles.conversationBadges}>\n {item.badges?.map(badge => (\n <Badge\n key={badge.text}\n variant=\"meta\"\n productLogoName={badge.appName}\n label={badge.pcoResourceType}\n metaLabel={badge.text || ''}\n />\n ))}\n </View>\n </View>\n <View style={styles.conversationExtra}>\n <Text variant=\"secondary\">{formatDatePreview(item.lastMessageCreatedAt)}</Text>\n <UnreadCountBadge count={item.unreadCount} />\n </View>\n </Pressable>\n )}\n onEndReached={() => fetchNextPage()}\n />\n <ActionButton\n visible={canCreateConversations}\n title=\"New conversation\"\n onPress={() => navigation.navigate('Create')}\n />\n </View>\n )\n}\n\nconst UnreadCountBadge = ({ count }: { count: number }) => {\n const styles = useStyles()\n const displayCount = count > 99 ? '99+' : count\n\n if (count === 0) return null\n\n return (\n <Text variant=\"tertiary\" style={styles.unreadCountBadge}>\n {displayCount}\n </Text>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n header: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n paddingTop: 8,\n paddingBottom: 8,\n paddingHorizontal: 16,\n },\n container: { flex: 1 },\n contentContainer: { paddingVertical: 16 },\n listItem: { color: colors.fillColorNeutral020 },\n conversation: {\n flexDirection: 'row',\n gap: 8,\n borderBottomWidth: 1,\n borderBottomColor: colors.fillColorNeutral060,\n paddingTop: 4,\n paddingBottom: 12,\n paddingHorizontal: 16,\n },\n conversationTitle: {},\n conversationBody: {\n flex: 1,\n rowGap: 2,\n },\n conversationExtra: {\n rowGap: 2,\n },\n conversationBadges: {\n marginTop: 4,\n alignItems: 'flex-start',\n },\n unreadCountBadge: {\n alignSelf: 'flex-end',\n backgroundColor: colors.interaction,\n paddingVertical: 0,\n paddingHorizontal: 10,\n borderRadius: 24,\n color: 'white',\n },\n })\n}\n"]}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { useNavigation } from '@react-navigation/native'
|
|
2
|
-
import { FlashList } from '@shopify/flash-list'
|
|
3
|
-
import React, { useMemo } from 'react'
|
|
4
|
-
import { Pressable, StyleSheet, View } from 'react-native'
|
|
5
|
-
import { useTheme } from '../hooks'
|
|
6
|
-
import { useConversationsJoltEvents } from '../hooks/use_conversation_jolt_events'
|
|
7
|
-
import { useConversations } from '../hooks/use_conversations'
|
|
8
|
-
import { formatDatePreview } from '../utils/date'
|
|
9
|
-
import { AvatarGroup, Badge, Heading, Text, TextButton } from './display'
|
|
10
|
-
import { ActionButton } from './display/action_button'
|
|
11
|
-
import { useCanCreateConversations } from '../hooks/use_chat_permissions'
|
|
12
|
-
|
|
13
|
-
export const Conversations = () => {
|
|
14
|
-
const styles = useStyles()
|
|
15
|
-
|
|
16
|
-
const { conversations, fetchNextPage, refetch, isRefetching } = useConversations()
|
|
17
|
-
const canCreateConversations = useCanCreateConversations()
|
|
18
|
-
|
|
19
|
-
// TODO: Filter using the API
|
|
20
|
-
const nonEmptyConversations = useMemo(
|
|
21
|
-
() => conversations.filter(c => c.lastMessageTextPreview) || [],
|
|
22
|
-
[conversations]
|
|
23
|
-
)
|
|
24
|
-
const navigation = useNavigation()
|
|
25
|
-
|
|
26
|
-
useConversationsJoltEvents()
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<View style={styles.container}>
|
|
30
|
-
<FlashList
|
|
31
|
-
data={nonEmptyConversations}
|
|
32
|
-
estimatedItemSize={97}
|
|
33
|
-
contentContainerStyle={styles.contentContainer}
|
|
34
|
-
onRefresh={refetch}
|
|
35
|
-
refreshing={isRefetching}
|
|
36
|
-
ListHeaderComponent={
|
|
37
|
-
<View style={styles.header}>
|
|
38
|
-
<Heading numberOfLines={1} variant="h2">
|
|
39
|
-
Conversations
|
|
40
|
-
</Heading>
|
|
41
|
-
<TextButton>Mark all read</TextButton>
|
|
42
|
-
</View>
|
|
43
|
-
}
|
|
44
|
-
ListEmptyComponent={<Text>No conversations found</Text>}
|
|
45
|
-
renderItem={({ item }) => (
|
|
46
|
-
<Pressable
|
|
47
|
-
style={styles.conversation}
|
|
48
|
-
onPress={() => navigation.navigate('Conversation', { conversation_id: item.id })}
|
|
49
|
-
>
|
|
50
|
-
<AvatarGroup size="lg" sourceUris={item.previewAvatarUrls || []} />
|
|
51
|
-
<View style={styles.conversationBody}>
|
|
52
|
-
<Heading numberOfLines={1} variant="h3" style={styles.conversationTitle}>
|
|
53
|
-
{item.title}
|
|
54
|
-
</Heading>
|
|
55
|
-
<Text style={styles.listItem} numberOfLines={2}>
|
|
56
|
-
{item.lastMessageAuthorName}: {item.lastMessageTextPreview}
|
|
57
|
-
</Text>
|
|
58
|
-
<View style={styles.conversationBadges}>
|
|
59
|
-
{item.badges?.map(badge => (
|
|
60
|
-
<Badge
|
|
61
|
-
key={badge.text}
|
|
62
|
-
variant="meta"
|
|
63
|
-
productLogoName={badge.appName}
|
|
64
|
-
label={badge.pcoResourceType}
|
|
65
|
-
metaLabel={badge.text || ''}
|
|
66
|
-
/>
|
|
67
|
-
))}
|
|
68
|
-
</View>
|
|
69
|
-
</View>
|
|
70
|
-
<View style={styles.conversationExtra}>
|
|
71
|
-
<Text variant="secondary">{formatDatePreview(item.lastMessageCreatedAt)}</Text>
|
|
72
|
-
<UnreadCountBadge count={item.unreadCount} />
|
|
73
|
-
</View>
|
|
74
|
-
</Pressable>
|
|
75
|
-
)}
|
|
76
|
-
onEndReached={() => fetchNextPage()}
|
|
77
|
-
/>
|
|
78
|
-
<ActionButton
|
|
79
|
-
visible={canCreateConversations}
|
|
80
|
-
title="New conversation"
|
|
81
|
-
onPress={() => navigation.navigate('Create')}
|
|
82
|
-
/>
|
|
83
|
-
</View>
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const UnreadCountBadge = ({ count }: { count: number }) => {
|
|
88
|
-
const styles = useStyles()
|
|
89
|
-
const displayCount = count > 99 ? '99+' : count
|
|
90
|
-
|
|
91
|
-
if (count === 0) return null
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<Text variant="tertiary" style={styles.unreadCountBadge}>
|
|
95
|
-
{displayCount}
|
|
96
|
-
</Text>
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const useStyles = () => {
|
|
101
|
-
const { colors } = useTheme()
|
|
102
|
-
|
|
103
|
-
return StyleSheet.create({
|
|
104
|
-
header: {
|
|
105
|
-
flexDirection: 'row',
|
|
106
|
-
justifyContent: 'space-between',
|
|
107
|
-
paddingTop: 8,
|
|
108
|
-
paddingBottom: 8,
|
|
109
|
-
paddingHorizontal: 16,
|
|
110
|
-
},
|
|
111
|
-
container: { flex: 1 },
|
|
112
|
-
contentContainer: { paddingVertical: 16 },
|
|
113
|
-
listItem: { color: colors.fillColorNeutral020 },
|
|
114
|
-
conversation: {
|
|
115
|
-
flexDirection: 'row',
|
|
116
|
-
gap: 8,
|
|
117
|
-
borderBottomWidth: 1,
|
|
118
|
-
borderBottomColor: colors.fillColorNeutral060,
|
|
119
|
-
paddingTop: 4,
|
|
120
|
-
paddingBottom: 12,
|
|
121
|
-
paddingHorizontal: 16,
|
|
122
|
-
},
|
|
123
|
-
conversationTitle: {},
|
|
124
|
-
conversationBody: {
|
|
125
|
-
flex: 1,
|
|
126
|
-
rowGap: 2,
|
|
127
|
-
},
|
|
128
|
-
conversationExtra: {
|
|
129
|
-
rowGap: 2,
|
|
130
|
-
},
|
|
131
|
-
conversationBadges: {
|
|
132
|
-
marginTop: 4,
|
|
133
|
-
alignItems: 'flex-start',
|
|
134
|
-
},
|
|
135
|
-
unreadCountBadge: {
|
|
136
|
-
alignSelf: 'flex-end',
|
|
137
|
-
backgroundColor: colors.interaction,
|
|
138
|
-
paddingVertical: 0,
|
|
139
|
-
paddingHorizontal: 10,
|
|
140
|
-
borderRadius: 24,
|
|
141
|
-
color: 'white',
|
|
142
|
-
},
|
|
143
|
-
})
|
|
144
|
-
}
|