@planningcenter/chat-react-native 3.17.0-rc.0 → 3.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/conversation/message.d.ts.map +1 -1
- package/build/components/conversation/message.js +27 -7
- package/build/components/conversation/message.js.map +1 -1
- package/build/components/conversation/message_form.d.ts +3 -2
- package/build/components/conversation/message_form.d.ts.map +1 -1
- package/build/components/conversation/message_form.js +6 -4
- package/build/components/conversation/message_form.js.map +1 -1
- package/build/components/conversation/reply_connectors.d.ts +1 -0
- package/build/components/conversation/reply_connectors.d.ts.map +1 -1
- package/build/components/conversation/reply_connectors.js +33 -14
- package/build/components/conversation/reply_connectors.js.map +1 -1
- package/build/components/conversation/reply_shadow_message.d.ts +12 -0
- package/build/components/conversation/reply_shadow_message.d.ts.map +1 -0
- package/build/components/conversation/{shadow_message.js → reply_shadow_message.js} +36 -6
- package/build/components/conversation/reply_shadow_message.js.map +1 -0
- package/build/hooks/use_conversation_message.d.ts +12 -0
- package/build/hooks/use_conversation_message.d.ts.map +1 -0
- package/build/hooks/use_conversation_message.js +11 -0
- package/build/hooks/use_conversation_message.js.map +1 -0
- package/build/hooks/use_conversation_messages.d.ts +1 -20
- package/build/hooks/use_conversation_messages.d.ts.map +1 -1
- package/build/hooks/use_conversation_messages.js +2 -33
- package/build/hooks/use_conversation_messages.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_message_create_or_update.d.ts +1 -1
- package/build/hooks/use_message_create_or_update.d.ts.map +1 -1
- package/build/hooks/use_message_create_or_update.js +1 -1
- package/build/hooks/use_message_create_or_update.js.map +1 -1
- package/build/hooks/use_message_reaction_toggle.js +1 -1
- package/build/hooks/use_message_reaction_toggle.js.map +1 -1
- package/build/navigation/index.d.ts +6 -2
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +3 -3
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_screen.d.ts +11 -3
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +46 -10
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/message_actions_screen.d.ts +1 -0
- package/build/screens/message_actions_screen.d.ts.map +1 -1
- package/build/screens/message_actions_screen.js +5 -5
- package/build/screens/message_actions_screen.js.map +1 -1
- package/build/types/resources/message.d.ts +3 -0
- package/build/types/resources/message.d.ts.map +1 -1
- package/build/types/resources/message.js.map +1 -1
- package/build/utils/cache/optimistically_create_message.js +1 -1
- package/build/utils/cache/optimistically_create_message.js.map +1 -1
- package/build/utils/cache/optimistically_update_message.js +1 -1
- package/build/utils/cache/optimistically_update_message.js.map +1 -1
- package/build/utils/pluralize.js +1 -1
- package/build/utils/pluralize.js.map +1 -1
- package/build/utils/request/get_message.d.ts +20 -0
- package/build/utils/request/get_message.d.ts.map +1 -0
- package/build/utils/request/get_message.js +18 -0
- package/build/utils/request/get_message.js.map +1 -0
- package/build/utils/request/get_messages.d.ts +20 -0
- package/build/utils/request/get_messages.d.ts.map +1 -0
- package/build/utils/request/get_messages.js +20 -0
- package/build/utils/request/get_messages.js.map +1 -0
- package/build/utils/request/messages_data_options.d.ts +7 -0
- package/build/utils/request/messages_data_options.d.ts.map +1 -0
- package/build/utils/request/messages_data_options.js +18 -0
- package/build/utils/request/messages_data_options.js.map +1 -0
- package/package.json +2 -2
- package/src/__tests__/utils/pluralize.tsx +3 -0
- package/src/components/conversation/message.tsx +31 -7
- package/src/components/conversation/message_form.tsx +10 -4
- package/src/components/conversation/reply_connectors.tsx +42 -20
- package/src/components/conversation/{shadow_message.tsx → reply_shadow_message.tsx} +55 -6
- package/src/hooks/use_conversation_message.ts +25 -0
- package/src/hooks/use_conversation_messages.ts +3 -53
- package/src/hooks/use_conversation_messages_jolt_events.ts +1 -1
- package/src/hooks/use_message_create_or_update.ts +2 -2
- package/src/hooks/use_message_reaction_toggle.ts +1 -1
- package/src/navigation/index.tsx +3 -3
- package/src/screens/conversation_screen.tsx +68 -12
- package/src/screens/message_actions_screen.tsx +13 -3
- package/src/types/resources/message.ts +3 -0
- package/src/utils/cache/optimistically_create_message.ts +1 -1
- package/src/utils/cache/optimistically_update_message.ts +1 -1
- package/src/utils/pluralize.ts +1 -1
- package/src/utils/request/get_message.ts +32 -0
- package/src/utils/request/get_messages.ts +34 -0
- package/src/utils/request/messages_data_options.ts +18 -0
- package/build/components/conversation/shadow_message.d.ts +0 -8
- package/build/components/conversation/shadow_message.d.ts.map +0 -1
- package/build/components/conversation/shadow_message.js.map +0 -1
- package/build/utils/request/messages.d.ts +0 -15
- package/build/utils/request/messages.d.ts.map +0 -1
- package/build/utils/request/messages.js +0 -22
- package/build/utils/request/messages.js.map +0 -1
- package/src/utils/request/messages.ts +0 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_actions_screen.js","sourceRoot":"","sources":["../../src/screens/message_actions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAqB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAA;AAChG,OAAO,SAAS,EAAE,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAA;AACzF,OAAO,EAAE,2BAA2B,EAAE,YAAY,EAAE,QAAQ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,QAAQ;SACnB;QACD,aAAa,EAAE;YACb,QAAQ,EAAE,EAAE;SACb;QACD,OAAO,EAAE;YACP,UAAU,EAAE,CAAC;SACd;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements'\nimport { StackActions, StaticScreenProps, useNavigation } from '@react-navigation/native'\nimport { useMutation } from '@tanstack/react-query'\nimport { isNil, omitBy } from 'lodash'\nimport React, { useCallback } from 'react'\nimport { Alert, Platform, StyleSheet, View } from 'react-native'\nimport { Text } from '../components'\nimport { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction'\nimport FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'\nimport { useCreateAndroidRippleColor, useFontScale, useTheme } from '../hooks'\nimport { useApiClient } from '../hooks/use_api_client'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useMessageReactionToggle } from '../hooks/use_message_reaction_toggle'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport { Clipboard, Haptic } from '../utils/native_adapters'\nimport { MessageResource } from '../types'\nimport { REPLIES_FEATURE_ENABLED } from '../utils'\n\nexport const MessageActionsScreenOptions = getFormSheetScreenOptions({\n sheetAllowedDetents: [0.5],\n headerTitle: 'Message actions',\n})\n\nexport type MessageActionsScreenProps = StaticScreenProps<{\n message_id: string\n conversation_id: number\n canDeleteNonAuthoredMessages?: boolean\n inReplyScreen?: boolean\n}>\n\nexport function MessageActionsScreen({ route }: MessageActionsScreenProps) {\n const { conversation_id, message_id, canDeleteNonAuthoredMessages, inReplyScreen } = route.params\n\n const { messages, refetch } = useConversationMessages(\n { conversation_id },\n { refetchOnMount: false }\n )\n const message = messages.find(m => m.id === message_id)\n\n if (!message) return null\n\n return (\n <MessageActionsScreenContent\n message={message}\n conversation_id={conversation_id}\n canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages || false}\n refetchMessages={refetch}\n inReplyScreen={inReplyScreen}\n />\n )\n}\n\nfunction MessageActionsScreenContent({\n message,\n conversation_id,\n canDeleteNonAuthoredMessages,\n refetchMessages,\n inReplyScreen,\n}: {\n message: MessageResource\n conversation_id: number\n canDeleteNonAuthoredMessages: boolean\n refetchMessages: () => void\n inReplyScreen?: boolean\n}) {\n const navigation = useNavigation()\n const apiClient = useApiClient()\n const styles = useStyles()\n\n const myReactions = message?.reactionCounts\n .filter(reaction => reaction.mine)\n .map(reaction => reaction.value)\n\n const availableReactions = Object.entries(REACTION_EMOJIS).map(([value, emoji]) => {\n return {\n value: value as ReactionCountResource['value'],\n emoji,\n mine: myReactions?.includes(value as ReactionCountResource['value']),\n }\n })\n\n const attachmentForCopy = (): string => {\n const giphyTitleLink = message?.attachments.find(\n attachment => attachment.type === 'giphy'\n )?.titleLink\n\n if (giphyTitleLink) return giphyTitleLink\n return ''\n }\n\n const handleReplyPress = useCallback(() => {\n navigation.goBack()\n // Waits for the modal to be dismissed before pushing the reply screen\n requestAnimationFrame(() => {\n navigation.navigate('ConversationReply', {\n conversation_id,\n reply_root_id: message.replyRootId || message.id,\n // TODO: Update title param with reply root author\n })\n })\n }, [navigation, conversation_id, message.id, message.replyRootId])\n\n const handleCopyPress = () => {\n Clipboard.setStringAsync(message?.text || attachmentForCopy() || '')\n navigation.goBack()\n }\n\n const { handleReactionToggle, isPending } = useMessageReactionToggle({\n conversation_id,\n message,\n onSuccess: () => navigation.goBack(),\n })\n\n const deleteMessage = useCallback(() => {\n const url = `/me/conversations/${conversation_id}/messages/${message.id}/`\n\n return apiClient.chat.delete({ url })\n }, [apiClient, conversation_id, message.id])\n\n const { mutate: handleDeleteMessage } = useMutation({\n mutationFn: deleteMessage,\n onSuccess: () => {\n refetchMessages()\n Haptic.notificationSuccess()\n navigation.goBack()\n },\n onError: () => {\n Alert.alert('Oops', 'We were unable to delete this message. Please try again.')\n },\n })\n\n const handleDeleteConfirm = useCallback(() => {\n Alert.alert('Delete message', 'Are you sure you want to permanently delete this message?', [\n { text: 'Cancel', style: 'cancel' },\n { text: 'Delete', style: 'destructive', onPress: () => handleDeleteMessage() },\n ])\n }, [handleDeleteMessage])\n\n const handleEditPress = useCallback(() => {\n const state = navigation.getState?.()\n const targetRoute = state?.routes?.find(r => r.name === 'Conversation')\n const params = omitBy(\n {\n ...(targetRoute?.params || {}),\n conversation_id,\n editing_message_id: message.id,\n },\n isNil\n )\n navigation.dispatch(StackActions.popTo('Conversation', params))\n }, [navigation, conversation_id, message.id])\n\n const handleViewReadReceiptsPress = useCallback(() => {\n Haptic.impactLight()\n const params = omitBy(\n {\n conversation_id,\n message_id: message.id,\n },\n isNil\n )\n navigation.dispatch(StackActions.popTo('MessageReadReceipts', params))\n }, [navigation, conversation_id, message.id])\n\n return (\n <FormSheet.Root style={styles.formSheetContent}>\n <View style={styles.reactionList}>\n {availableReactions.map((reaction, index) => (\n <Reaction\n key={index}\n reaction={reaction}\n onPress={() => {\n Haptic.impactLight()\n handleReactionToggle({\n value: reaction.value,\n mine: reaction.mine,\n })\n }}\n />\n ))}\n </View>\n <View style={styles.actions}>\n {REPLIES_FEATURE_ENABLED && !inReplyScreen && (\n <FormSheet.Action\n onPress={handleReplyPress}\n title=\"Reply to message\"\n iconName=\"registrations.undo\"\n accessibilityHint=\"Navigates to the reply screen\"\n accessibilityRole=\"link\"\n />\n )}\n <FormSheet.Action\n onPress={handleCopyPress}\n title=\"Copy text\"\n iconName=\"services.fileCopy\"\n accessibilityHint=\"Copies text and links to clipboard\"\n />\n {message?.mine && (\n <FormSheet.Action\n onPress={() => handleEditPress()}\n title=\"Edit message\"\n iconName=\"accounts.editor\"\n accessibilityHint=\"Opens existing text in the message form input.\"\n />\n )}\n {message?.mine && (\n <FormSheet.Action\n onPress={() => handleViewReadReceiptsPress()}\n title=\"View read receipts\"\n iconName=\"general.checkPerson\"\n accessibilityHint=\"Opens a modal with a list of people who read your message.\"\n />\n )}\n {(message?.mine || canDeleteNonAuthoredMessages) && (\n <FormSheet.Action\n onPress={() => handleDeleteConfirm()}\n title=\"Delete message\"\n iconName=\"publishing.trash\"\n appearance=\"danger\"\n disabled={isPending}\n accessibilityHint=\"Opens a confirmation alert to delete this message permanently.\"\n />\n )}\n </View>\n </FormSheet.Root>\n )\n}\n\nconst Reaction = ({\n reaction,\n onPress,\n}: {\n reaction: { value: ReactionCountResource['value']; emoji: string; mine: boolean | undefined }\n onPress: () => void\n}) => {\n const styles = useStyles()\n const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 })\n\n const { colors } = useTheme()\n const baseRippleColor = reaction.mine ? colors.interaction : colors.fillColorNeutral060\n const androidRippleColor = useCreateAndroidRippleColor({ color: baseRippleColor })\n\n return (\n <PlatformPressable\n key={reaction.value}\n style={[reactionStyles.reaction, styles.reaction]}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n onPress={onPress}\n >\n <Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>\n </PlatformPressable>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 })\n\n const btnBorderWidth = 1\n const baseSize = 46 * fontScale\n const reactionBtnSize = Platform.select({\n ios: baseSize,\n android: baseSize + btnBorderWidth * 2,\n })\n\n return StyleSheet.create({\n formSheetContent: {\n paddingTop: 16,\n },\n reactionList: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n gap: 16,\n paddingTop: 8,\n paddingBottom: 16,\n borderBottomColor: colors.borderColorDefaultBase,\n borderBottomWidth: 1,\n },\n reaction: {\n height: reactionBtnSize,\n width: reactionBtnSize,\n borderWidth: btnBorderWidth,\n borderRadius: 32,\n justifyContent: 'center',\n overflow: 'hidden',\n },\n reactionEmoji: {\n fontSize: 24,\n },\n actions: {\n paddingTop: 4,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"message_actions_screen.js","sourceRoot":"","sources":["../../src/screens/message_actions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4B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B,MAAM,QAAQ,GAAG,EAAE,GAAG,SAAS,CAAA;IAC/B,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC;QACtC,GAAG,EAAE,QAAQ;QACb,OAAO,EAAE,QAAQ,GAAG,cAAc,GAAG,CAAC;KACvC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE;YAChB,UAAU,EAAE,EAAE;SACf;QACD,YAAY,EAAE;YACZ,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,EAAE;YACP,UAAU,EAAE,CAAC;YACb,aAAa,EAAE,EAAE;YACjB,iBAAiB,EAAE,MAAM,CAAC,sBAAsB;YAChD,iBAAiB,EAAE,CAAC;SACrB;QACD,QAAQ,EAAE;YACR,MAAM,EAAE,eAAe;YACvB,KAAK,EAAE,eAAe;YACtB,WAAW,EAAE,cAAc;YAC3B,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,QAAQ;YACxB,QAAQ,EAAE,QAAQ;SACnB;QACD,aAAa,EAAE;YACb,QAAQ,EAAE,EAAE;SACb;QACD,OAAO,EAAE;YACP,UAAU,EAAE,CAAC;SACd;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements'\nimport { StackActions, StaticScreenProps, useNavigation } from '@react-navigation/native'\nimport { useMutation } from '@tanstack/react-query'\nimport { isNil, omitBy } from 'lodash'\nimport React, { useCallback } from 'react'\nimport { Alert, Platform, StyleSheet, View } from 'react-native'\nimport { Text } from '../components'\nimport { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction'\nimport FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'\nimport { useCreateAndroidRippleColor, useFontScale, useTheme } from '../hooks'\nimport { useApiClient } from '../hooks/use_api_client'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useMessageReactionToggle } from '../hooks/use_message_reaction_toggle'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport { Clipboard, Haptic } from '../utils/native_adapters'\nimport { MessageResource } from '../types'\nimport { REPLIES_FEATURE_ENABLED } from '../utils'\n\nexport const MessageActionsScreenOptions = getFormSheetScreenOptions({\n sheetAllowedDetents: [0.5],\n headerTitle: 'Message actions',\n})\n\nexport type MessageActionsScreenProps = StaticScreenProps<{\n message_id: string\n reply_root_author_name?: string\n conversation_id: number\n canDeleteNonAuthoredMessages?: boolean\n inReplyScreen?: boolean\n}>\n\nexport function MessageActionsScreen({ route }: MessageActionsScreenProps) {\n const {\n conversation_id,\n message_id,\n canDeleteNonAuthoredMessages,\n inReplyScreen,\n reply_root_author_name,\n } = route.params\n\n const { messages, refetch } = useConversationMessages(\n { conversation_id },\n { refetchOnMount: false }\n )\n const message = messages.find(m => m.id === message_id)\n\n if (!message) return null\n\n return (\n <MessageActionsScreenContent\n message={message}\n conversation_id={conversation_id}\n canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages || false}\n refetchMessages={refetch}\n inReplyScreen={inReplyScreen}\n replyRootAuthorName={reply_root_author_name}\n />\n )\n}\n\nfunction MessageActionsScreenContent({\n message,\n conversation_id,\n canDeleteNonAuthoredMessages,\n refetchMessages,\n inReplyScreen,\n replyRootAuthorName,\n}: {\n message: MessageResource\n conversation_id: number\n canDeleteNonAuthoredMessages: boolean\n refetchMessages: () => void\n inReplyScreen?: boolean\n replyRootAuthorName?: string\n}) {\n const navigation = useNavigation()\n const apiClient = useApiClient()\n const styles = useStyles()\n\n const myReactions = message?.reactionCounts\n .filter(reaction => reaction.mine)\n .map(reaction => reaction.value)\n\n const availableReactions = Object.entries(REACTION_EMOJIS).map(([value, emoji]) => {\n return {\n value: value as ReactionCountResource['value'],\n emoji,\n mine: myReactions?.includes(value as ReactionCountResource['value']),\n }\n })\n\n const attachmentForCopy = (): string => {\n const giphyTitleLink = message?.attachments.find(\n attachment => attachment.type === 'giphy'\n )?.titleLink\n\n if (giphyTitleLink) return giphyTitleLink\n return ''\n }\n\n const handleReplyPress = useCallback(() => {\n navigation.goBack()\n // Waits for the modal to be dismissed before pushing the reply screen\n requestAnimationFrame(() => {\n navigation.navigate('ConversationReply', {\n conversation_id,\n reply_root_id: message.replyRootId || message.id,\n reply_root_author_name: replyRootAuthorName,\n })\n })\n }, [navigation, conversation_id, message.id, message.replyRootId, replyRootAuthorName])\n\n const handleCopyPress = () => {\n Clipboard.setStringAsync(message?.text || attachmentForCopy() || '')\n navigation.goBack()\n }\n\n const { handleReactionToggle, isPending } = useMessageReactionToggle({\n conversation_id,\n message,\n onSuccess: () => navigation.goBack(),\n })\n\n const deleteMessage = useCallback(() => {\n const url = `/me/conversations/${conversation_id}/messages/${message.id}/`\n\n return apiClient.chat.delete({ url })\n }, [apiClient, conversation_id, message.id])\n\n const { mutate: handleDeleteMessage } = useMutation({\n mutationFn: deleteMessage,\n onSuccess: () => {\n refetchMessages()\n Haptic.notificationSuccess()\n navigation.goBack()\n },\n onError: () => {\n Alert.alert('Oops', 'We were unable to delete this message. Please try again.')\n },\n })\n\n const handleDeleteConfirm = useCallback(() => {\n Alert.alert('Delete message', 'Are you sure you want to permanently delete this message?', [\n { text: 'Cancel', style: 'cancel' },\n { text: 'Delete', style: 'destructive', onPress: () => handleDeleteMessage() },\n ])\n }, [handleDeleteMessage])\n\n const handleEditPress = useCallback(() => {\n const state = navigation.getState?.()\n const targetRoute = state?.routes?.find(r => r.name === 'Conversation')\n const params = omitBy(\n {\n ...(targetRoute?.params || {}),\n conversation_id,\n editing_message_id: message.id,\n },\n isNil\n )\n navigation.dispatch(StackActions.popTo('Conversation', params))\n }, [navigation, conversation_id, message.id])\n\n const handleViewReadReceiptsPress = useCallback(() => {\n Haptic.impactLight()\n const params = omitBy(\n {\n conversation_id,\n message_id: message.id,\n },\n isNil\n )\n navigation.dispatch(StackActions.popTo('MessageReadReceipts', params))\n }, [navigation, conversation_id, message.id])\n\n return (\n <FormSheet.Root style={styles.formSheetContent}>\n <View style={styles.reactionList}>\n {availableReactions.map((reaction, index) => (\n <Reaction\n key={index}\n reaction={reaction}\n onPress={() => {\n Haptic.impactLight()\n handleReactionToggle({\n value: reaction.value,\n mine: reaction.mine,\n })\n }}\n />\n ))}\n </View>\n <View style={styles.actions}>\n {REPLIES_FEATURE_ENABLED && !inReplyScreen && (\n <FormSheet.Action\n onPress={handleReplyPress}\n title=\"Reply to message\"\n iconName=\"registrations.undo\"\n accessibilityHint=\"Navigates to the reply screen\"\n accessibilityRole=\"link\"\n />\n )}\n <FormSheet.Action\n onPress={handleCopyPress}\n title=\"Copy text\"\n iconName=\"services.fileCopy\"\n accessibilityHint=\"Copies text and links to clipboard\"\n />\n {message?.mine && (\n <FormSheet.Action\n onPress={() => handleEditPress()}\n title=\"Edit message\"\n iconName=\"accounts.editor\"\n accessibilityHint=\"Opens existing text in the message form input.\"\n />\n )}\n {message?.mine && (\n <FormSheet.Action\n onPress={() => handleViewReadReceiptsPress()}\n title=\"View read receipts\"\n iconName=\"general.checkPerson\"\n accessibilityHint=\"Opens a modal with a list of people who read your message.\"\n />\n )}\n {(message?.mine || canDeleteNonAuthoredMessages) && (\n <FormSheet.Action\n onPress={() => handleDeleteConfirm()}\n title=\"Delete message\"\n iconName=\"publishing.trash\"\n appearance=\"danger\"\n disabled={isPending}\n accessibilityHint=\"Opens a confirmation alert to delete this message permanently.\"\n />\n )}\n </View>\n </FormSheet.Root>\n )\n}\n\nconst Reaction = ({\n reaction,\n onPress,\n}: {\n reaction: { value: ReactionCountResource['value']; emoji: string; mine: boolean | undefined }\n onPress: () => void\n}) => {\n const styles = useStyles()\n const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 })\n\n const { colors } = useTheme()\n const baseRippleColor = reaction.mine ? colors.interaction : colors.fillColorNeutral060\n const androidRippleColor = useCreateAndroidRippleColor({ color: baseRippleColor })\n\n return (\n <PlatformPressable\n key={reaction.value}\n style={[reactionStyles.reaction, styles.reaction]}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n onPress={onPress}\n >\n <Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>\n </PlatformPressable>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 })\n\n const btnBorderWidth = 1\n const baseSize = 46 * fontScale\n const reactionBtnSize = Platform.select({\n ios: baseSize,\n android: baseSize + btnBorderWidth * 2,\n })\n\n return StyleSheet.create({\n formSheetContent: {\n paddingTop: 16,\n },\n reactionList: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n gap: 16,\n paddingTop: 8,\n paddingBottom: 16,\n borderBottomColor: colors.borderColorDefaultBase,\n borderBottomWidth: 1,\n },\n reaction: {\n height: reactionBtnSize,\n width: reactionBtnSize,\n borderWidth: btnBorderWidth,\n borderRadius: 32,\n justifyContent: 'center',\n overflow: 'hidden',\n },\n reactionEmoji: {\n fontSize: 24,\n },\n actions: {\n paddingTop: 4,\n },\n })\n}\n"]}
|
|
@@ -23,6 +23,9 @@ export interface MessageResource {
|
|
|
23
23
|
threadPosition?: 'first' | 'center' | 'last' | null;
|
|
24
24
|
prevIsMyReply?: boolean;
|
|
25
25
|
nextIsMyReply?: boolean;
|
|
26
|
+
nextRendersAuthor?: boolean;
|
|
27
|
+
isReplyShadowMessage?: boolean;
|
|
28
|
+
nextIsReplyShadowMessage?: boolean;
|
|
26
29
|
pending?: boolean;
|
|
27
30
|
error?: string;
|
|
28
31
|
attachmentsForCreate?: DenormalizedAttachmentResourceForCreate[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/types/resources/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAA;AACnF,OAAO,EAAE,uCAAuC,EAAE,MAAM,+CAA+C,CAAA;AACvG,OAAO,KAAK,EAAE,cAAc,EAAE,MA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,CAAA;IACV,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,8BAA8B,EAAE,CAAA;IAC7C,MAAM,EAAE,cAAc,CAAA;IACtB,cAAc,EAAE,qBAAqB,EAAE,CAAA;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAG3B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,cAAc,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAA;IACnD,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAGlC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oBAAoB,CAAC,EAAE,uCAAuC,EAAE,CAAA;CACjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/types/resources/message.ts"],"names":[],"mappings":"","sourcesContent":["import { DenormalizedAttachmentResource } from './denormalized_attachment_resource'\nimport { DenormalizedAttachmentResourceForCreate } from './denormalized_attachment_resource_for_create'\nimport type { PersonResource } from './person'\nimport type { ReactionCountResource } from './reaction'\n\nexport interface MessageResource {\n type: 'Message'\n id: string\n text: string | null\n html: string\n createdAt: string\n deletedAt: string | null\n textEditedAt: string | null\n mine: boolean\n attachments: DenormalizedAttachmentResource[]\n author: PersonResource\n reactionCounts: ReactionCountResource[]\n replyCount: number\n replyRootId?: string | null\n\n // Custom Local Properties we set for rendering\n renderAuthor?: boolean\n renderTime?: boolean\n myLatestInConversation?: boolean\n lastInGroup?: boolean\n threadPosition?: 'first' | 'center' | 'last' | null\n prevIsMyReply?: boolean\n nextIsMyReply?: boolean\n\n // Properties for mutation state\n pending?: boolean // Indicates if the message is optimistically created and pending server response\n error?: string // Error message if the message failed to send\n attachmentsForCreate?: DenormalizedAttachmentResourceForCreate[]\n}\n"]}
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/types/resources/message.ts"],"names":[],"mappings":"","sourcesContent":["import { DenormalizedAttachmentResource } from './denormalized_attachment_resource'\nimport { DenormalizedAttachmentResourceForCreate } from './denormalized_attachment_resource_for_create'\nimport type { PersonResource } from './person'\nimport type { ReactionCountResource } from './reaction'\n\nexport interface MessageResource {\n type: 'Message'\n id: string\n text: string | null\n html: string\n createdAt: string\n deletedAt: string | null\n textEditedAt: string | null\n mine: boolean\n attachments: DenormalizedAttachmentResource[]\n author: PersonResource\n reactionCounts: ReactionCountResource[]\n replyCount: number\n replyRootId?: string | null\n\n // Custom Local Properties we set for rendering\n renderAuthor?: boolean\n renderTime?: boolean\n myLatestInConversation?: boolean\n lastInGroup?: boolean\n threadPosition?: 'first' | 'center' | 'last' | null\n prevIsMyReply?: boolean\n nextIsMyReply?: boolean\n nextRendersAuthor?: boolean\n isReplyShadowMessage?: boolean\n nextIsReplyShadowMessage?: boolean\n\n // Properties for mutation state\n pending?: boolean // Indicates if the message is optimistically created and pending server response\n error?: string // Error message if the message failed to send\n attachmentsForCreate?: DenormalizedAttachmentResourceForCreate[]\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getMessagesQueryKey } from '../../
|
|
1
|
+
import { getMessagesQueryKey } from '../../utils/request/get_messages';
|
|
2
2
|
import { chatQueryClient } from '../../contexts/api_provider';
|
|
3
3
|
import { updateOrCreateRecordInPagesData } from './page_mutations';
|
|
4
4
|
import { convertAttachmentsForCreate } from '../convert_attachments_for_create';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimistically_create_message.js","sourceRoot":"","sources":["../../../src/utils/cache/optimistically_create_message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"optimistically_create_message.js","sourceRoot":"","sources":["../../../src/utils/cache/optimistically_create_message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAA;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAA;AAG/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAEtE,MAAM,UAAU,2BAA2B,CAAC,EAC1C,cAAc,EACd,IAAI,EACJ,WAAW,EACX,aAAa,EACb,OAAO,GAOR;IACC,MAAM,EAAE,GAAG,OAAO,EAAE,EAAE,IAAI,qBAAqB,EAAE,CAAA;IAEjD,+DAA+D;IAC/D,MAAM,oBAAoB,GAAqC,2BAA2B,CACxF,WAAW,IAAI,EAAE,CAClB,CAAA;IAED,+BAA+B;IAC/B,MAAM,iBAAiB,GAAoB;QACzC,GAAG,OAAO;QACV,IAAI,EAAE,SAAS;QACf,EAAE;QACF,IAAI;QACJ,IAAI,EAAE,EAAE,EAAE,2BAA2B;QACrC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,IAAI;QAClB,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,oBAAoB;QACjC,oBAAoB,EAAE,WAAW,IAAI,EAAE;QACvC,MAAM,EAAE,aAAa;QACrB,cAAc,EAAE,EAAE;QAClB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,IAAI;QAChB,sBAAsB,EAAE,IAAI;QAC5B,WAAW,EAAE,IAAI;QACjB,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,IAAI;KAClB,CAAA;IAID,MAAM,QAAQ,GAAG,mBAAmB,CAAC,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC,CAAA;IAEzE,eAAe,CAAC,YAAY,CAAY,QAAQ,EAAE,IAAI,CAAC,EAAE,CACvD,+BAA+B,CAAC;QAC9B,IAAI;QACJ,MAAM,EAAE,iBAAoC;KAC7C,CAAC,CACH,CAAA;IAED,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAED,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACjC,0FAA0F;IAC1F,sEAAsE;IACtE,OAAO,GAAG,uBAAuB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,OAAO,CAAA;AAC9D,CAAC,CAAA","sourcesContent":["import { InfiniteData } from '@tanstack/react-query'\nimport { ApiCollection, CurrentPersonResource, MessageResource } from '../../types'\nimport { getMessagesQueryKey } from '../../utils/request/get_messages'\nimport { chatQueryClient } from '../../contexts/api_provider'\nimport { updateOrCreateRecordInPagesData } from './page_mutations'\nimport { convertAttachmentsForCreate } from '../convert_attachments_for_create'\nimport { DenormalizedAttachmentResourceForCreate } from '../../types/resources/denormalized_attachment_resource_for_create'\nimport { DenormalizedAttachmentResource } from '../../types/resources/denormalized_attachment_resource'\nimport { generatePlaceholderUlid } from '../generate_placeholder_ulid'\n\nexport function optimisticallyCreateMessage({\n conversationId,\n text,\n attachments,\n currentPerson,\n message,\n}: {\n conversationId: number\n text: string\n attachments?: DenormalizedAttachmentResourceForCreate[]\n currentPerson: CurrentPersonResource\n message?: MessageResource\n}) {\n const id = message?.id || generateTempMessageId()\n\n // Convert attachments to denormalized format for optimistic UI\n const decoratedAttachments: DenormalizedAttachmentResource[] = convertAttachmentsForCreate(\n attachments || []\n )\n\n // Create an optimistic message\n const optimisticMessage: MessageResource = {\n ...message,\n type: 'Message',\n id,\n text,\n html: '', // Will be filled by server\n createdAt: new Date().toISOString(),\n deletedAt: null,\n textEditedAt: null,\n mine: true,\n attachments: decoratedAttachments,\n attachmentsForCreate: attachments || [],\n author: currentPerson,\n reactionCounts: [],\n renderAuthor: false,\n renderTime: true,\n myLatestInConversation: true,\n lastInGroup: true,\n pending: true,\n replyCount: 0,\n replyRootId: null,\n }\n\n // Add the optimistic message to the cache\n type QueryData = InfiniteData<ApiCollection<MessageResource>>\n const queryKey = getMessagesQueryKey({ conversation_id: conversationId })\n\n chatQueryClient.setQueryData<QueryData>(queryKey, data =>\n updateOrCreateRecordInPagesData({\n data,\n record: optimisticMessage as MessageResource,\n })\n )\n\n return optimisticMessage\n}\n\nconst generateTempMessageId = () => {\n // Put it 5 seconds in the future to account for server lag of previously created messages\n // that are still pending. This gets overwritten by the server anyway.\n return `${generatePlaceholderUlid({ offsetMs: 5000 })}-temp`\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getMessagesQueryKey } from '../../
|
|
1
|
+
import { getMessagesQueryKey } from '../../utils/request/get_messages';
|
|
2
2
|
import { chatQueryClient } from '../../contexts/api_provider';
|
|
3
3
|
import { updateOrCreateRecordInPagesData } from './page_mutations';
|
|
4
4
|
export function optimisticallyUpdateMessage({ conversationId, message, text, }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimistically_update_message.js","sourceRoot":"","sources":["../../../src/utils/cache/optimistically_update_message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"optimistically_update_message.js","sourceRoot":"","sources":["../../../src/utils/cache/optimistically_update_message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAA;AAElE,MAAM,UAAU,2BAA2B,CAAC,EAC1C,cAAc,EACd,OAAO,EACP,IAAI,GAKL;IAEC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC,CAAA;IAEzE,IAAI,iBAAiB,GAAG,OAAO,CAAA;IAE/B,eAAe,CAAC,YAAY,CAAY,QAAQ,EAAE,IAAI,CAAC,EAAE,CACvD,+BAA+B,CAAC;QAC9B,IAAI;QACJ,MAAM,EAAE,OAAO;QACf,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;YAC5B,iBAAiB,GAAG;gBAClB,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC;gBACjB,IAAI;gBACJ,OAAO,EAAE,IAAI;aACd,CAAA;YACD,OAAO,iBAAiB,CAAA;QAC1B,CAAC;KACF,CAAC,CACH,CAAA;IAED,OAAO,iBAAiB,CAAA;AAC1B,CAAC","sourcesContent":["import { InfiniteData } from '@tanstack/react-query'\nimport { ApiCollection, MessageResource } from '../../types'\nimport { getMessagesQueryKey } from '../../utils/request/get_messages'\nimport { chatQueryClient } from '../../contexts/api_provider'\nimport { updateOrCreateRecordInPagesData } from './page_mutations'\n\nexport function optimisticallyUpdateMessage({\n conversationId,\n message,\n text,\n}: {\n conversationId: number\n message: MessageResource\n text: string\n}) {\n type QueryData = InfiniteData<ApiCollection<MessageResource>>\n const queryKey = getMessagesQueryKey({ conversation_id: conversationId })\n\n let optimisticMessage = message\n\n chatQueryClient.setQueryData<QueryData>(queryKey, data =>\n updateOrCreateRecordInPagesData({\n data,\n record: message,\n processRecord: (next, prev) => {\n optimisticMessage = {\n ...(prev || next),\n text,\n pending: true,\n }\n return optimisticMessage\n },\n })\n )\n\n return optimisticMessage\n}\n"]}
|
package/build/utils/pluralize.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const irregularInflections = { person: 'people' };
|
|
1
|
+
const irregularInflections = { person: 'people', reply: 'replies' };
|
|
2
2
|
export function pluralize(count, singularWord, includeCount = true) {
|
|
3
3
|
const plural = count !== 1;
|
|
4
4
|
const pluralWord = irregularInflections[singularWord] || `${singularWord}s`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pluralize.js","sourceRoot":"","sources":["../../src/utils/pluralize.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAA2B,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"pluralize.js","sourceRoot":"","sources":["../../src/utils/pluralize.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAA2B,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAA;AAE3F,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,YAAoB,EAAE,YAAY,GAAG,IAAI;IAChF,MAAM,MAAM,GAAG,KAAK,KAAK,CAAC,CAAA;IAC1B,MAAM,UAAU,GAAG,oBAAoB,CAAC,YAAY,CAAC,IAAI,GAAG,YAAY,GAAG,CAAA;IAE3E,OAAO;QACL,YAAY,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE;QAChD,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY;KACnC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACZ,CAAC","sourcesContent":["const irregularInflections: Record<string, string> = { person: 'people', reply: 'replies' }\n\nexport function pluralize(count: number, singularWord: string, includeCount = true) {\n const plural = count !== 1\n const pluralWord = irregularInflections[singularWord] || `${singularWord}s`\n\n return [\n includeCount ? `${count.toLocaleString()} ` : '',\n plural ? pluralWord : singularWord,\n ].join('')\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const getMessageRequestArgs: ({ conversation_id, messageId, }: {
|
|
2
|
+
conversation_id: number;
|
|
3
|
+
messageId: string;
|
|
4
|
+
}) => {
|
|
5
|
+
url: string;
|
|
6
|
+
data: {
|
|
7
|
+
perPage: number;
|
|
8
|
+
fields: {
|
|
9
|
+
Message: string[];
|
|
10
|
+
Person: string[];
|
|
11
|
+
ReactionCount: string[];
|
|
12
|
+
};
|
|
13
|
+
include: string[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const getMessageQueryKey: ({ conversation_id, messageId, }: {
|
|
17
|
+
conversation_id: number;
|
|
18
|
+
messageId: string;
|
|
19
|
+
}) => import("../../hooks/use_suspense_api").RequestQueryKey;
|
|
20
|
+
//# sourceMappingURL=get_message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_message.d.ts","sourceRoot":"","sources":["../../../src/utils/request/get_message.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,oCAG/B;IACD,eAAe,EAAE,MAAM,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;CAClB;;;;;;;;;;;CAWA,CAAA;AAED,eAAO,MAAM,kBAAkB,oCAG5B;IACD,eAAe,EAAE,MAAM,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;CAClB,2DAGA,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getRequestQueryKey } from '../../hooks/use_suspense_api';
|
|
2
|
+
import { getMessageFields, getMessagesInclude } from './messages_data_options';
|
|
3
|
+
export const getMessageRequestArgs = ({ conversation_id, messageId, }) => {
|
|
4
|
+
const url = `/me/conversations/${conversation_id}/messages/${messageId}`;
|
|
5
|
+
return {
|
|
6
|
+
url,
|
|
7
|
+
data: {
|
|
8
|
+
perPage: 25,
|
|
9
|
+
fields: getMessageFields,
|
|
10
|
+
include: getMessagesInclude,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export const getMessageQueryKey = ({ conversation_id, messageId, }) => {
|
|
15
|
+
const requestArgs = getMessageRequestArgs({ conversation_id, messageId });
|
|
16
|
+
return getRequestQueryKey(requestArgs);
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=get_message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_message.js","sourceRoot":"","sources":["../../../src/utils/request/get_message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE9E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EACpC,eAAe,EACf,SAAS,GAIV,EAAE,EAAE;IACH,MAAM,GAAG,GAAG,qBAAqB,eAAe,aAAa,SAAS,EAAE,CAAA;IAExE,OAAO;QACL,GAAG;QACH,IAAI,EAAE;YACJ,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,gBAAgB;YACxB,OAAO,EAAE,kBAAkB;SAC5B;KACF,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,eAAe,EACf,SAAS,GAIV,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,qBAAqB,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,CAAA;IACzE,OAAO,kBAAkB,CAAC,WAAW,CAAC,CAAA;AACxC,CAAC,CAAA","sourcesContent":["import { getRequestQueryKey } from '../../hooks/use_suspense_api'\nimport { getMessageFields, getMessagesInclude } from './messages_data_options'\n\nexport const getMessageRequestArgs = ({\n conversation_id,\n messageId,\n}: {\n conversation_id: number\n messageId: string\n}) => {\n const url = `/me/conversations/${conversation_id}/messages/${messageId}`\n\n return {\n url,\n data: {\n perPage: 25,\n fields: getMessageFields,\n include: getMessagesInclude,\n },\n }\n}\n\nexport const getMessageQueryKey = ({\n conversation_id,\n messageId,\n}: {\n conversation_id: number\n messageId: string\n}) => {\n const requestArgs = getMessageRequestArgs({ conversation_id, messageId })\n return getRequestQueryKey(requestArgs)\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const getMessagesRequestArgs: ({ conversation_id, reply_root_id, }: {
|
|
2
|
+
conversation_id: number;
|
|
3
|
+
reply_root_id?: string | null;
|
|
4
|
+
}) => {
|
|
5
|
+
url: string;
|
|
6
|
+
data: {
|
|
7
|
+
perPage: number;
|
|
8
|
+
fields: {
|
|
9
|
+
Message: string[];
|
|
10
|
+
Person: string[];
|
|
11
|
+
ReactionCount: string[];
|
|
12
|
+
};
|
|
13
|
+
include: string[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const getMessagesQueryKey: ({ conversation_id, reply_root_id, }: {
|
|
17
|
+
conversation_id: number;
|
|
18
|
+
reply_root_id?: string | null;
|
|
19
|
+
}) => import("../../hooks/use_suspense_api").RequestQueryKey;
|
|
20
|
+
//# sourceMappingURL=get_messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_messages.d.ts","sourceRoot":"","sources":["../../../src/utils/request/get_messages.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,sBAAsB,wCAGhC;IACD,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;;;;;;;;;;;CAaA,CAAA;AAED,eAAO,MAAM,mBAAmB,wCAG7B;IACD,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B,2DAGA,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getRequestQueryKey } from '../../hooks/use_suspense_api';
|
|
2
|
+
import { getMessageFields, getMessagesInclude } from './messages_data_options';
|
|
3
|
+
export const getMessagesRequestArgs = ({ conversation_id, reply_root_id, }) => {
|
|
4
|
+
const url = reply_root_id
|
|
5
|
+
? `/me/conversations/${conversation_id}/messages/${reply_root_id}/replies`
|
|
6
|
+
: `/me/conversations/${conversation_id}/messages`;
|
|
7
|
+
return {
|
|
8
|
+
url,
|
|
9
|
+
data: {
|
|
10
|
+
perPage: 25,
|
|
11
|
+
fields: getMessageFields,
|
|
12
|
+
include: getMessagesInclude,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export const getMessagesQueryKey = ({ conversation_id, reply_root_id, }) => {
|
|
17
|
+
const requestArgs = getMessagesRequestArgs({ conversation_id, reply_root_id });
|
|
18
|
+
return getRequestQueryKey(requestArgs);
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=get_messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_messages.js","sourceRoot":"","sources":["../../../src/utils/request/get_messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE9E,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACrC,eAAe,EACf,aAAa,GAId,EAAE,EAAE;IACH,MAAM,GAAG,GAAG,aAAa;QACvB,CAAC,CAAC,qBAAqB,eAAe,aAAa,aAAa,UAAU;QAC1E,CAAC,CAAC,qBAAqB,eAAe,WAAW,CAAA;IAEnD,OAAO;QACL,GAAG;QACH,IAAI,EAAE;YACJ,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,gBAAgB;YACxB,OAAO,EAAE,kBAAkB;SAC5B;KACF,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAClC,eAAe,EACf,aAAa,GAId,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,sBAAsB,CAAC,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC,CAAA;IAC9E,OAAO,kBAAkB,CAAC,WAAW,CAAC,CAAA;AACxC,CAAC,CAAA","sourcesContent":["import { getRequestQueryKey } from '../../hooks/use_suspense_api'\nimport { getMessageFields, getMessagesInclude } from './messages_data_options'\n\nexport const getMessagesRequestArgs = ({\n conversation_id,\n reply_root_id,\n}: {\n conversation_id: number\n reply_root_id?: string | null\n}) => {\n const url = reply_root_id\n ? `/me/conversations/${conversation_id}/messages/${reply_root_id}/replies`\n : `/me/conversations/${conversation_id}/messages`\n\n return {\n url,\n data: {\n perPage: 25,\n fields: getMessageFields,\n include: getMessagesInclude,\n },\n }\n}\n\nexport const getMessagesQueryKey = ({\n conversation_id,\n reply_root_id,\n}: {\n conversation_id: number\n reply_root_id?: string | null\n}) => {\n const requestArgs = getMessagesRequestArgs({ conversation_id, reply_root_id })\n return getRequestQueryKey(requestArgs)\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages_data_options.d.ts","sourceRoot":"","sources":["../../../src/utils/request/messages_data_options.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;CAe5B,CAAA;AAED,eAAO,MAAM,kBAAkB,UAAgC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const getMessageFields = {
|
|
2
|
+
Message: [
|
|
3
|
+
'text',
|
|
4
|
+
'text_edited_at',
|
|
5
|
+
'mine',
|
|
6
|
+
'attachments',
|
|
7
|
+
'created_at',
|
|
8
|
+
'deleted_at',
|
|
9
|
+
'author',
|
|
10
|
+
'reaction_counts',
|
|
11
|
+
'reply_count',
|
|
12
|
+
'reply_root',
|
|
13
|
+
],
|
|
14
|
+
Person: ['name', 'avatar'],
|
|
15
|
+
ReactionCount: ['value', 'count', 'mine', 'message_id', 'author_ids'],
|
|
16
|
+
};
|
|
17
|
+
export const getMessagesInclude = ['author', 'reaction_counts'];
|
|
18
|
+
//# sourceMappingURL=messages_data_options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages_data_options.js","sourceRoot":"","sources":["../../../src/utils/request/messages_data_options.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,OAAO,EAAE;QACP,MAAM;QACN,gBAAgB;QAChB,MAAM;QACN,aAAa;QACb,YAAY;QACZ,YAAY;QACZ,QAAQ;QACR,iBAAiB;QACjB,aAAa;QACb,YAAY;KACb;IACD,MAAM,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC;CACtE,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAA","sourcesContent":["export const getMessageFields = {\n Message: [\n 'text',\n 'text_edited_at',\n 'mine',\n 'attachments',\n 'created_at',\n 'deleted_at',\n 'author',\n 'reaction_counts',\n 'reply_count',\n 'reply_root',\n ],\n Person: ['name', 'avatar'],\n ReactionCount: ['value', 'count', 'mine', 'message_id', 'author_ids'],\n}\n\nexport const getMessagesInclude = ['author', 'reaction_counts']\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "3.17.0
|
|
3
|
+
"version": "3.17.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"react-native-url-polyfill": "^2.0.0",
|
|
57
57
|
"typescript": "<5.6.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "df5f37a2d46dca3d54aeff706c80bbcf086a36b2"
|
|
60
60
|
}
|
|
@@ -14,4 +14,7 @@ describe('pluralize', () => {
|
|
|
14
14
|
it('can convert "person" to "people"', () => {
|
|
15
15
|
expect(pluralize(2, 'person', false)).toEqual('people')
|
|
16
16
|
})
|
|
17
|
+
it('can convert "reply" to "replies"', () => {
|
|
18
|
+
expect(pluralize(2, 'reply', false)).toEqual('replies')
|
|
19
|
+
})
|
|
17
20
|
})
|
|
@@ -24,8 +24,9 @@ import { useLiveRelativeTime } from '../../hooks/use_live_relative_time'
|
|
|
24
24
|
import { MessageReadReceipts } from './message_read_receipts'
|
|
25
25
|
import { isNewMessage, useMessageCreateOrUpdate } from '../../hooks/use_message_create_or_update'
|
|
26
26
|
import { Haptic } from '../../utils/native_adapters'
|
|
27
|
-
import { TheirReplyConnector, MyReplyConnector } from './reply_connectors'
|
|
28
|
-
import { REPLIES_FEATURE_ENABLED } from '../../utils'
|
|
27
|
+
import { TheirReplyConnector, MyReplyConnector, AVATAR_CONNECTOR_SPACING } from './reply_connectors'
|
|
28
|
+
import { pluralize, REPLIES_FEATURE_ENABLED } from '../../utils'
|
|
29
|
+
import { useConversationMessage } from '../../hooks/use_conversation_message'
|
|
29
30
|
|
|
30
31
|
/** Message
|
|
31
32
|
* Component for display of a message within a conversation list
|
|
@@ -59,6 +60,15 @@ export function Message({
|
|
|
59
60
|
const [messageBubbleHeight, setMessageBubbleHeight] = React.useState(0)
|
|
60
61
|
const { animatedBackgroundColor, handleMessagePressIn, handleMessagePressOut } =
|
|
61
62
|
useAnimatedMessageBackgroundColor()
|
|
63
|
+
const { message: replyRootMessage } = useConversationMessage({
|
|
64
|
+
conversation_id,
|
|
65
|
+
messageId: message.replyRootId || '',
|
|
66
|
+
enabled: !!message.replyRootId,
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const replyRootAuthorName = message.replyRootId
|
|
70
|
+
? replyRootMessage?.author.name
|
|
71
|
+
: message.author.name
|
|
62
72
|
|
|
63
73
|
useEffect(() => {
|
|
64
74
|
if (pending) {
|
|
@@ -93,6 +103,7 @@ export function Message({
|
|
|
93
103
|
conversation_id,
|
|
94
104
|
canDeleteNonAuthoredMessages,
|
|
95
105
|
inReplyScreen,
|
|
106
|
+
reply_root_author_name: replyRootAuthorName,
|
|
96
107
|
})
|
|
97
108
|
}
|
|
98
109
|
const handleReactionLongPress = (reaction: ReactionCountResource) => {
|
|
@@ -120,7 +131,7 @@ export function Message({
|
|
|
120
131
|
navigation.navigate('ConversationReply', {
|
|
121
132
|
conversation_id,
|
|
122
133
|
reply_root_id: message.id,
|
|
123
|
-
|
|
134
|
+
reply_root_author_name: message.author.name,
|
|
124
135
|
})
|
|
125
136
|
}
|
|
126
137
|
|
|
@@ -130,10 +141,16 @@ export function Message({
|
|
|
130
141
|
}
|
|
131
142
|
|
|
132
143
|
const renderAuthor = (!message.mine && message.renderAuthor) || false
|
|
133
|
-
const messageBottomMargin = message.lastInGroup ? 12 : hasReactions || showMessageMeta ? 8 : 4
|
|
134
144
|
const messagePendingLabel = isPersisted ? 'Saving' : 'Sending'
|
|
135
145
|
const showReplyCountButton =
|
|
136
146
|
!inReplyScreen && message.replyRootId === message.id && REPLIES_FEATURE_ENABLED
|
|
147
|
+
const replyCountText = pluralize(message.replyCount, 'reply')
|
|
148
|
+
const messageBottomMargin =
|
|
149
|
+
message.lastInGroup || message.nextIsReplyShadowMessage
|
|
150
|
+
? 16
|
|
151
|
+
: hasReactions || showMessageMeta || showReplyCountButton
|
|
152
|
+
? 8
|
|
153
|
+
: 4
|
|
137
154
|
|
|
138
155
|
return (
|
|
139
156
|
<Pressable
|
|
@@ -162,7 +179,11 @@ export function Message({
|
|
|
162
179
|
</View>
|
|
163
180
|
)}
|
|
164
181
|
<View style={[styles.messageContent, { marginBottom: messageBottomMargin }]}>
|
|
165
|
-
{renderAuthor &&
|
|
182
|
+
{renderAuthor && (
|
|
183
|
+
<Text variant="footnote" style={styles.authorName}>
|
|
184
|
+
{message.author.name}
|
|
185
|
+
</Text>
|
|
186
|
+
)}
|
|
166
187
|
<View
|
|
167
188
|
style={styles.messageBubble}
|
|
168
189
|
onLayout={e => setMessageBubbleHeight(e.nativeEvent.layout.height)}
|
|
@@ -189,7 +210,7 @@ export function Message({
|
|
|
189
210
|
accessibilityHint="Navigates to reply screen for this message"
|
|
190
211
|
accessibilityRole="link"
|
|
191
212
|
>
|
|
192
|
-
{
|
|
213
|
+
{replyCountText}
|
|
193
214
|
</TextButton>
|
|
194
215
|
)}
|
|
195
216
|
{hasReactions && (
|
|
@@ -282,11 +303,14 @@ const useMessageStyles = ({ mine }: MessageResource) => {
|
|
|
282
303
|
gap: 4,
|
|
283
304
|
},
|
|
284
305
|
avatar: {
|
|
285
|
-
marginBottom:
|
|
306
|
+
marginBottom: AVATAR_CONNECTOR_SPACING,
|
|
286
307
|
},
|
|
287
308
|
avatarPlaceholder: {
|
|
288
309
|
width: MESSAGE_AUTHOR_AVATAR_COLUMN_WIDTH, // Same width as avatar
|
|
289
310
|
},
|
|
311
|
+
authorName: {
|
|
312
|
+
fontWeight: platformFontWeightMedium,
|
|
313
|
+
},
|
|
290
314
|
messageBubble: {
|
|
291
315
|
backgroundColor: messageBubbleBackgroundColor,
|
|
292
316
|
borderRadius: 8,
|
|
@@ -59,7 +59,8 @@ export const MessageForm = {
|
|
|
59
59
|
interface MessagesFormRootProps extends ViewProps {
|
|
60
60
|
conversation: ConversationResource
|
|
61
61
|
currentlyEditingMessage?: MessageResource | null
|
|
62
|
-
replyRootId?: string
|
|
62
|
+
replyRootId?: string | null
|
|
63
|
+
replyRootAuthorFirstName?: string | null
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
const MessageFormContext = React.createContext<{
|
|
@@ -73,7 +74,8 @@ const MessageFormContext = React.createContext<{
|
|
|
73
74
|
attachmentUploader?: ReturnType<typeof useAttachmentUploader>
|
|
74
75
|
currentlyEditingMessage?: MessageResource | null
|
|
75
76
|
reset: () => void
|
|
76
|
-
replyRootId?: string
|
|
77
|
+
replyRootId?: string | null
|
|
78
|
+
replyRootAuthorFirstName?: string | null
|
|
77
79
|
}>({
|
|
78
80
|
text: '',
|
|
79
81
|
setText: (_text: string) => {},
|
|
@@ -85,6 +87,7 @@ const MessageFormContext = React.createContext<{
|
|
|
85
87
|
currentlyEditingMessage: null,
|
|
86
88
|
reset: () => {},
|
|
87
89
|
replyRootId: undefined,
|
|
90
|
+
replyRootAuthorFirstName: undefined,
|
|
88
91
|
})
|
|
89
92
|
|
|
90
93
|
const GIPHY_MAX_LENGTH = 50
|
|
@@ -95,6 +98,7 @@ function MessageFormRoot({
|
|
|
95
98
|
currentlyEditingMessage,
|
|
96
99
|
children,
|
|
97
100
|
replyRootId,
|
|
101
|
+
replyRootAuthorFirstName,
|
|
98
102
|
}: MessagesFormRootProps) {
|
|
99
103
|
const { giphyApiKey } = useContext(ChatContext)
|
|
100
104
|
const canGiphy = !!giphyApiKey && !currentlyEditingMessage
|
|
@@ -248,6 +252,7 @@ function MessageFormRoot({
|
|
|
248
252
|
currentlyEditingMessage,
|
|
249
253
|
reset,
|
|
250
254
|
replyRootId,
|
|
255
|
+
replyRootAuthorFirstName,
|
|
251
256
|
}}
|
|
252
257
|
>
|
|
253
258
|
<View style={styles.container}>
|
|
@@ -559,14 +564,15 @@ function EditingIndicator() {
|
|
|
559
564
|
}
|
|
560
565
|
|
|
561
566
|
function ReplyIndicator() {
|
|
562
|
-
const { replyRootId } = React.useContext(MessageFormContext)
|
|
567
|
+
const { replyRootId, replyRootAuthorFirstName } = React.useContext(MessageFormContext)
|
|
563
568
|
const navigation = useNavigation()
|
|
569
|
+
const title = replyRootAuthorFirstName ? `Reply to ${replyRootAuthorFirstName}` : 'Reply'
|
|
564
570
|
|
|
565
571
|
if (!REPLIES_FEATURE_ENABLED || !replyRootId) return null
|
|
566
572
|
|
|
567
573
|
return (
|
|
568
574
|
<FormIndicatorRow
|
|
569
|
-
title=
|
|
575
|
+
title={title}
|
|
570
576
|
buttonText="Exit replies"
|
|
571
577
|
accessibilityHint="Return to the main conversation"
|
|
572
578
|
iconName="registrations.undo"
|