@planningcenter/chat-react-native 3.16.0-rc.4 → 3.16.0-rc.6
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.js +1 -1
- package/build/components/conversation/message.js.map +1 -1
- package/build/contexts/chat_context.d.ts +3 -0
- package/build/contexts/chat_context.d.ts.map +1 -1
- package/build/contexts/chat_context.js +3 -1
- package/build/contexts/chat_context.js.map +1 -1
- package/build/hooks/index.d.ts +3 -0
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +3 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use_current_person.d.ts.map +1 -1
- package/build/hooks/use_current_person.js +9 -1
- package/build/hooks/use_current_person.js.map +1 -1
- package/build/hooks/use_organization.d.ts +39 -0
- package/build/hooks/use_organization.d.ts.map +1 -0
- package/build/hooks/use_organization.js +14 -0
- package/build/hooks/use_organization.js.map +1 -0
- package/build/hooks/use_qualified_by_age.d.ts +2 -0
- package/build/hooks/use_qualified_by_age.d.ts.map +1 -0
- package/build/hooks/use_qualified_by_age.js +14 -0
- package/build/hooks/use_qualified_by_age.js.map +1 -0
- package/build/hooks/use_submit_age_check.d.ts +78 -0
- package/build/hooks/use_submit_age_check.d.ts.map +1 -0
- package/build/hooks/use_submit_age_check.js +37 -0
- package/build/hooks/use_submit_age_check.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/navigation/chat_access_gate.d.ts +3 -0
- package/build/navigation/chat_access_gate.d.ts.map +1 -0
- package/build/navigation/chat_access_gate.js +46 -0
- package/build/navigation/chat_access_gate.js.map +1 -0
- package/build/navigation/index.d.ts +6 -4
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +6 -3
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/screenLayout.d.ts +3 -0
- package/build/navigation/screenLayout.d.ts.map +1 -1
- package/build/navigation/screenLayout.js +8 -0
- package/build/navigation/screenLayout.js.map +1 -1
- package/build/screens/age_check/age_check_required_screen.d.ts +3 -0
- package/build/screens/age_check/age_check_required_screen.d.ts.map +1 -0
- package/build/screens/age_check/age_check_required_screen.js +148 -0
- package/build/screens/age_check/age_check_required_screen.js.map +1 -0
- package/build/screens/age_check/age_check_underage_screen.d.ts +6 -0
- package/build/screens/age_check/age_check_underage_screen.d.ts.map +1 -0
- package/build/screens/age_check/age_check_underage_screen.js +71 -0
- package/build/screens/age_check/age_check_underage_screen.js.map +1 -0
- package/build/screens/age_check/components/age_check_select_birthdate_modal.d.ts +11 -0
- package/build/screens/age_check/components/age_check_select_birthdate_modal.d.ts.map +1 -0
- package/build/screens/age_check/components/age_check_select_birthdate_modal.js +91 -0
- package/build/screens/age_check/components/age_check_select_birthdate_modal.js.map +1 -0
- package/build/screens/age_check/index.d.ts +3 -0
- package/build/screens/age_check/index.d.ts.map +1 -0
- package/build/screens/age_check/index.js +3 -0
- package/build/screens/age_check/index.js.map +1 -0
- package/build/screens/age_check/screen_props.d.ts +5 -0
- package/build/screens/age_check/screen_props.d.ts.map +1 -0
- package/build/screens/age_check/screen_props.js +2 -0
- package/build/screens/age_check/screen_props.js.map +1 -0
- 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/organization.d.ts +6 -0
- package/build/types/resources/organization.d.ts.map +1 -0
- package/build/types/resources/organization.js +2 -0
- package/build/types/resources/organization.js.map +1 -0
- package/build/types/resources/person.d.ts +7 -0
- package/build/types/resources/person.d.ts.map +1 -1
- package/build/types/resources/person.js +5 -1
- package/build/types/resources/person.js.map +1 -1
- package/package.json +3 -2
- package/src/components/conversation/message.tsx +1 -1
- package/src/contexts/chat_context.tsx +14 -1
- package/src/hooks/index.ts +3 -0
- package/src/hooks/use_current_person.ts +9 -1
- package/src/hooks/use_organization.ts +17 -0
- package/src/hooks/use_qualified_by_age.ts +17 -0
- package/src/hooks/use_submit_age_check.ts +48 -0
- package/src/index.tsx +1 -0
- package/src/navigation/chat_access_gate.tsx +60 -0
- package/src/navigation/index.tsx +6 -3
- package/src/navigation/screenLayout.tsx +11 -0
- package/src/screens/age_check/age_check_required_screen.tsx +197 -0
- package/src/screens/age_check/age_check_underage_screen.tsx +96 -0
- package/src/screens/age_check/components/age_check_select_birthdate_modal.tsx +143 -0
- package/src/screens/age_check/index.ts +2 -0
- package/src/screens/age_check/screen_props.ts +3 -0
- package/src/types/resources/index.ts +1 -0
- package/src/types/resources/organization.ts +6 -0
- package/src/types/resources/person.ts +10 -0
|
@@ -95,7 +95,7 @@ export function Message({ canDeleteNonAuthoredMessages, conversation_id, latestR
|
|
|
95
95
|
const messageBottomMargin = message.lastInGroup ? 12 : hasReactions || showMessageMeta ? 8 : 4;
|
|
96
96
|
const messagePendingLabel = isPersisted ? 'Saving' : 'Sending';
|
|
97
97
|
const showReplyCountButton = !inReplyScreen && message.replyRootId === message.id && REPLIES_FEATURE_ENABLED;
|
|
98
|
-
return (<Pressable onLongPress={handleMessageLongPress} onPress={() => setShowMessageMetaToggle(!showMessageMetaToggle)} onPressIn={handleMessagePressIn} onPressOut={handleMessagePressOut} android_ripple={{ color: colors.androidRippleNeutral }} accessibilityHint="Long press to view message actions like reacting and copying.">
|
|
98
|
+
return (<Pressable onLongPress={handleMessageLongPress} onPress={() => setShowMessageMetaToggle(!showMessageMetaToggle)} onPressIn={handleMessagePressIn} onPressOut={handleMessagePressOut} android_ripple={{ color: colors.androidRippleNeutral, borderless: false, foreground: true }} accessibilityHint="Long press to view message actions like reacting and copying.">
|
|
99
99
|
<Animated.View style={[styles.message, animatedBackgroundColor]}>
|
|
100
100
|
{!message.mine && (<View>
|
|
101
101
|
{renderAuthor ? (<Avatar size={'md'} sourceUri={message.author.avatar} style={styles.avatar} maxFontSizeMultiplier={1} minFontSizeMultiplier={1}/>) : (<View style={styles.avatarPlace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EAAE,CAAC;SACP;QACD,cAAc,EAAE;YACd,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,CAAC;SACP;QACD,SAAS,EAAE;YACT,KAAK,EAAE,MAAM,CAAC,eAAe;SAC9B;QACD,SAAS,EAAE;YACT,KAAK,EAAE,MAAM,CAAC,eAAe;SAC9B;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useNavigation } from '@react-navigation/native'\nimport React, { useEffect } from 'react'\nimport { Pressable, StyleSheet, useWindowDimensions, View } from 'react-native'\nimport { MessageReaction } from '../../components/conversation/message_reaction'\nimport { Avatar, Icon, Spinner, Text, TextButton, TextInlineButton } from '../../components/display'\nimport {\n useAnimatedMessageBackgroundColor,\n useInteractionGhostBackgroundColor,\n useTheme,\n} from '../../hooks'\nimport { MessageResource } from '../../types'\nimport { ReactionCountResource } from '../../types/resources/reaction'\nimport { MessageAttachments } from './message_attachments'\nimport ErrorBoundary from '../page/error_boundary'\nimport { MessageMarkdown } from './message_markdown'\nimport { DenormalizedMessageAttachmentResource } from '../../types/resources/denormalized_attachment_resource'\nimport {\n CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,\n MESSAGE_AUTHOR_AVATAR_COLUMN_WIDTH,\n platformFontWeightMedium,\n} from '../../utils/styles'\nimport Animated from 'react-native-reanimated'\nimport { useLiveRelativeTime } from '../../hooks/use_live_relative_time'\nimport { MessageReadReceipts } from './message_read_receipts'\nimport { isNewMessage, useMessageCreateOrUpdate } from '../../hooks/use_message_create_or_update'\nimport { Haptic } from '../../utils/native_adapters'\nimport { TheirReplyConnector, MyReplyConnector } from './reply_connectors'\nimport { REPLIES_FEATURE_ENABLED } from '../../utils'\n\n/** Message\n * Component for display of a message within a conversation list\n */\ninterface MessageProps extends MessageResource {\n canDeleteNonAuthoredMessages: boolean\n conversation_id: number\n latestReadMessageSortKey?: string\n inReplyScreen?: boolean\n}\n\nexport function Message({\n canDeleteNonAuthoredMessages,\n conversation_id,\n latestReadMessageSortKey,\n inReplyScreen,\n ...message\n}: MessageProps) {\n const { text, reactionCounts, pending, error } = message\n const styles = useMessageStyles(message)\n const navigation = useNavigation()\n const { colors } = useTheme()\n const hasReactions = reactionCounts.length > 0\n const [showMessageMetaToggle, setShowMessageMetaToggle] = React.useState(false)\n const showMessageMeta =\n showMessageMetaToggle || message.myLatestInConversation || !!pending || !!error || false\n const timestamp = useLiveRelativeTime(message.createdAt)\n const wasEdited = Boolean(message.textEditedAt)\n const isPersisted = !isNewMessage(message)\n const [temporarilyHidePendingState, setTemporarilyHidePendingState] = React.useState(true)\n const [messageBubbleHeight, setMessageBubbleHeight] = React.useState(0)\n const { animatedBackgroundColor, handleMessagePressIn, handleMessagePressOut } =\n useAnimatedMessageBackgroundColor()\n\n useEffect(() => {\n if (pending) {\n const timer = setTimeout(() => {\n setTemporarilyHidePendingState(false)\n }, 2000)\n return () => clearTimeout(timer)\n }\n return () => {}\n }, [pending])\n\n const retryFailedSaveMutation = useMessageCreateOrUpdate({\n conversationId: conversation_id,\n message,\n })\n\n const handleRetry = () => {\n if (text && error) {\n retryFailedSaveMutation.mutateAsync({\n text,\n attachments: message.attachmentsForCreate,\n })\n }\n }\n\n const handleMessageLongPress = () => {\n if (!isPersisted) return\n\n Haptic.impactLight()\n navigation.navigate('MessageActions', {\n message_id: message.id,\n conversation_id,\n canDeleteNonAuthoredMessages,\n inReplyScreen,\n })\n }\n const handleReactionLongPress = (reaction: ReactionCountResource) => {\n Haptic.impactLight()\n navigation.navigate('Reactions', {\n message_id: message.id,\n conversation_id,\n reaction_value: reaction.value,\n })\n }\n\n const handleMessageAttachmentLongPress = (attachment: DenormalizedMessageAttachmentResource) => {\n Haptic.impactLight()\n navigation.navigate('AttachmentActions', {\n attachmentId: attachment?.id,\n attachmentContentType: attachment?.attributes.contentType,\n attachmentUrl: attachment?.attributes.url,\n conversation_id,\n canDeleteNonAuthoredMessages,\n myMessage: message.mine,\n })\n }\n\n const handleNavigateToReplyPress = () => {\n navigation.navigate('ConversationReply', {\n conversation_id,\n reply_root_id: message.id,\n // TODO: Add a way to pass the reply root author's name\n })\n }\n\n const metaProps = {\n authorName: message.author.name,\n createdAt: message.createdAt,\n }\n\n const renderAuthor = (!message.mine && message.renderAuthor) || false\n const messageBottomMargin = message.lastInGroup ? 12 : hasReactions || showMessageMeta ? 8 : 4\n const messagePendingLabel = isPersisted ? 'Saving' : 'Sending'\n const showReplyCountButton =\n !inReplyScreen && message.replyRootId === message.id && REPLIES_FEATURE_ENABLED\n\n return (\n <Pressable\n onLongPress={handleMessageLongPress}\n onPress={() => setShowMessageMetaToggle(!showMessageMetaToggle)}\n onPressIn={handleMessagePressIn}\n onPressOut={handleMessagePressOut}\n android_ripple={{ color: colors.androidRippleNeutral }}\n accessibilityHint=\"Long press to view message actions like reacting and copying.\"\n >\n <Animated.View style={[styles.message, animatedBackgroundColor]}>\n {!message.mine && (\n <View>\n {renderAuthor ? (\n <Avatar\n size={'md'}\n sourceUri={message.author.avatar}\n style={styles.avatar}\n maxFontSizeMultiplier={1}\n minFontSizeMultiplier={1}\n />\n ) : (\n <View style={styles.avatarPlaceholder} />\n )}\n <TheirReplyConnector message={message} messageBubbleHeight={messageBubbleHeight} />\n </View>\n )}\n <View style={[styles.messageContent, { marginBottom: messageBottomMargin }]}>\n {renderAuthor && <Text variant=\"tertiary\">{message.author.name}</Text>}\n <View\n style={styles.messageBubble}\n onLayout={e => setMessageBubbleHeight(e.nativeEvent.layout.height)}\n >\n <ErrorBoundary>\n <MessageAttachments\n attachments={message.attachments}\n metaProps={metaProps}\n onMessageAttachmentLongPress={handleMessageAttachmentLongPress}\n onMessageLongPress={handleMessageLongPress}\n />\n </ErrorBoundary>\n {text && (\n <View style={styles.messageText}>\n <MessageMarkdown text={text} />\n </View>\n )}\n </View>\n {showReplyCountButton && (\n <TextButton\n variant=\"footnote\"\n onPress={handleNavigateToReplyPress}\n style={styles.messageReplyCount}\n accessibilityHint=\"Navigates to reply screen for this message\"\n accessibilityRole=\"link\"\n >\n {message.replyCount} replies\n </TextButton>\n )}\n {hasReactions && (\n <View style={styles.messageReactions}>\n {reactionCounts.map(reaction => (\n <MessageReaction\n key={reaction.value}\n reaction={reaction}\n onLongPress={handleReactionLongPress}\n message={message}\n conversationId={conversation_id}\n />\n ))}\n </View>\n )}\n {showMessageMeta && (\n <View style={styles.messageMeta}>\n {message.mine && !pending && !error && (\n <MessageReadReceipts\n message={message}\n latestReadMessageSortKey={latestReadMessageSortKey}\n />\n )}\n {error ? (\n <View style={styles.errorContainer}>\n {retryFailedSaveMutation.isPending ? (\n <Spinner size={12} />\n ) : (\n <Icon name=\"general.exclamationTriangle\" size={12} style={styles.errorIcon} />\n )}\n <Text variant=\"footnote\" style={styles.errorText}>\n Failed to {isPersisted ? 'edit' : 'send'} |{' '}\n <TextInlineButton\n onPress={handleRetry}\n variant=\"footnote\"\n appearance=\"danger\"\n disabled={retryFailedSaveMutation.isPending}\n >\n Try again\n </TextInlineButton>\n </Text>\n </View>\n ) : pending && (!temporarilyHidePendingState || isPersisted) ? (\n <View style={styles.pendingIndicatorContainer}>\n <Icon\n name=\"general.outlinedClock\"\n size={12}\n color={colors.iconColorDefaultSecondary}\n />\n <Text variant=\"footnote\">{messagePendingLabel}</Text>\n </View>\n ) : isPersisted ? (\n <Text variant=\"footnote\">{timestamp}</Text>\n ) : null}\n {!pending && !error && wasEdited && (\n <Text variant=\"footnote\">\n |{' '}\n <Text variant=\"footnote\" style={styles.editedText}>\n Edited\n </Text>\n </Text>\n )}\n </View>\n )}\n </View>\n {message.mine && (\n <MyReplyConnector message={message} messageBubbleHeight={messageBubbleHeight} />\n )}\n </Animated.View>\n </Pressable>\n )\n}\n\nconst useMessageStyles = ({ mine }: MessageResource) => {\n const { colors } = useTheme()\n const myMessageBackgroundColor = useInteractionGhostBackgroundColor()\n const { width } = useWindowDimensions()\n const tabletWidth = width >= 744 // Smallest iPad Mini's width\n\n const messageBubbleBackgroundColor = mine ? myMessageBackgroundColor : colors.fillColorNeutral070\n\n return StyleSheet.create({\n message: {\n gap: 8,\n flexDirection: mine ? 'row-reverse' : 'row',\n paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,\n },\n messageContent: {\n flex: 1,\n gap: 4,\n },\n avatar: {\n marginBottom: 8,\n },\n avatarPlaceholder: {\n width: MESSAGE_AUTHOR_AVATAR_COLUMN_WIDTH, // Same width as avatar\n },\n messageBubble: {\n backgroundColor: messageBubbleBackgroundColor,\n borderRadius: 8,\n maxWidth: tabletWidth ? 360 : '80%',\n alignSelf: mine ? 'flex-end' : 'flex-start',\n },\n messageText: {\n paddingVertical: 6,\n paddingHorizontal: 8,\n },\n messageReactions: {\n flexDirection: 'row',\n gap: 4,\n justifyContent: mine ? 'flex-end' : 'flex-start',\n },\n messageReplyCount: {\n alignSelf: mine ? 'flex-end' : 'flex-start',\n },\n messageMeta: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: mine ? 'flex-end' : 'flex-start',\n gap: 4,\n },\n editedText: {\n fontWeight: platformFontWeightMedium,\n },\n pendingIndicatorContainer: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 4,\n },\n errorContainer: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 4,\n },\n errorIcon: {\n color: colors.statusErrorIcon,\n },\n errorText: {\n color: colors.statusErrorText,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/components/conversation/message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AAChF,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OA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;YACjB,KAAK,EAAE,kCAAkC,EAAE,uBAAuB;SACnE;QACD,aAAa,EAAE;YACb,eAAe,EAAE,4BAA4B;YAC7C,YAAY,EAAE,CAAC;YACf,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK;YACnC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY;SAC5C;QACD,WAAW,EAAE;YACX,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,CAAC;SACrB;QACD,gBAAgB,EAAE;YAChB,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;YACN,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY;SACjD;QACD,iBAAiB,EAAE;YACjB,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY;SAC5C;QACD,WAAW,EAAE;YACX,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY;YAChD,GAAG,EAAE,CAAC;SACP;QACD,UAAU,EAAE;YACV,UAAU,EAAE,wBAAwB;SACrC;QACD,yBAAyB,EAAE;YACzB,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,CAAC;SACP;QACD,cAAc,EAAE;YACd,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,CAAC;SACP;QACD,SAAS,EAAE;YACT,KAAK,EAAE,MAAM,CAAC,eAAe;SAC9B;QACD,SAAS,EAAE;YACT,KAAK,EAAE,MAAM,CAAC,eAAe;SAC9B;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useNavigation } from '@react-navigation/native'\nimport React, { useEffect } from 'react'\nimport { Pressable, StyleSheet, useWindowDimensions, View } from 'react-native'\nimport { MessageReaction } from '../../components/conversation/message_reaction'\nimport { Avatar, Icon, Spinner, Text, TextButton, TextInlineButton } from '../../components/display'\nimport {\n useAnimatedMessageBackgroundColor,\n useInteractionGhostBackgroundColor,\n useTheme,\n} from '../../hooks'\nimport { MessageResource } from '../../types'\nimport { ReactionCountResource } from '../../types/resources/reaction'\nimport { MessageAttachments } from './message_attachments'\nimport ErrorBoundary from '../page/error_boundary'\nimport { MessageMarkdown } from './message_markdown'\nimport { DenormalizedMessageAttachmentResource } from '../../types/resources/denormalized_attachment_resource'\nimport {\n CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,\n MESSAGE_AUTHOR_AVATAR_COLUMN_WIDTH,\n platformFontWeightMedium,\n} from '../../utils/styles'\nimport Animated from 'react-native-reanimated'\nimport { useLiveRelativeTime } from '../../hooks/use_live_relative_time'\nimport { MessageReadReceipts } from './message_read_receipts'\nimport { isNewMessage, useMessageCreateOrUpdate } from '../../hooks/use_message_create_or_update'\nimport { Haptic } from '../../utils/native_adapters'\nimport { TheirReplyConnector, MyReplyConnector } from './reply_connectors'\nimport { REPLIES_FEATURE_ENABLED } from '../../utils'\n\n/** Message\n * Component for display of a message within a conversation list\n */\ninterface MessageProps extends MessageResource {\n canDeleteNonAuthoredMessages: boolean\n conversation_id: number\n latestReadMessageSortKey?: string\n inReplyScreen?: boolean\n}\n\nexport function Message({\n canDeleteNonAuthoredMessages,\n conversation_id,\n latestReadMessageSortKey,\n inReplyScreen,\n ...message\n}: MessageProps) {\n const { text, reactionCounts, pending, error } = message\n const styles = useMessageStyles(message)\n const navigation = useNavigation()\n const { colors } = useTheme()\n const hasReactions = reactionCounts.length > 0\n const [showMessageMetaToggle, setShowMessageMetaToggle] = React.useState(false)\n const showMessageMeta =\n showMessageMetaToggle || message.myLatestInConversation || !!pending || !!error || false\n const timestamp = useLiveRelativeTime(message.createdAt)\n const wasEdited = Boolean(message.textEditedAt)\n const isPersisted = !isNewMessage(message)\n const [temporarilyHidePendingState, setTemporarilyHidePendingState] = React.useState(true)\n const [messageBubbleHeight, setMessageBubbleHeight] = React.useState(0)\n const { animatedBackgroundColor, handleMessagePressIn, handleMessagePressOut } =\n useAnimatedMessageBackgroundColor()\n\n useEffect(() => {\n if (pending) {\n const timer = setTimeout(() => {\n setTemporarilyHidePendingState(false)\n }, 2000)\n return () => clearTimeout(timer)\n }\n return () => {}\n }, [pending])\n\n const retryFailedSaveMutation = useMessageCreateOrUpdate({\n conversationId: conversation_id,\n message,\n })\n\n const handleRetry = () => {\n if (text && error) {\n retryFailedSaveMutation.mutateAsync({\n text,\n attachments: message.attachmentsForCreate,\n })\n }\n }\n\n const handleMessageLongPress = () => {\n if (!isPersisted) return\n\n Haptic.impactLight()\n navigation.navigate('MessageActions', {\n message_id: message.id,\n conversation_id,\n canDeleteNonAuthoredMessages,\n inReplyScreen,\n })\n }\n const handleReactionLongPress = (reaction: ReactionCountResource) => {\n Haptic.impactLight()\n navigation.navigate('Reactions', {\n message_id: message.id,\n conversation_id,\n reaction_value: reaction.value,\n })\n }\n\n const handleMessageAttachmentLongPress = (attachment: DenormalizedMessageAttachmentResource) => {\n Haptic.impactLight()\n navigation.navigate('AttachmentActions', {\n attachmentId: attachment?.id,\n attachmentContentType: attachment?.attributes.contentType,\n attachmentUrl: attachment?.attributes.url,\n conversation_id,\n canDeleteNonAuthoredMessages,\n myMessage: message.mine,\n })\n }\n\n const handleNavigateToReplyPress = () => {\n navigation.navigate('ConversationReply', {\n conversation_id,\n reply_root_id: message.id,\n // TODO: Add a way to pass the reply root author's name\n })\n }\n\n const metaProps = {\n authorName: message.author.name,\n createdAt: message.createdAt,\n }\n\n const renderAuthor = (!message.mine && message.renderAuthor) || false\n const messageBottomMargin = message.lastInGroup ? 12 : hasReactions || showMessageMeta ? 8 : 4\n const messagePendingLabel = isPersisted ? 'Saving' : 'Sending'\n const showReplyCountButton =\n !inReplyScreen && message.replyRootId === message.id && REPLIES_FEATURE_ENABLED\n\n return (\n <Pressable\n onLongPress={handleMessageLongPress}\n onPress={() => setShowMessageMetaToggle(!showMessageMetaToggle)}\n onPressIn={handleMessagePressIn}\n onPressOut={handleMessagePressOut}\n android_ripple={{ color: colors.androidRippleNeutral, borderless: false, foreground: true }}\n accessibilityHint=\"Long press to view message actions like reacting and copying.\"\n >\n <Animated.View style={[styles.message, animatedBackgroundColor]}>\n {!message.mine && (\n <View>\n {renderAuthor ? (\n <Avatar\n size={'md'}\n sourceUri={message.author.avatar}\n style={styles.avatar}\n maxFontSizeMultiplier={1}\n minFontSizeMultiplier={1}\n />\n ) : (\n <View style={styles.avatarPlaceholder} />\n )}\n <TheirReplyConnector message={message} messageBubbleHeight={messageBubbleHeight} />\n </View>\n )}\n <View style={[styles.messageContent, { marginBottom: messageBottomMargin }]}>\n {renderAuthor && <Text variant=\"tertiary\">{message.author.name}</Text>}\n <View\n style={styles.messageBubble}\n onLayout={e => setMessageBubbleHeight(e.nativeEvent.layout.height)}\n >\n <ErrorBoundary>\n <MessageAttachments\n attachments={message.attachments}\n metaProps={metaProps}\n onMessageAttachmentLongPress={handleMessageAttachmentLongPress}\n onMessageLongPress={handleMessageLongPress}\n />\n </ErrorBoundary>\n {text && (\n <View style={styles.messageText}>\n <MessageMarkdown text={text} />\n </View>\n )}\n </View>\n {showReplyCountButton && (\n <TextButton\n variant=\"footnote\"\n onPress={handleNavigateToReplyPress}\n style={styles.messageReplyCount}\n accessibilityHint=\"Navigates to reply screen for this message\"\n accessibilityRole=\"link\"\n >\n {message.replyCount} replies\n </TextButton>\n )}\n {hasReactions && (\n <View style={styles.messageReactions}>\n {reactionCounts.map(reaction => (\n <MessageReaction\n key={reaction.value}\n reaction={reaction}\n onLongPress={handleReactionLongPress}\n message={message}\n conversationId={conversation_id}\n />\n ))}\n </View>\n )}\n {showMessageMeta && (\n <View style={styles.messageMeta}>\n {message.mine && !pending && !error && (\n <MessageReadReceipts\n message={message}\n latestReadMessageSortKey={latestReadMessageSortKey}\n />\n )}\n {error ? (\n <View style={styles.errorContainer}>\n {retryFailedSaveMutation.isPending ? (\n <Spinner size={12} />\n ) : (\n <Icon name=\"general.exclamationTriangle\" size={12} style={styles.errorIcon} />\n )}\n <Text variant=\"footnote\" style={styles.errorText}>\n Failed to {isPersisted ? 'edit' : 'send'} |{' '}\n <TextInlineButton\n onPress={handleRetry}\n variant=\"footnote\"\n appearance=\"danger\"\n disabled={retryFailedSaveMutation.isPending}\n >\n Try again\n </TextInlineButton>\n </Text>\n </View>\n ) : pending && (!temporarilyHidePendingState || isPersisted) ? (\n <View style={styles.pendingIndicatorContainer}>\n <Icon\n name=\"general.outlinedClock\"\n size={12}\n color={colors.iconColorDefaultSecondary}\n />\n <Text variant=\"footnote\">{messagePendingLabel}</Text>\n </View>\n ) : isPersisted ? (\n <Text variant=\"footnote\">{timestamp}</Text>\n ) : null}\n {!pending && !error && wasEdited && (\n <Text variant=\"footnote\">\n |{' '}\n <Text variant=\"footnote\" style={styles.editedText}>\n Edited\n </Text>\n </Text>\n )}\n </View>\n )}\n </View>\n {message.mine && (\n <MyReplyConnector message={message} messageBubbleHeight={messageBubbleHeight} />\n )}\n </Animated.View>\n </Pressable>\n )\n}\n\nconst useMessageStyles = ({ mine }: MessageResource) => {\n const { colors } = useTheme()\n const myMessageBackgroundColor = useInteractionGhostBackgroundColor()\n const { width } = useWindowDimensions()\n const tabletWidth = width >= 744 // Smallest iPad Mini's width\n\n const messageBubbleBackgroundColor = mine ? myMessageBackgroundColor : colors.fillColorNeutral070\n\n return StyleSheet.create({\n message: {\n gap: 8,\n flexDirection: mine ? 'row-reverse' : 'row',\n paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,\n },\n messageContent: {\n flex: 1,\n gap: 4,\n },\n avatar: {\n marginBottom: 8,\n },\n avatarPlaceholder: {\n width: MESSAGE_AUTHOR_AVATAR_COLUMN_WIDTH, // Same width as avatar\n },\n messageBubble: {\n backgroundColor: messageBubbleBackgroundColor,\n borderRadius: 8,\n maxWidth: tabletWidth ? 360 : '80%',\n alignSelf: mine ? 'flex-end' : 'flex-start',\n },\n messageText: {\n paddingVertical: 6,\n paddingHorizontal: 8,\n },\n messageReactions: {\n flexDirection: 'row',\n gap: 4,\n justifyContent: mine ? 'flex-end' : 'flex-start',\n },\n messageReplyCount: {\n alignSelf: mine ? 'flex-end' : 'flex-start',\n },\n messageMeta: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: mine ? 'flex-end' : 'flex-start',\n gap: 4,\n },\n editedText: {\n fontWeight: platformFontWeightMedium,\n },\n pendingIndicatorContainer: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 4,\n },\n errorContainer: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 4,\n },\n errorIcon: {\n color: colors.statusErrorIcon,\n },\n errorText: {\n color: colors.statusErrorText,\n },\n })\n}\n"]}
|
|
@@ -3,9 +3,11 @@ import { ColorSchemeName } from 'react-native';
|
|
|
3
3
|
import { DeepPartial } from '../types';
|
|
4
4
|
import { ENV, OauthType, PartialToken, ResponseError, Session } from '../utils';
|
|
5
5
|
import { ChatTheme, DefaultTheme } from '../utils/theme';
|
|
6
|
+
import { AgeCheckContactInfo } from '../screens/age_check/screen_props';
|
|
6
7
|
export interface ChatProviderProps {
|
|
7
8
|
env?: ENV;
|
|
8
9
|
giphyApiKey?: string;
|
|
10
|
+
onAgeDisqualification?: (params: AgeCheckContactInfo) => void;
|
|
9
11
|
onUnauthorizedResponse: (_response: ResponseError) => void;
|
|
10
12
|
token?: PartialToken;
|
|
11
13
|
tokenType?: OauthType;
|
|
@@ -15,6 +17,7 @@ export interface ChatProviderProps {
|
|
|
15
17
|
export interface ChatContextValue extends Omit<ChatProviderProps, 'theme'> {
|
|
16
18
|
session: Session;
|
|
17
19
|
theme: ChatTheme;
|
|
20
|
+
onAgeDisqualification: (params: AgeCheckContactInfo) => void;
|
|
18
21
|
}
|
|
19
22
|
export declare const ChatContext: React.Context<ChatContextValue>;
|
|
20
23
|
export declare function ChatProvider({ children, value }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat_context.d.ts","sourceRoot":"","sources":["../../src/contexts/chat_context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiC,MAAM,OAAO,CAAA;AACrD,OAAO,EAAE,eAAe,EAAkB,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAE,SAAS,EAAgB,YAAY,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"chat_context.d.ts","sourceRoot":"","sources":["../../src/contexts/chat_context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiC,MAAM,OAAO,CAAA;AACrD,OAAO,EAAE,eAAe,EAAkB,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAE,SAAS,EAAgB,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAEvE,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,GAAG,CAAA;IACT,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qBAAqB,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAA;IAC7D,sBAAsB,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,IAAI,CAAA;IAC1D,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,KAAK,EAAE,oBAAoB,CAAA;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACxE,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,SAAS,CAAA;IAChB,qBAAqB,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAA;CAC7D;AAED,eAAO,MAAM,WAAW,iCAStB,CAAA;AAEF,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;IAAE,QAAQ,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,qBA4B5F;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAA;IACjC,WAAW,CAAC,EAAE,eAAe,CAAA;CAC9B;AAED,eAAO,MAAM,cAAc,wBAE1B,CAAA;AAED,eAAO,MAAM,kBAAkB,yDAG5B,oBAAoB,KAAG,SAYzB,CAAA"}
|
|
@@ -6,6 +6,7 @@ import { defaultTheme } from '../utils/theme';
|
|
|
6
6
|
export const ChatContext = createContext({
|
|
7
7
|
env: undefined,
|
|
8
8
|
giphyApiKey: undefined,
|
|
9
|
+
onAgeDisqualification: (_params) => { },
|
|
9
10
|
onUnauthorizedResponse: () => { },
|
|
10
11
|
session: new Session(),
|
|
11
12
|
theme: defaultTheme('light'),
|
|
@@ -13,13 +14,14 @@ export const ChatContext = createContext({
|
|
|
13
14
|
edgeToEdge: true,
|
|
14
15
|
});
|
|
15
16
|
export function ChatProvider({ children, value }) {
|
|
16
|
-
const { env, token, onUnauthorizedResponse, giphyApiKey, tokenType, edgeToEdge = true } = value;
|
|
17
|
+
const { env, token, onAgeDisqualification = (_params) => { }, onUnauthorizedResponse, giphyApiKey, tokenType, edgeToEdge = true, } = value;
|
|
17
18
|
const theme = useCreateChatTheme(value.theme || {});
|
|
18
19
|
const session = useMemo(() => new Session({ token, env, type: tokenType }), [env, token, tokenType]);
|
|
19
20
|
const contextValue = {
|
|
20
21
|
edgeToEdge,
|
|
21
22
|
env,
|
|
22
23
|
giphyApiKey,
|
|
24
|
+
onAgeDisqualification,
|
|
23
25
|
onUnauthorizedResponse,
|
|
24
26
|
session,
|
|
25
27
|
theme,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat_context.js","sourceRoot":"","sources":["../../src/contexts/chat_context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC9B,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,EAAmB,cAAc,EAAE,MAAM,cAAc,CAAA;AAE9D,OAAO,EAA+C,OAAO,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAa,YAAY,EAAgB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"chat_context.js","sourceRoot":"","sources":["../../src/contexts/chat_context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC9B,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,EAAmB,cAAc,EAAE,MAAM,cAAc,CAAA;AAE9D,OAAO,EAA+C,OAAO,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAa,YAAY,EAAgB,MAAM,gBAAgB,CAAA;AAoBtE,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAmB;IACzD,GAAG,EAAE,SAAS;IACd,WAAW,EAAE,SAAS;IACtB,qBAAqB,EAAE,CAAC,OAA4B,EAAE,EAAE,GAAE,CAAC;IAC3D,sBAAsB,EAAE,GAAG,EAAE,GAAE,CAAC;IAChC,OAAO,EAAE,IAAI,OAAO,EAAE;IACtB,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC;IAC5B,KAAK,EAAE,SAAS;IAChB,UAAU,EAAE,IAAI;CACjB,CAAC,CA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WAAW,CAAC;QACpD,MAAM,EAAE;YACN,GAAG,KAAK,CAAC,EAAE,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC;SACpE;KACF,CAAA;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { merge } from 'lodash'\nimport React, { createContext, useMemo } from 'react'\nimport { ColorSchemeName, useColorScheme } from 'react-native'\nimport { DeepPartial } from '../types'\nimport { ENV, OauthType, PartialToken, ResponseError, Session } from '../utils'\nimport { ChatTheme, defaultTheme, DefaultTheme } from '../utils/theme'\nimport { AgeCheckContactInfo } from '../screens/age_check/screen_props'\n\nexport interface ChatProviderProps {\n env?: ENV\n giphyApiKey?: string\n onAgeDisqualification?: (params: AgeCheckContactInfo) => void\n onUnauthorizedResponse: (_response: ResponseError) => void\n token?: PartialToken\n tokenType?: OauthType\n theme: CreateChatThemeProps\n edgeToEdge?: boolean\n}\n\nexport interface ChatContextValue extends Omit<ChatProviderProps, 'theme'> {\n session: Session\n theme: ChatTheme\n onAgeDisqualification: (params: AgeCheckContactInfo) => void\n}\n\nexport const ChatContext = createContext<ChatContextValue>({\n env: undefined,\n giphyApiKey: undefined,\n onAgeDisqualification: (_params: AgeCheckContactInfo) => {},\n onUnauthorizedResponse: () => {},\n session: new Session(),\n theme: defaultTheme('light'),\n token: undefined,\n edgeToEdge: true,\n})\n\nexport function ChatProvider({ children, value }: { children: any; value: ChatProviderProps }) {\n const {\n env,\n token,\n onAgeDisqualification = (_params: AgeCheckContactInfo) => {},\n onUnauthorizedResponse,\n giphyApiKey,\n tokenType,\n edgeToEdge = true,\n } = value\n const theme = useCreateChatTheme(value.theme || {})\n const session = useMemo(\n () => new Session({ token, env, type: tokenType }),\n [env, token, tokenType]\n )\n\n const contextValue: ChatContextValue = {\n edgeToEdge,\n env,\n giphyApiKey,\n onAgeDisqualification,\n onUnauthorizedResponse,\n session,\n theme,\n token,\n }\n\n return <ChatContext.Provider value={contextValue}>{children}</ChatContext.Provider>\n}\n\nexport interface CreateChatThemeProps {\n theme?: DeepPartial<DefaultTheme>\n colorScheme?: ColorSchemeName\n}\n\nexport const useChatContext = () => {\n return React.useContext(ChatContext)\n}\n\nexport const useCreateChatTheme = ({\n theme: customTheme = {},\n colorScheme: appColorScheme,\n}: CreateChatThemeProps): ChatTheme => {\n const internalColorScheme = useColorScheme() || 'light'\n const colorScheme = appColorScheme || internalColorScheme\n\n const theme = {\n ...merge({}, defaultTheme(colorScheme), customTheme),\n colors: {\n ...merge({}, defaultTheme(colorScheme).colors, customTheme?.colors),\n },\n }\n\n return theme\n}\n"]}
|
package/build/hooks/index.d.ts
CHANGED
|
@@ -14,5 +14,8 @@ export * from './use_api_client';
|
|
|
14
14
|
export * from './use_message_reaction_toggle';
|
|
15
15
|
export * from './use_interaction_ghost_color';
|
|
16
16
|
export * from './use_at_font_scale_breakpoint';
|
|
17
|
+
export * from './use_qualified_by_age';
|
|
17
18
|
export * from './use_scalable_number_of_lines';
|
|
19
|
+
export * from './use_submit_age_check';
|
|
20
|
+
export * from './use_organization';
|
|
18
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yCAAyC,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,gCAAgC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yCAAyC,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA"}
|
package/build/hooks/index.js
CHANGED
|
@@ -14,5 +14,8 @@ export * from './use_api_client';
|
|
|
14
14
|
export * from './use_message_reaction_toggle';
|
|
15
15
|
export * from './use_interaction_ghost_color';
|
|
16
16
|
export * from './use_at_font_scale_breakpoint';
|
|
17
|
+
export * from './use_qualified_by_age';
|
|
17
18
|
export * from './use_scalable_number_of_lines';
|
|
19
|
+
export * from './use_submit_age_check';
|
|
20
|
+
export * from './use_organization';
|
|
18
21
|
//# sourceMappingURL=index.js.map
|
package/build/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yCAAyC,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,gCAAgC,CAAA","sourcesContent":["export * from './use_async_storage'\nexport * from './use_animated_message_background_color'\nexport * from './use_theme'\nexport * from './use_suspense_api'\nexport * from './use_current_person'\nexport * from './use_font_scale'\nexport * from './use_create_android_ripple_color'\nexport * from './use_chat_permissions'\nexport * from './use_api_client'\nexport * from './use_groups_groups'\nexport * from './use_groups'\nexport * from './use_api'\nexport * from './use_api_client'\nexport * from './use_message_reaction_toggle'\nexport * from './use_interaction_ghost_color'\nexport * from './use_at_font_scale_breakpoint'\nexport * from './use_scalable_number_of_lines'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yCAAyC,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA","sourcesContent":["export * from './use_async_storage'\nexport * from './use_animated_message_background_color'\nexport * from './use_theme'\nexport * from './use_suspense_api'\nexport * from './use_current_person'\nexport * from './use_font_scale'\nexport * from './use_create_android_ripple_color'\nexport * from './use_chat_permissions'\nexport * from './use_api_client'\nexport * from './use_groups_groups'\nexport * from './use_groups'\nexport * from './use_api'\nexport * from './use_api_client'\nexport * from './use_message_reaction_toggle'\nexport * from './use_interaction_ghost_color'\nexport * from './use_at_font_scale_breakpoint'\nexport * from './use_qualified_by_age'\nexport * from './use_scalable_number_of_lines'\nexport * from './use_submit_age_check'\nexport * from './use_organization'\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_current_person.d.ts","sourceRoot":"","sources":["../../src/hooks/use_current_person.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAIhD,eAAO,MAAM,wBAAwB;;;;;;;
|
|
1
|
+
{"version":3,"file":"use_current_person.d.ts","sourceRoot":"","sources":["../../src/hooks/use_current_person.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAIhD,eAAO,MAAM,wBAAwB;;;;;;;CAepC,CAAA;AAED,eAAO,MAAM,qBAAqB,8CAA+C,CAAA;AAEjF,eAAO,MAAM,gBAAgB,6BAO5B,CAAA;AAED,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;AAE5D,eAAO,MAAM,qBAAqB;qBAGtB,OAAO,CAAC,qBAAqB,CAAC,kBACvB,aAAa,CAAC,qBAAqB,CAAC;;CActD,CAAA"}
|
|
@@ -4,7 +4,15 @@ export const currentPersonRequestArgs = {
|
|
|
4
4
|
url: '/me',
|
|
5
5
|
data: {
|
|
6
6
|
fields: {
|
|
7
|
-
Person: [
|
|
7
|
+
Person: [
|
|
8
|
+
'id',
|
|
9
|
+
'name',
|
|
10
|
+
'avatar',
|
|
11
|
+
'can_chat',
|
|
12
|
+
'unread_count',
|
|
13
|
+
'pco_chat_enabled',
|
|
14
|
+
'age_qualification_status',
|
|
15
|
+
],
|
|
8
16
|
},
|
|
9
17
|
},
|
|
10
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_current_person.js","sourceRoot":"","sources":["../../src/hooks/use_current_person.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGvE,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,GAAG,EAAE,KAAK;IACV,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"use_current_person.js","sourceRoot":"","sources":["../../src/hooks/use_current_person.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGvE,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,GAAG,EAAE,KAAK;IACV,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,IAAI;gBACJ,MAAM;gBACN,QAAQ;gBACR,UAAU;gBACV,cAAc;gBACd,kBAAkB;gBAClB,0BAA0B;aAC3B;SACF;KACF;CACF,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,wBAAwB,CAAC,CAAA;AAEjF,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,cAAc,CAAwB,wBAAwB,EAAE;QACvF,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,6CAA6C;QACvE,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,kEAAkE;KAC3F,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAID,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACxC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,YAAY,GAAG,CACnB,MAAsC,EACtC,gBAAsD,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,EAChF,EAAE;QACF,WAAW,CAAC,YAAY,CAAqC,qBAAqB,EAAE,IAAI,CAAC,EAAE;YACzF,IAAI,CAAC,IAAI;gBAAE,OAAO,IAAI,CAAA;YAEtB,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAA;QAC5D,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,MAAM,gBAAgB,GAAG,GAAG,EAAE;QAC5B,WAAW,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,qBAAqB,EAAE,CAAC,CAAA;IACpE,CAAC,CAAA;IAED,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAA;AAC/D,CAAC,CAAA","sourcesContent":["import { useQueryClient } from '@tanstack/react-query'\nimport { CurrentPersonResource } from '../types'\nimport { getRequestQueryKey, useSuspenseGet } from './use_suspense_api'\nimport { ApiResource } from '../types/api_primitives'\n\nexport const currentPersonRequestArgs = {\n url: '/me',\n data: {\n fields: {\n Person: [\n 'id',\n 'name',\n 'avatar',\n 'can_chat',\n 'unread_count',\n 'pco_chat_enabled',\n 'age_qualification_status',\n ],\n },\n },\n}\n\nexport const currentPersonQueryKey = getRequestQueryKey(currentPersonRequestArgs)\n\nexport const useCurrentPerson = () => {\n const { data: person } = useSuspenseGet<CurrentPersonResource>(currentPersonRequestArgs, {\n staleTime: 5 * 60 * 1000, // 5 minutes - data stays fresh for 5 minutes\n gcTime: 30 * 60 * 1000, // 30 minutes - data stays in cache for 30 minutes when not in use\n })\n\n return person\n}\n\ntype ProcessRecord<T> = (record: T, update: Partial<T>) => T\n\nexport const useCurrentPersonCache = () => {\n const queryClient = useQueryClient()\n const handleUpdate = (\n update: Partial<CurrentPersonResource>,\n processRecord: ProcessRecord<CurrentPersonResource> = (r, u) => ({ ...r, ...u })\n ) => {\n queryClient.setQueryData<ApiResource<CurrentPersonResource>>(currentPersonQueryKey, data => {\n if (!data) return data\n\n return { ...data, data: processRecord(data.data, update) }\n })\n }\n\n const handleInvalidate = () => {\n queryClient.invalidateQueries({ queryKey: currentPersonQueryKey })\n }\n\n return { update: handleUpdate, invalidate: handleInvalidate }\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { OrganizationResource } from '../types';
|
|
2
|
+
import { App } from './use_api_client';
|
|
3
|
+
export declare const organizationRequestArgs: {
|
|
4
|
+
url: string;
|
|
5
|
+
data: {
|
|
6
|
+
fields: {
|
|
7
|
+
Organization: string[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
app: App;
|
|
11
|
+
};
|
|
12
|
+
export declare function useOrganization(): {
|
|
13
|
+
error: import("../types").ApiError | null;
|
|
14
|
+
status: "success" | "error";
|
|
15
|
+
isError: boolean;
|
|
16
|
+
isPending: false;
|
|
17
|
+
isLoading: false;
|
|
18
|
+
isLoadingError: false;
|
|
19
|
+
isRefetchError: boolean;
|
|
20
|
+
isSuccess: boolean;
|
|
21
|
+
dataUpdatedAt: number;
|
|
22
|
+
errorUpdatedAt: number;
|
|
23
|
+
failureCount: number;
|
|
24
|
+
failureReason: import("../types").ApiError | null;
|
|
25
|
+
errorUpdateCount: number;
|
|
26
|
+
isFetched: boolean;
|
|
27
|
+
isFetchedAfterMount: boolean;
|
|
28
|
+
isFetching: boolean;
|
|
29
|
+
isInitialLoading: boolean;
|
|
30
|
+
isPaused: boolean;
|
|
31
|
+
isRefetching: boolean;
|
|
32
|
+
isStale: boolean;
|
|
33
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("../types").ApiResource<OrganizationResource>, import("../types").ApiError>>;
|
|
34
|
+
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
35
|
+
data: OrganizationResource;
|
|
36
|
+
links: Record<string, string>;
|
|
37
|
+
meta: Record<string, unknown>;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=use_organization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_organization.d.ts","sourceRoot":"","sources":["../../src/hooks/use_organization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAE/C,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAEtC,eAAO,MAAM,uBAAuB;;;;;;;SAOnB,GAAG;CACnB,CAAA;AAED,wBAAgB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;EAE9B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useSuspenseGet } from './use_suspense_api';
|
|
2
|
+
export const organizationRequestArgs = {
|
|
3
|
+
url: '/',
|
|
4
|
+
data: {
|
|
5
|
+
fields: {
|
|
6
|
+
Organization: ['contact_email'],
|
|
7
|
+
},
|
|
8
|
+
},
|
|
9
|
+
app: 'chat',
|
|
10
|
+
};
|
|
11
|
+
export function useOrganization() {
|
|
12
|
+
return useSuspenseGet(organizationRequestArgs);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=use_organization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_organization.js","sourceRoot":"","sources":["../../src/hooks/use_organization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGnD,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,GAAG,EAAE,GAAG;IACR,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,YAAY,EAAE,CAAC,eAAe,CAAC;SAChC;KACF;IACD,GAAG,EAAE,MAAa;CACnB,CAAA;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,cAAc,CAAuB,uBAAuB,CAAC,CAAA;AACtE,CAAC","sourcesContent":["import { OrganizationResource } from '../types'\nimport { useSuspenseGet } from './use_suspense_api'\nimport { App } from './use_api_client'\n\nexport const organizationRequestArgs = {\n url: '/',\n data: {\n fields: {\n Organization: ['contact_email'],\n },\n },\n app: 'chat' as App,\n}\n\nexport function useOrganization() {\n return useSuspenseGet<OrganizationResource>(organizationRequestArgs)\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_qualified_by_age.d.ts","sourceRoot":"","sources":["../../src/hooks/use_qualified_by_age.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,QAAO,OAYpC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AgeQualificationStatus } from '../types';
|
|
2
|
+
import { useApiGet } from './use_api';
|
|
3
|
+
import { currentPersonRequestArgs } from './use_current_person';
|
|
4
|
+
export const useQualifiedByAge = () => {
|
|
5
|
+
const { data: person, isFetched } = useApiGet(currentPersonRequestArgs);
|
|
6
|
+
if (!isFetched) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (!person) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return person.ageQualificationStatus === AgeQualificationStatus.QUALIFIED;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=use_qualified_by_age.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_qualified_by_age.js","sourceRoot":"","sources":["../../src/hooks/use_qualified_by_age.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAyB,MAAM,UAAU,CAAA;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAE/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAY,EAAE;IAC7C,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,CAAwB,wBAAwB,CAAC,CAAA;IAE9F,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,MAAM,CAAC,sBAAsB,KAAK,sBAAsB,CAAC,SAAS,CAAA;AAC3E,CAAC,CAAA","sourcesContent":["import { AgeQualificationStatus, CurrentPersonResource } from '../types'\nimport { useApiGet } from './use_api'\nimport { currentPersonRequestArgs } from './use_current_person'\n\nexport const useQualifiedByAge = (): boolean => {\n const { data: person, isFetched } = useApiGet<CurrentPersonResource>(currentPersonRequestArgs)\n\n if (!isFetched) {\n return false\n }\n\n if (!person) {\n return false\n }\n\n return person.ageQualificationStatus === AgeQualificationStatus.QUALIFIED\n}\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ApiResource } from '../types/api_primitives';
|
|
2
|
+
interface AgeCheckResource {
|
|
3
|
+
type: 'AgeCheck';
|
|
4
|
+
id: string;
|
|
5
|
+
stated_date: string;
|
|
6
|
+
status: 'passed' | 'failed';
|
|
7
|
+
}
|
|
8
|
+
export declare function useSubmitAgeCheck(): {
|
|
9
|
+
data: undefined;
|
|
10
|
+
variables: undefined;
|
|
11
|
+
error: null;
|
|
12
|
+
isError: false;
|
|
13
|
+
isIdle: true;
|
|
14
|
+
isPending: false;
|
|
15
|
+
isSuccess: false;
|
|
16
|
+
status: "idle";
|
|
17
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<ApiResource<AgeCheckResource>, Error, Date, unknown>;
|
|
18
|
+
reset: () => void;
|
|
19
|
+
context: unknown;
|
|
20
|
+
failureCount: number;
|
|
21
|
+
failureReason: Error | null;
|
|
22
|
+
isPaused: boolean;
|
|
23
|
+
submittedAt: number;
|
|
24
|
+
submitAgeCheck: import("@tanstack/react-query").UseMutateAsyncFunction<ApiResource<AgeCheckResource>, Error, Date, unknown>;
|
|
25
|
+
} | {
|
|
26
|
+
data: undefined;
|
|
27
|
+
variables: Date;
|
|
28
|
+
error: null;
|
|
29
|
+
isError: false;
|
|
30
|
+
isIdle: false;
|
|
31
|
+
isPending: true;
|
|
32
|
+
isSuccess: false;
|
|
33
|
+
status: "pending";
|
|
34
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<ApiResource<AgeCheckResource>, Error, Date, unknown>;
|
|
35
|
+
reset: () => void;
|
|
36
|
+
context: unknown;
|
|
37
|
+
failureCount: number;
|
|
38
|
+
failureReason: Error | null;
|
|
39
|
+
isPaused: boolean;
|
|
40
|
+
submittedAt: number;
|
|
41
|
+
submitAgeCheck: import("@tanstack/react-query").UseMutateAsyncFunction<ApiResource<AgeCheckResource>, Error, Date, unknown>;
|
|
42
|
+
} | {
|
|
43
|
+
data: undefined;
|
|
44
|
+
error: Error;
|
|
45
|
+
variables: Date;
|
|
46
|
+
isError: true;
|
|
47
|
+
isIdle: false;
|
|
48
|
+
isPending: false;
|
|
49
|
+
isSuccess: false;
|
|
50
|
+
status: "error";
|
|
51
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<ApiResource<AgeCheckResource>, Error, Date, unknown>;
|
|
52
|
+
reset: () => void;
|
|
53
|
+
context: unknown;
|
|
54
|
+
failureCount: number;
|
|
55
|
+
failureReason: Error | null;
|
|
56
|
+
isPaused: boolean;
|
|
57
|
+
submittedAt: number;
|
|
58
|
+
submitAgeCheck: import("@tanstack/react-query").UseMutateAsyncFunction<ApiResource<AgeCheckResource>, Error, Date, unknown>;
|
|
59
|
+
} | {
|
|
60
|
+
data: ApiResource<AgeCheckResource>;
|
|
61
|
+
error: null;
|
|
62
|
+
variables: Date;
|
|
63
|
+
isError: false;
|
|
64
|
+
isIdle: false;
|
|
65
|
+
isPending: false;
|
|
66
|
+
isSuccess: true;
|
|
67
|
+
status: "success";
|
|
68
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<ApiResource<AgeCheckResource>, Error, Date, unknown>;
|
|
69
|
+
reset: () => void;
|
|
70
|
+
context: unknown;
|
|
71
|
+
failureCount: number;
|
|
72
|
+
failureReason: Error | null;
|
|
73
|
+
isPaused: boolean;
|
|
74
|
+
submittedAt: number;
|
|
75
|
+
submitAgeCheck: import("@tanstack/react-query").UseMutateAsyncFunction<ApiResource<AgeCheckResource>, Error, Date, unknown>;
|
|
76
|
+
};
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=use_submit_age_check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_submit_age_check.d.ts","sourceRoot":"","sources":["../../src/hooks/use_submit_age_check.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAGrD,UAAU,gBAAgB;IACxB,IAAI,EAAE,UAAU,CAAA;IAChB,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAA;CAC5B;AAED,wBAAgB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiChC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Alert } from 'react-native';
|
|
2
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { useApiClient } from './use_api_client';
|
|
4
|
+
import { currentPersonQueryKey } from './use_current_person';
|
|
5
|
+
import { Haptic } from '../utils/native_adapters';
|
|
6
|
+
export function useSubmitAgeCheck() {
|
|
7
|
+
const apiClient = useApiClient();
|
|
8
|
+
const queryClient = useQueryClient();
|
|
9
|
+
const { mutateAsync: submitAgeCheck, ...mutation } = useMutation({
|
|
10
|
+
mutationKey: ['submitAgeCheck'],
|
|
11
|
+
mutationFn: (date) => apiClient.people.post({
|
|
12
|
+
url: '/me/age_checks',
|
|
13
|
+
data: {
|
|
14
|
+
fields: { AgeCheck: 'stated_date,status' },
|
|
15
|
+
data: {
|
|
16
|
+
type: 'AgeCheck',
|
|
17
|
+
attributes: {
|
|
18
|
+
stated_date: date.toISOString(),
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
onSuccess: (response) => {
|
|
24
|
+
queryClient.invalidateQueries({ queryKey: currentPersonQueryKey });
|
|
25
|
+
if (response.data.status === 'passed') {
|
|
26
|
+
Haptic.notificationSuccess();
|
|
27
|
+
Alert.alert('Profile updated', `Your birthdate has been updated.`);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
onError: () => {
|
|
31
|
+
Haptic.notificationError();
|
|
32
|
+
Alert.alert('Oops', `We were unable to update your birthdate. Please try again.`);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return { submitAgeCheck, ...mutation };
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=use_submit_age_check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_submit_age_check.js","sourceRoot":"","sources":["../../src/hooks/use_submit_age_check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AASjD,MAAM,UAAU,iBAAiB;IAC/B,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IAEpC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,QAAQ,EAAE,GAAG,WAAW,CAAC;QAC/D,WAAW,EAAE,CAAC,gBAAgB,CAAC;QAC/B,UAAU,EAAE,CAAC,IAAU,EAAE,EAAE,CACzB,SAAS,CAAC,MAAM,CAAC,IAAI,CAAgC;YACnD,GAAG,EAAE,gBAAgB;YACrB,IAAI,EAAE;gBACJ,MAAM,EAAE,EAAE,QAAQ,EAAE,oBAAoB,EAAE;gBAC1C,IAAI,EAAE;oBACJ,IAAI,EAAE,UAAU;oBAChB,UAAU,EAAE;wBACV,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;qBAChC;iBACF;aACF;SACF,CAAC;QACJ,SAAS,EAAE,CAAC,QAAuC,EAAE,EAAE;YACrD,WAAW,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,qBAAqB,EAAE,CAAC,CAAA;YAClE,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBACtC,MAAM,CAAC,mBAAmB,EAAE,CAAA;gBAC5B,KAAK,CAAC,KAAK,CAAC,iBAAiB,EAAE,kCAAkC,CAAC,CAAA;YACpE,CAAC;QACH,CAAC;QACD,OAAO,EAAE,GAAG,EAAE;YACZ,MAAM,CAAC,iBAAiB,EAAE,CAAA;YAC1B,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,4DAA4D,CAAC,CAAA;QACnF,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,EAAE,cAAc,EAAE,GAAG,QAAQ,EAAE,CAAA;AACxC,CAAC","sourcesContent":["import { Alert } from 'react-native'\nimport { useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useApiClient } from './use_api_client'\nimport { currentPersonQueryKey } from './use_current_person'\nimport { ApiResource } from '../types/api_primitives'\nimport { Haptic } from '../utils/native_adapters'\n\ninterface AgeCheckResource {\n type: 'AgeCheck'\n id: string\n stated_date: string\n status: 'passed' | 'failed'\n}\n\nexport function useSubmitAgeCheck() {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n\n const { mutateAsync: submitAgeCheck, ...mutation } = useMutation({\n mutationKey: ['submitAgeCheck'],\n mutationFn: (date: Date) =>\n apiClient.people.post<ApiResource<AgeCheckResource>>({\n url: '/me/age_checks',\n data: {\n fields: { AgeCheck: 'stated_date,status' },\n data: {\n type: 'AgeCheck',\n attributes: {\n stated_date: date.toISOString(),\n },\n },\n },\n }),\n onSuccess: (response: ApiResource<AgeCheckResource>) => {\n queryClient.invalidateQueries({ queryKey: currentPersonQueryKey })\n if (response.data.status === 'passed') {\n Haptic.notificationSuccess()\n Alert.alert('Profile updated', `Your birthdate has been updated.`)\n }\n },\n onError: () => {\n Haptic.notificationError()\n Alert.alert('Oops', `We were unable to update your birthdate. Please try again.`)\n },\n })\n\n return { submitAgeCheck, ...mutation }\n}\n"]}
|
package/build/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './contexts/chat_context';
|
|
|
4
4
|
export * from './navigation';
|
|
5
5
|
export { ScreenLayout } from './navigation/screenLayout';
|
|
6
6
|
export * from './screens';
|
|
7
|
+
export { AgeCheckUnderageScreen } from './screens/age_check/age_check_underage_screen';
|
|
7
8
|
export * from './types';
|
|
8
9
|
export { platformFontWeightBold, Session, TemporaryDefaultColorsType, Uri } from './utils';
|
|
9
10
|
export * from './utils/client';
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACvF,cAAc,yBAAyB,CAAA;AACvC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,0BAA0B,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAC1F,cAAc,gBAAgB,CAAA;AAC9B,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACvF,cAAc,yBAAyB,CAAA;AACvC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAA;AACtF,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,0BAA0B,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAC1F,cAAc,gBAAgB,CAAA;AAC9B,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from './contexts/chat_context';
|
|
|
4
4
|
export * from './navigation';
|
|
5
5
|
export { ScreenLayout } from './navigation/screenLayout';
|
|
6
6
|
export * from './screens';
|
|
7
|
+
export { AgeCheckUnderageScreen } from './screens/age_check/age_check_underage_screen'; // TODO: add to barrel
|
|
7
8
|
export * from './types';
|
|
8
9
|
export { platformFontWeightBold, Session, Uri } from './utils';
|
|
9
10
|
export * from './utils/client';
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACvF,cAAc,yBAAyB,CAAA;AACvC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAA8B,GAAG,EAAE,MAAM,SAAS,CAAA;AAC1F,cAAc,gBAAgB,CAAA;AAC9B,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA","sourcesContent":["export { GroupConversations } from './components'\nexport { ApiProvider, chatQueryClient, useFocusManager } from './contexts/api_provider'\nexport * from './contexts/chat_context'\nexport * from './navigation'\nexport { ScreenLayout } from './navigation/screenLayout'\nexport * from './screens'\nexport * from './types'\nexport { platformFontWeightBold, Session, TemporaryDefaultColorsType, Uri } from './utils'\nexport * from './utils/client'\nexport * from './utils/native_adapters'\nexport { default as Event } from './polyfills/events/Event'\nexport { CustomEvent } from './polyfills/events/CustomEvent'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACvF,cAAc,yBAAyB,CAAA;AACvC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAA,CAAC,sBAAsB;AAC7G,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAA8B,GAAG,EAAE,MAAM,SAAS,CAAA;AAC1F,cAAc,gBAAgB,CAAA;AAC9B,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA","sourcesContent":["export { GroupConversations } from './components'\nexport { ApiProvider, chatQueryClient, useFocusManager } from './contexts/api_provider'\nexport * from './contexts/chat_context'\nexport * from './navigation'\nexport { ScreenLayout } from './navigation/screenLayout'\nexport * from './screens'\nexport { AgeCheckUnderageScreen } from './screens/age_check/age_check_underage_screen' // TODO: add to barrel\nexport * from './types'\nexport { platformFontWeightBold, Session, TemporaryDefaultColorsType, Uri } from './utils'\nexport * from './utils/client'\nexport * from './utils/native_adapters'\nexport { default as Event } from './polyfills/events/Event'\nexport { CustomEvent } from './polyfills/events/CustomEvent'\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat_access_gate.d.ts","sourceRoot":"","sources":["../../src/navigation/chat_access_gate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAqB,MAAM,OAAO,CAAA;AASnE,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,qBA0B7D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { currentPersonRequestArgs } from '../hooks/use_current_person';
|
|
3
|
+
import { AgeCheckRequiredScreen } from '../screens/age_check/age_check_required_screen';
|
|
4
|
+
import { DefaultLoading } from '../components/page/loading';
|
|
5
|
+
import { useApiGet, useOrganization } from '../hooks';
|
|
6
|
+
import { AgeQualificationStatus } from '../types';
|
|
7
|
+
import { useChatContext } from '../contexts/chat_context';
|
|
8
|
+
import { AgeCheckUnderageScreen } from '../screens/age_check/age_check_underage_screen';
|
|
9
|
+
export function ChatAccessGate({ children }) {
|
|
10
|
+
const { data: person, isFetched } = useApiGet(currentPersonRequestArgs);
|
|
11
|
+
const { data: organization } = useOrganization();
|
|
12
|
+
const ageQualificationStatus = person?.ageQualificationStatus;
|
|
13
|
+
const contactEmail = organization?.contactEmail;
|
|
14
|
+
useAgeDisqualification(ageQualificationStatus, contactEmail);
|
|
15
|
+
if (!isFetched) {
|
|
16
|
+
return <DefaultLoading />;
|
|
17
|
+
}
|
|
18
|
+
if (!person) {
|
|
19
|
+
throw new Error('Current person not found');
|
|
20
|
+
}
|
|
21
|
+
if (ageQualificationStatus === AgeQualificationStatus.DISQUALIFIED) {
|
|
22
|
+
return <AgeCheckUnderageScreen contactEmail={contactEmail}/>;
|
|
23
|
+
}
|
|
24
|
+
if (ageQualificationStatus === AgeQualificationStatus.UNKNOWN) {
|
|
25
|
+
return <AgeCheckRequiredScreen />;
|
|
26
|
+
}
|
|
27
|
+
return <>{children}</>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Helper hook that handles the age disqualification logic.
|
|
31
|
+
*
|
|
32
|
+
* If a host app provides an onAgeDisqualification callback, it will be called
|
|
33
|
+
* when a user is found to be disqualified by their age.
|
|
34
|
+
*/
|
|
35
|
+
function useAgeDisqualification(ageQualificationStatus, contactEmail) {
|
|
36
|
+
const { onAgeDisqualification } = useChatContext();
|
|
37
|
+
const hasCalledCallbackRef = useRef(false);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (ageQualificationStatus === AgeQualificationStatus.DISQUALIFIED &&
|
|
40
|
+
!hasCalledCallbackRef.current) {
|
|
41
|
+
hasCalledCallbackRef.current = true;
|
|
42
|
+
onAgeDisqualification({ contactEmail: contactEmail || '' });
|
|
43
|
+
}
|
|
44
|
+
}, [ageQualificationStatus, onAgeDisqualification, contactEmail]);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=chat_access_gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat_access_gate.js","sourceRoot":"","sources":["../../src/navigation/chat_access_gate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAqB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAA;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAyB,MAAM,UAAU,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAA;AAEvF,MAAM,UAAU,cAAc,CAAC,EAAE,QAAQ,EAAqB;IAC5D,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,CAAwB,wBAAwB,CAAC,CAAA;IAC9F,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,eAAe,EAAE,CAAA;IAEhD,MAAM,sBAAsB,GAAG,MAAM,EAAE,sBAAsB,CAAA;IAC7D,MAAM,YAAY,GAAG,YAAY,EAAE,YAAY,CAAA;IAE/C,sBAAsB,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAA;IAE5D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,cAAc,CAAC,AAAD,EAAG,CAAA;IAC3B,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;IAC7C,CAAC;IAED,IAAI,sBAAsB,KAAK,sBAAsB,CAAC,YAAY,EAAE,CAAC;QACnE,OAAO,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,EAAG,CAAA;IAC/D,CAAC;IAED,IAAI,sBAAsB,KAAK,sBAAsB,CAAC,OAAO,EAAE,CAAC;QAC9D,OAAO,CAAC,sBAAsB,CAAC,AAAD,EAAG,CAAA;IACnC,CAAC;IAED,OAAO,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAA;AACxB,CAAC;AAED;;;;;GAKG;AACH,SAAS,sBAAsB,CAC7B,sBAAuE,EACvE,YAAgC;IAEhC,MAAM,EAAE,qBAAqB,EAAE,GAAG,cAAc,EAAE,CAAA;IAClD,MAAM,oBAAoB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAE1C,SAAS,CAAC,GAAG,EAAE;QACb,IACE,sBAAsB,KAAK,sBAAsB,CAAC,YAAY;YAC9D,CAAC,oBAAoB,CAAC,OAAO,EAC7B,CAAC;YACD,oBAAoB,CAAC,OAAO,GAAG,IAAI,CAAA;YACnC,qBAAqB,CAAC,EAAE,YAAY,EAAE,YAAY,IAAI,EAAE,EAAE,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC,EAAE,CAAC,sBAAsB,EAAE,qBAAqB,EAAE,YAAY,CAAC,CAAC,CAAA;AACnE,CAAC","sourcesContent":["import React, { PropsWithChildren, useEffect, useRef } from 'react'\nimport { currentPersonRequestArgs } from '../hooks/use_current_person'\nimport { AgeCheckRequiredScreen } from '../screens/age_check/age_check_required_screen'\nimport { DefaultLoading } from '../components/page/loading'\nimport { useApiGet, useOrganization } from '../hooks'\nimport { AgeQualificationStatus, CurrentPersonResource } from '../types'\nimport { useChatContext } from '../contexts/chat_context'\nimport { AgeCheckUnderageScreen } from '../screens/age_check/age_check_underage_screen'\n\nexport function ChatAccessGate({ children }: PropsWithChildren) {\n const { data: person, isFetched } = useApiGet<CurrentPersonResource>(currentPersonRequestArgs)\n const { data: organization } = useOrganization()\n\n const ageQualificationStatus = person?.ageQualificationStatus\n const contactEmail = organization?.contactEmail\n\n useAgeDisqualification(ageQualificationStatus, contactEmail)\n\n if (!isFetched) {\n return <DefaultLoading />\n }\n\n if (!person) {\n throw new Error('Current person not found')\n }\n\n if (ageQualificationStatus === AgeQualificationStatus.DISQUALIFIED) {\n return <AgeCheckUnderageScreen contactEmail={contactEmail} />\n }\n\n if (ageQualificationStatus === AgeQualificationStatus.UNKNOWN) {\n return <AgeCheckRequiredScreen />\n }\n\n return <>{children}</>\n}\n\n/**\n * Helper hook that handles the age disqualification logic.\n *\n * If a host app provides an onAgeDisqualification callback, it will be called\n * when a user is found to be disqualified by their age.\n */\nfunction useAgeDisqualification(\n ageQualificationStatus: CurrentPersonResource['ageQualificationStatus'],\n contactEmail: string | undefined\n) {\n const { onAgeDisqualification } = useChatContext()\n const hasCalledCallbackRef = useRef(false)\n\n useEffect(() => {\n if (\n ageQualificationStatus === AgeQualificationStatus.DISQUALIFIED &&\n !hasCalledCallbackRef.current\n ) {\n hasCalledCallbackRef.current = true\n onAgeDisqualification({ contactEmail: contactEmail || '' })\n }\n }, [ageQualificationStatus, onAgeDisqualification, contactEmail])\n}\n"]}
|