@planningcenter/chat-react-native 3.1.0-rc.13 → 3.1.0-rc.15
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.js +1 -1
- 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 +11 -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 +86 -62
- package/build/screens/conversation_details_screen.js.map +1 -1
- package/build/screens/conversation_filters_screen.d.ts +13 -0
- package/build/screens/conversation_filters_screen.d.ts.map +1 -0
- package/build/screens/conversation_filters_screen.js +346 -0
- package/build/screens/conversation_filters_screen.js.map +1 -0
- package/build/screens/conversation_screen.js +2 -1
- 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/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 +1 -1
- 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 +149 -117
- package/src/screens/conversation_filters_screen.tsx +488 -0
- package/src/screens/conversation_screen.tsx +8 -1
- 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/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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import Svg, {
|
|
2
|
+
import type { TextStyle, ViewProps, ViewStyle } from 'react-native'
|
|
3
|
+
import { Pressable, StyleSheet, View } from 'react-native'
|
|
4
|
+
import Svg, { Defs, LinearGradient, Path, Stop } from 'react-native-svg'
|
|
5
5
|
import { useFontScale, useTheme } from '../../hooks'
|
|
6
|
-
import { Icon } from './icon'
|
|
7
|
-
import { Text } from './text'
|
|
8
6
|
import { platformFontWeightMedium, space } from '../../utils'
|
|
9
7
|
import { tokens } from '../../vendor/tapestry/tokens'
|
|
8
|
+
import { Icon } from './icon'
|
|
9
|
+
import { Text } from './text'
|
|
10
10
|
import { useStatusColorAppearanceMap, type StatusAppearanceUnion } from './utils/status_colors'
|
|
11
11
|
|
|
12
12
|
// =================================
|
|
@@ -72,6 +72,10 @@ interface BadgeProps {
|
|
|
72
72
|
* Shows an icon of the user choice to the left of the text.
|
|
73
73
|
*/
|
|
74
74
|
iconName?: string
|
|
75
|
+
/**
|
|
76
|
+
* Shows an icon of the user choice to the right of the text.
|
|
77
|
+
*/
|
|
78
|
+
iconNameRight?: string
|
|
75
79
|
/**
|
|
76
80
|
* Styles badge wrapper.
|
|
77
81
|
*/
|
|
@@ -80,6 +84,10 @@ interface BadgeProps {
|
|
|
80
84
|
* Specifies the maximum size a font can reach when allowFontScaling is enabled.
|
|
81
85
|
*/
|
|
82
86
|
maxFontSizeMultiplier?: number
|
|
87
|
+
/**
|
|
88
|
+
* Callback function when the badge is pressed.
|
|
89
|
+
*/
|
|
90
|
+
onPress?: () => void
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
export function Badge({
|
|
@@ -87,40 +95,59 @@ export function Badge({
|
|
|
87
95
|
metaLabel,
|
|
88
96
|
style,
|
|
89
97
|
iconName,
|
|
98
|
+
iconNameRight,
|
|
90
99
|
label,
|
|
91
100
|
productLogoName,
|
|
92
101
|
variant = 'default',
|
|
93
102
|
maxFontSizeMultiplier,
|
|
103
|
+
onPress,
|
|
94
104
|
}: BadgeProps) {
|
|
95
105
|
const styles = useStyles({ appearance, maxFontSizeMultiplier, variant })
|
|
96
|
-
const {
|
|
106
|
+
const { showBadgeProductLogo } = useTheme()
|
|
97
107
|
|
|
98
108
|
const isMetaSubtle = variant === 'metaSubtle'
|
|
99
|
-
const isMeta = variant === 'meta'
|
|
100
109
|
const hasMetaLabel = Boolean(metaLabel)
|
|
101
110
|
|
|
102
|
-
const showLogo =
|
|
111
|
+
const showLogo = showBadgeProductLogo && productLogoName
|
|
103
112
|
const ProductLogoSvg = showLogo && PRODUCT_LOGO_COMPONENT_MAP[productLogoName?.toLowerCase()]
|
|
104
113
|
const badgeLabel = isMetaSubtle && hasMetaLabel ? `${label}:` : label
|
|
105
114
|
|
|
106
115
|
return (
|
|
107
|
-
<
|
|
116
|
+
<BadgeWrapper style={[styles.badgeWrapper, style]} onPress={onPress} accessibilityRole="button">
|
|
108
117
|
<View style={styles.badge}>
|
|
109
118
|
{showLogo && ProductLogoSvg && <ProductLogoSvg logoSize={styles.logo.fontSize} />}
|
|
110
119
|
{iconName && <Icon name={iconName} style={styles.icon} />}
|
|
111
120
|
<Text variant="footnote" style={styles.label}>
|
|
112
121
|
{badgeLabel}
|
|
113
122
|
</Text>
|
|
123
|
+
{iconNameRight && <Icon name={iconNameRight} style={styles.iconRight} />}
|
|
114
124
|
</View>
|
|
115
125
|
{hasMetaLabel && (
|
|
116
126
|
<Text variant="footnote" style={styles.metaLabel} numberOfLines={1}>
|
|
117
127
|
{metaLabel}
|
|
118
128
|
</Text>
|
|
119
129
|
)}
|
|
120
|
-
</
|
|
130
|
+
</BadgeWrapper>
|
|
121
131
|
)
|
|
122
132
|
}
|
|
123
133
|
|
|
134
|
+
const BadgeWrapper = ({
|
|
135
|
+
children,
|
|
136
|
+
onPress,
|
|
137
|
+
accessibilityRole,
|
|
138
|
+
...restProps
|
|
139
|
+
}: ViewProps & Pick<BadgeProps, 'onPress'>) => {
|
|
140
|
+
if (onPress) {
|
|
141
|
+
return (
|
|
142
|
+
<Pressable accessibilityRole={accessibilityRole} onPress={onPress} {...restProps}>
|
|
143
|
+
{children}
|
|
144
|
+
</Pressable>
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return <View {...restProps}>{children}</View>
|
|
149
|
+
}
|
|
150
|
+
|
|
124
151
|
// =================================
|
|
125
152
|
// ====== Styles ===================
|
|
126
153
|
// =================================
|
|
@@ -199,6 +226,10 @@ const useStyles = ({
|
|
|
199
226
|
color: statusColorMap[appearance].icon,
|
|
200
227
|
fontSize: badgeFontSize,
|
|
201
228
|
},
|
|
229
|
+
iconRight: {
|
|
230
|
+
color: statusColorMap[appearance].icon,
|
|
231
|
+
fontSize: badgeFontSize - 2,
|
|
232
|
+
},
|
|
202
233
|
logo: {
|
|
203
234
|
fontSize: badgeFontSize * fontScale,
|
|
204
235
|
},
|
|
@@ -50,7 +50,7 @@ type VariantColors = Record<
|
|
|
50
50
|
// ====== Component ================
|
|
51
51
|
// =================================
|
|
52
52
|
|
|
53
|
-
interface ButtonProps extends PressableProps {
|
|
53
|
+
export interface ButtonProps extends PressableProps {
|
|
54
54
|
/**
|
|
55
55
|
* Specifies whether fonts should be scaled down automatically to fit given style constraints.
|
|
56
56
|
*/
|
|
@@ -4,7 +4,7 @@ import { BannerCollapsible } from './banner_collapsible'
|
|
|
4
4
|
import BannerPrimitive from '../primitive/banner_primitive'
|
|
5
5
|
import { View, StyleSheet } from 'react-native'
|
|
6
6
|
import { Avatar } from './avatar'
|
|
7
|
-
import { platformFontWeightMedium } from '../../utils'
|
|
7
|
+
import { platformFontWeightMedium, pluralize } from '../../utils'
|
|
8
8
|
import { Text } from './text'
|
|
9
9
|
|
|
10
10
|
// =================================
|
|
@@ -17,7 +17,7 @@ interface ChildNoticeProps {
|
|
|
17
17
|
|
|
18
18
|
export function ChildNotice({ childMembers }: ChildNoticeProps) {
|
|
19
19
|
const styles = useStyles()
|
|
20
|
-
const heading = `${childMembers.length}
|
|
20
|
+
const heading = `${pluralize(childMembers.length, 'member')} under age 13`
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
23
|
<BannerCollapsible appearance="warning" iconName="general.shieldExclamation" heading={heading}>
|
|
@@ -4,14 +4,15 @@ 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
|
-
import * as
|
|
8
|
-
import * as
|
|
7
|
+
import * as api from '@planningcenter/icons/paths/api'
|
|
8
|
+
import * as brand from '@planningcenter/icons/paths/brand'
|
|
9
9
|
import * as calendar from '@planningcenter/icons/paths/calendar'
|
|
10
|
-
import * as people from '@planningcenter/icons/paths/people'
|
|
11
10
|
import * as churchCenter from '@planningcenter/icons/paths/church-center'
|
|
11
|
+
import * as general from '@planningcenter/icons/paths/general'
|
|
12
|
+
import * as groups from '@planningcenter/icons/paths/groups'
|
|
12
13
|
import * as logomark from '@planningcenter/icons/paths/logomark'
|
|
13
|
-
import * as
|
|
14
|
-
import * as
|
|
14
|
+
import * as people from '@planningcenter/icons/paths/people'
|
|
15
|
+
import * as services from '@planningcenter/icons/paths/services'
|
|
15
16
|
|
|
16
17
|
// =================================
|
|
17
18
|
// ====== Constants ================
|
|
@@ -21,13 +22,14 @@ const FALLBACK_SIZE = 12
|
|
|
21
22
|
|
|
22
23
|
const ICONS = {
|
|
23
24
|
api,
|
|
25
|
+
brand,
|
|
24
26
|
calendar,
|
|
25
|
-
people,
|
|
26
27
|
churchCenter,
|
|
27
|
-
groups,
|
|
28
28
|
general,
|
|
29
|
+
groups,
|
|
29
30
|
logomark,
|
|
30
|
-
|
|
31
|
+
people,
|
|
32
|
+
services,
|
|
31
33
|
} as const
|
|
32
34
|
|
|
33
35
|
type IconStyle = ViewStyle & {
|
|
@@ -39,7 +39,7 @@ export function Text({ style, variant = 'plain', children, ...props }: TextProps
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
|
-
<ReactNativeText style={[
|
|
42
|
+
<ReactNativeText style={[variantStyleMap[variant], style]} {...props}>
|
|
43
43
|
{children}
|
|
44
44
|
</ReactNativeText>
|
|
45
45
|
)
|
|
@@ -52,12 +52,6 @@ export function Text({ style, variant = 'plain', children, ...props }: TextProps
|
|
|
52
52
|
const useStyles = () => {
|
|
53
53
|
const { colors } = useTheme()
|
|
54
54
|
return StyleSheet.create({
|
|
55
|
-
global: {
|
|
56
|
-
fontFamily: Platform.select({
|
|
57
|
-
ios: 'System',
|
|
58
|
-
android: 'normal',
|
|
59
|
-
}),
|
|
60
|
-
},
|
|
61
55
|
plain: {
|
|
62
56
|
color: colors.textColorDefaultPrimary,
|
|
63
57
|
fontSize: tokens.fontSizeMd,
|
package/src/components/index.tsx
CHANGED
package/src/hooks/use_api.ts
CHANGED
|
@@ -6,20 +6,20 @@ import {
|
|
|
6
6
|
} from '@tanstack/react-query'
|
|
7
7
|
import { ApiCollection, ApiResource, ResourceObject } from '../types'
|
|
8
8
|
import { GetRequest, RequestData } from '../utils/client/types'
|
|
9
|
-
import { useApiClient } from './use_api_client'
|
|
9
|
+
import { App, useApiClient } from './use_api_client'
|
|
10
10
|
import { getRequestQueryKey } from './use_suspense_api'
|
|
11
11
|
|
|
12
|
-
interface
|
|
13
|
-
app?:
|
|
12
|
+
interface ApiGetOptions extends GetRequest {
|
|
13
|
+
app?: App
|
|
14
|
+
enabled?: boolean
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export const useApiGet = <T extends ResourceObject | ResourceObject[]>(
|
|
17
|
-
args: SuspenseGetOptions
|
|
18
|
-
) => {
|
|
17
|
+
export const useApiGet = <T extends ResourceObject | ResourceObject[]>(args: ApiGetOptions) => {
|
|
19
18
|
type Resource = ApiResource<T>
|
|
20
19
|
|
|
21
20
|
const { data, ...query } = useQuery<Resource, Response>({
|
|
22
21
|
queryKey: getRequestQueryKey(args),
|
|
22
|
+
enabled: args.enabled,
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
return { ...data, ...query }
|
|
@@ -36,7 +36,7 @@ export type SuspensePaginatorOptions = Omit<
|
|
|
36
36
|
>
|
|
37
37
|
|
|
38
38
|
export const useApiPaginator = <T extends ResourceObject>(
|
|
39
|
-
args:
|
|
39
|
+
args: ApiGetOptions,
|
|
40
40
|
opts?: SuspensePaginatorOptions
|
|
41
41
|
) => {
|
|
42
42
|
const apiClient = useApiClient()
|
|
@@ -52,11 +52,11 @@ export const useApiPaginator = <T extends ResourceObject>(
|
|
|
52
52
|
const pageParmWhere = pageParam?.where || {}
|
|
53
53
|
const argsWhere = args.data.where || {}
|
|
54
54
|
const where = { ...argsWhere, ...pageParmWhere }
|
|
55
|
-
|
|
55
|
+
const app = args.app || 'chat'
|
|
56
56
|
const offset = pageParam?.offset || args.data.offset
|
|
57
57
|
const data = { ...args.data, where, offset }
|
|
58
58
|
|
|
59
|
-
return apiClient.
|
|
59
|
+
return apiClient[app].get({
|
|
60
60
|
url: args.url,
|
|
61
61
|
data,
|
|
62
62
|
})
|
|
@@ -71,10 +71,11 @@ export const useApiPaginator = <T extends ResourceObject>(
|
|
|
71
71
|
|
|
72
72
|
return undefined
|
|
73
73
|
},
|
|
74
|
+
enabled: args.enabled,
|
|
74
75
|
...(opts || {}),
|
|
75
76
|
})
|
|
76
77
|
|
|
77
|
-
const data: T[] = query.data?.pages
|
|
78
|
+
const data: T[] = query.data?.pages?.flatMap(page => page.data) || []
|
|
78
79
|
|
|
79
80
|
return { ...query, data }
|
|
80
81
|
}
|
|
@@ -2,7 +2,7 @@ import { useContext, useMemo } from 'react'
|
|
|
2
2
|
import { ChatContext } from '../contexts/chat_context'
|
|
3
3
|
import { Client } from '../utils/client'
|
|
4
4
|
|
|
5
|
-
type App = 'chat' | 'groups' | 'services'
|
|
5
|
+
export type App = 'chat' | 'groups' | 'services'
|
|
6
6
|
const apps: App[] = ['chat', 'groups', 'services']
|
|
7
7
|
|
|
8
8
|
export type ApiClient = { [_K in App]: Client }
|
|
@@ -4,7 +4,7 @@ import { ApiResource, ConversationResource } from '../types'
|
|
|
4
4
|
import { transformGetToPost } from '../utils/client/request_helpers'
|
|
5
5
|
import { useApiClient } from './use_api_client'
|
|
6
6
|
import { getRequestQueryKey, useSuspenseGet } from './use_suspense_api'
|
|
7
|
-
import { getConversationsRequestArgs } from '
|
|
7
|
+
import { getConversationsRequestArgs } from '../utils/request/conversation'
|
|
8
8
|
|
|
9
9
|
export const getConversationRequestArgs = ({ conversation_id }: { conversation_id: number }) => ({
|
|
10
10
|
url: `/me/conversations/${conversation_id}`,
|
|
@@ -2,12 +2,12 @@ import { InfiniteData, useQueryClient } from '@tanstack/react-query'
|
|
|
2
2
|
import { ApiCollection, ApiResource, ConversationResource } from '../types'
|
|
3
3
|
import { deleteRecordInPagesData, updateOrCreateRecordInPagesData } from '../utils'
|
|
4
4
|
import { useApiClient } from './use_api_client'
|
|
5
|
-
import { getConversationsRequestArgs } from './use_conversations'
|
|
6
5
|
import { useCurrentPerson } from './use_current_person'
|
|
7
6
|
import { useJoltChannel, useJoltEvent } from './use_jolt'
|
|
8
7
|
import { getRequestQueryKey } from './use_suspense_api'
|
|
9
8
|
import { JoltConversationEvent } from '../types/jolt_events'
|
|
10
9
|
import { ConversationDeletedEvent } from '../types/jolt_events/conversation_events'
|
|
10
|
+
import { getConversationsRequestArgs } from '../utils/request/conversation'
|
|
11
11
|
|
|
12
12
|
type QueryData = InfiniteData<ApiCollection<ConversationResource>>
|
|
13
13
|
|
|
@@ -9,10 +9,10 @@ import { MessageCreatedEvent, MessageDeletedEvent } from '../types/jolt_events/m
|
|
|
9
9
|
import { InfiniteData, useQueryClient } from '@tanstack/react-query'
|
|
10
10
|
import { useCurrentPerson } from './use_current_person'
|
|
11
11
|
import { transformMessageEventDataToMessageResource } from '../utils/jolt/transform_message_event_data_to_message_resource'
|
|
12
|
-
import { getMessagesRequestArgs } from './use_conversation_messages'
|
|
13
12
|
import { getRequestQueryKey } from './use_suspense_api'
|
|
14
13
|
import { JoltReactionEvent } from '../types/jolt_events'
|
|
15
14
|
import { transformReactionEventDataToReactionCountResource } from '../utils/jolt/transform_reaction_event_data_to_reaction_count_resource'
|
|
15
|
+
import { getMessagesRequestArgs } from '../utils/request/messages'
|
|
16
16
|
|
|
17
17
|
interface Props {
|
|
18
18
|
conversationId: number
|
|
@@ -1,38 +1,10 @@
|
|
|
1
1
|
import { useMemo } from 'react'
|
|
2
2
|
import { ConversationResource } from '../types'
|
|
3
|
-
import { GetRequest } from '../utils/client/types'
|
|
4
3
|
import { useSuspensePaginator } from './use_suspense_api'
|
|
4
|
+
import { ConversationRequestArgs, getConversationsRequestArgs } from '../utils/request/conversation'
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
data: {
|
|
9
|
-
perPage: 20,
|
|
10
|
-
order: '-last_message',
|
|
11
|
-
fields: {
|
|
12
|
-
Conversation: [
|
|
13
|
-
'created_at',
|
|
14
|
-
'badges',
|
|
15
|
-
'groups',
|
|
16
|
-
'last_message_author_id',
|
|
17
|
-
'last_message_author_name',
|
|
18
|
-
'last_message_created_at',
|
|
19
|
-
'last_message_text_preview',
|
|
20
|
-
'preview_avatar_urls',
|
|
21
|
-
'member_ability',
|
|
22
|
-
'muted',
|
|
23
|
-
'replies_disabled',
|
|
24
|
-
'title',
|
|
25
|
-
'unread_count',
|
|
26
|
-
'updated_at',
|
|
27
|
-
],
|
|
28
|
-
ConversationBadge: ['app_name', 'pco_resource_type', 'text'],
|
|
29
|
-
},
|
|
30
|
-
include: ['badges'],
|
|
31
|
-
},
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
export function useConversations() {
|
|
35
|
-
const requestArgs = getConversationsRequestArgs()
|
|
6
|
+
export function useConversations(args?: Partial<ConversationRequestArgs>) {
|
|
7
|
+
const requestArgs = getConversationsRequestArgs(args)
|
|
36
8
|
const { data, ...rest } = useSuspensePaginator<ConversationResource>(requestArgs)
|
|
37
9
|
|
|
38
10
|
const conversations = useMemo(
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AppName } from '../types/resources/app_name'
|
|
2
|
+
import { GroupResource, SourceType } from '../types/resources/group_resource'
|
|
3
|
+
import { useApiPaginator } from './use_api'
|
|
4
|
+
|
|
5
|
+
type UseGroupsProps = {
|
|
6
|
+
source_app_name: AppName
|
|
7
|
+
source_type: SourceType
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const useGroups = ({ source_app_name, source_type }: UseGroupsProps) => {
|
|
11
|
+
return useApiPaginator<GroupResource>({
|
|
12
|
+
url: '/me/groups',
|
|
13
|
+
data: {
|
|
14
|
+
fields: {
|
|
15
|
+
Group: [],
|
|
16
|
+
},
|
|
17
|
+
where: {
|
|
18
|
+
source_app_name,
|
|
19
|
+
source_type,
|
|
20
|
+
},
|
|
21
|
+
perPage: 100,
|
|
22
|
+
},
|
|
23
|
+
app: 'chat',
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const useCanDisplayGroups = (props: UseGroupsProps) => {
|
|
28
|
+
const { data: teams = [] } = useGroups(props)
|
|
29
|
+
|
|
30
|
+
return teams?.length > 0
|
|
31
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GroupsGroupResource } from '../types'
|
|
2
|
+
import { useApiPaginator } from './use_api'
|
|
3
|
+
|
|
4
|
+
export const useGroupsGroups = () => {
|
|
5
|
+
return useApiPaginator<GroupsGroupResource>({
|
|
6
|
+
url: '/me/groups',
|
|
7
|
+
data: {
|
|
8
|
+
perPage: 100,
|
|
9
|
+
fields: {
|
|
10
|
+
Group: ['can_create_conversation', 'name', 'header_image', 'memberships_count'],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
app: 'groups',
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const useCanDisplayGroupsGroups = () => {
|
|
18
|
+
const { data: groups = [] } = useGroupsGroups()
|
|
19
|
+
return groups?.length > 0
|
|
20
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TeamOptionResource, TeamOptionResponseItem } from '../types'
|
|
2
|
+
import { useApiGet } from './use_api'
|
|
3
|
+
|
|
4
|
+
export const useServicesTeams = () => {
|
|
5
|
+
const { data: chat } = useApiGet<TeamOptionResource>({
|
|
6
|
+
url: '/chat',
|
|
7
|
+
data: {
|
|
8
|
+
fields: {
|
|
9
|
+
Chat: ['teams'],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
app: 'services',
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
return chat?.teams || []
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const useServicesTeamsMap = () => {
|
|
19
|
+
const teams = useServicesTeams()
|
|
20
|
+
|
|
21
|
+
return teams.reduce(
|
|
22
|
+
(acc, team) => {
|
|
23
|
+
const id = `Services-Team-${team.value.teamId}`
|
|
24
|
+
acc[id] = team
|
|
25
|
+
|
|
26
|
+
return acc
|
|
27
|
+
},
|
|
28
|
+
{} as Record<string, TeamOptionResponseItem>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from '@tanstack/react-query'
|
|
7
7
|
import { ApiCollection, ApiResource, ResourceObject } from '../types'
|
|
8
8
|
import { GetRequest, RequestData } from '../utils/client/types'
|
|
9
|
-
import { useApiClient } from './use_api_client'
|
|
9
|
+
import { App, useApiClient } from './use_api_client'
|
|
10
10
|
|
|
11
11
|
interface SuspenseGetOptions extends GetRequest {
|
|
12
|
-
app?:
|
|
12
|
+
app?: App
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export const useSuspenseGet = <T extends ResourceObject | ResourceObject[]>(
|
|
@@ -51,11 +51,11 @@ export const useSuspensePaginator = <T extends ResourceObject>(
|
|
|
51
51
|
const pageParmWhere = pageParam?.where || {}
|
|
52
52
|
const argsWhere = args.data.where || {}
|
|
53
53
|
const where = { ...argsWhere, ...pageParmWhere }
|
|
54
|
-
|
|
54
|
+
const app = args.app || 'chat'
|
|
55
55
|
const offset = pageParam?.offset || args.data.offset
|
|
56
56
|
const data = { ...args.data, where, offset }
|
|
57
57
|
|
|
58
|
-
return apiClient.
|
|
58
|
+
return apiClient[app].get({
|
|
59
59
|
url: args.url,
|
|
60
60
|
data,
|
|
61
61
|
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { GroupResource } from '../types/resources/group_resource'
|
|
2
|
+
import { useApiPaginator } from './use_api'
|
|
3
|
+
|
|
4
|
+
export const useTeams = () => {
|
|
5
|
+
return useApiPaginator<GroupResource>({
|
|
6
|
+
url: '/me/groups',
|
|
7
|
+
data: {
|
|
8
|
+
fields: {
|
|
9
|
+
Group: [],
|
|
10
|
+
},
|
|
11
|
+
where: {
|
|
12
|
+
source_app_name: 'Services',
|
|
13
|
+
source_type: 'Team',
|
|
14
|
+
},
|
|
15
|
+
perPage: 100,
|
|
16
|
+
},
|
|
17
|
+
app: 'chat',
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const useCanDisplayTeams = () => {
|
|
22
|
+
const { data: teams = [] } = useTeams()
|
|
23
|
+
|
|
24
|
+
return teams?.length > 0
|
|
25
|
+
}
|
package/src/navigation/index.tsx
CHANGED
|
@@ -23,6 +23,10 @@ import { NotFound } from '../screens/not_found'
|
|
|
23
23
|
import { ReactionsScreen, ReactionsScreenOptions } from '../screens/reactions_screen'
|
|
24
24
|
import { HeaderRightButton } from './header'
|
|
25
25
|
import { ScreenLayout } from './screenLayout'
|
|
26
|
+
import {
|
|
27
|
+
ConversationFiltersScreen,
|
|
28
|
+
ConversationFiltersScreenOptions,
|
|
29
|
+
} from '../screens/conversation_filters_screen'
|
|
26
30
|
|
|
27
31
|
export const CreateConversationStack = createNativeStackNavigator({
|
|
28
32
|
initialRouteName: 'ConversationSelectRecipients',
|
|
@@ -75,6 +79,10 @@ export const ChatStack = createNativeStackNavigator({
|
|
|
75
79
|
),
|
|
76
80
|
}),
|
|
77
81
|
},
|
|
82
|
+
ConversationFilters: {
|
|
83
|
+
screen: ConversationFiltersScreen,
|
|
84
|
+
options: ConversationFiltersScreenOptions,
|
|
85
|
+
},
|
|
78
86
|
Conversation: {
|
|
79
87
|
screen: ConversationScreen,
|
|
80
88
|
},
|