@planningcenter/chat-react-native 3.24.4 → 3.25.0-rc.1

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.
Files changed (86) hide show
  1. package/build/components/conversations/conversation_actions.js +3 -3
  2. package/build/components/conversations/conversation_actions.js.map +1 -1
  3. package/build/components/conversations/conversations.d.ts.map +1 -1
  4. package/build/components/conversations/conversations.js +1 -0
  5. package/build/components/conversations/conversations.js.map +1 -1
  6. package/build/hooks/use_conversation.d.ts.map +1 -1
  7. package/build/hooks/use_conversation.js +13 -1
  8. package/build/hooks/use_conversation.js.map +1 -1
  9. package/build/hooks/use_conversation_membership.d.ts +5 -0
  10. package/build/hooks/use_conversation_membership.d.ts.map +1 -0
  11. package/build/hooks/use_conversation_membership.js +63 -0
  12. package/build/hooks/use_conversation_membership.js.map +1 -0
  13. package/build/hooks/use_conversations_actions.d.ts.map +1 -1
  14. package/build/hooks/use_conversations_actions.js +4 -0
  15. package/build/hooks/use_conversations_actions.js.map +1 -1
  16. package/build/hooks/use_features.d.ts +1 -0
  17. package/build/hooks/use_features.d.ts.map +1 -1
  18. package/build/hooks/use_features.js +1 -0
  19. package/build/hooks/use_features.js.map +1 -1
  20. package/build/navigation/index.d.ts +10 -0
  21. package/build/navigation/index.d.ts.map +1 -1
  22. package/build/navigation/index.js +12 -2
  23. package/build/navigation/index.js.map +1 -1
  24. package/build/screens/conversation_details_screen.d.ts.map +1 -1
  25. package/build/screens/conversation_details_screen.js +50 -16
  26. package/build/screens/conversation_details_screen.js.map +1 -1
  27. package/build/screens/conversation_notification_level_select_screen.d.ts +8 -0
  28. package/build/screens/conversation_notification_level_select_screen.d.ts.map +1 -0
  29. package/build/screens/conversation_notification_level_select_screen.js +49 -0
  30. package/build/screens/conversation_notification_level_select_screen.js.map +1 -0
  31. package/build/screens/conversation_screen.d.ts +3 -1
  32. package/build/screens/conversation_screen.d.ts.map +1 -1
  33. package/build/screens/conversation_screen.js +16 -5
  34. package/build/screens/conversation_screen.js.map +1 -1
  35. package/build/screens/group_notification_level_select_screen.d.ts +8 -0
  36. package/build/screens/group_notification_level_select_screen.d.ts.map +1 -0
  37. package/build/screens/group_notification_level_select_screen.js +40 -0
  38. package/build/screens/group_notification_level_select_screen.js.map +1 -0
  39. package/build/screens/group_notification_settings_screen.d.ts.map +1 -1
  40. package/build/screens/group_notification_settings_screen.js +30 -17
  41. package/build/screens/group_notification_settings_screen.js.map +1 -1
  42. package/build/screens/notification_settings/hooks/groups.d.ts +6 -5
  43. package/build/screens/notification_settings/hooks/groups.d.ts.map +1 -1
  44. package/build/screens/notification_settings/hooks/groups.js +63 -36
  45. package/build/screens/notification_settings/hooks/groups.js.map +1 -1
  46. package/build/screens/notification_settings_screen.d.ts.map +1 -1
  47. package/build/screens/notification_settings_screen.js +25 -11
  48. package/build/screens/notification_settings_screen.js.map +1 -1
  49. package/build/types/resources/conversation.d.ts +2 -3
  50. package/build/types/resources/conversation.d.ts.map +1 -1
  51. package/build/types/resources/conversation.js.map +1 -1
  52. package/build/types/resources/conversation_membership.d.ts +16 -0
  53. package/build/types/resources/conversation_membership.d.ts.map +1 -0
  54. package/build/types/resources/conversation_membership.js +2 -0
  55. package/build/types/resources/conversation_membership.js.map +1 -0
  56. package/build/types/resources/group_membership.d.ts +7 -0
  57. package/build/types/resources/group_membership.d.ts.map +1 -1
  58. package/build/types/resources/group_membership.js.map +1 -1
  59. package/build/types/resources/index.d.ts +1 -0
  60. package/build/types/resources/index.d.ts.map +1 -1
  61. package/build/types/resources/index.js +1 -0
  62. package/build/types/resources/index.js.map +1 -1
  63. package/build/utils/deep_snake_case_keys.d.ts +4 -0
  64. package/build/utils/deep_snake_case_keys.d.ts.map +1 -0
  65. package/build/utils/deep_snake_case_keys.js +13 -0
  66. package/build/utils/deep_snake_case_keys.js.map +1 -0
  67. package/package.json +2 -2
  68. package/src/components/conversations/conversation_actions.tsx +3 -3
  69. package/src/components/conversations/conversations.tsx +1 -0
  70. package/src/hooks/use_conversation.ts +13 -1
  71. package/src/hooks/use_conversation_membership.ts +91 -0
  72. package/src/hooks/use_conversations_actions.ts +4 -0
  73. package/src/hooks/use_features.ts +1 -0
  74. package/src/navigation/index.tsx +19 -1
  75. package/src/screens/conversation_details_screen.tsx +87 -22
  76. package/src/screens/conversation_notification_level_select_screen.tsx +73 -0
  77. package/src/screens/conversation_screen.tsx +18 -4
  78. package/src/screens/group_notification_level_select_screen.tsx +62 -0
  79. package/src/screens/group_notification_settings_screen.tsx +53 -18
  80. package/src/screens/notification_settings/hooks/groups.ts +76 -37
  81. package/src/screens/notification_settings_screen.tsx +24 -21
  82. package/src/types/resources/conversation.ts +2 -3
  83. package/src/types/resources/conversation_membership.ts +17 -0
  84. package/src/types/resources/group_membership.ts +7 -0
  85. package/src/types/resources/index.ts +1 -0
  86. package/src/utils/deep_snake_case_keys.ts +16 -0
@@ -1 +1 @@
1
- {"version":3,"file":"conversation_screen.js","sourceRoot":"","sources":["../../src/screens/conversation_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAE,WAAW,EAAoB,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC7F,OAAO,EACL,aAAa,EAGb,aAAa,EACb,QAAQ,IAAI,kBAAkB,EAC9B,QAAQ,GACT,MAAM,0BAA0B,CAAA;AACjC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EACL,4B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,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,iCAAiC,GAAG,GAAG,EAAE;IAC7C,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAA+C,CAAA;IAE1E,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,eAAe,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAA;QAC7C,MAAM,MAAM,GAAG,eAAe,EAAE,MAAM,IAAI,EAAE,CAAA;QAC5C,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CAAC,CAAA;QAEvE,IAAI,kBAAkB;YAAE,OAAM;QAE9B,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YAC1B,OAAO,aAAa,CAAC,KAAK,CAAC;gBACzB,GAAG,KAAK;gBACR,MAAM,EAAE;oBACN,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,mBAAmB,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE;oBACvF,GAAG,MAAM;iBACV;gBACD,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC;aACvB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAA;AAC/C,CAAC,CAAA","sourcesContent":["import { date as formatDate } from '@planningcenter/datetime-fmt'\nimport { HeaderTitle, HeaderTitleProps, PlatformPressable } from '@react-navigation/elements'\nimport {\n CommonActions,\n RouteProp,\n StaticScreenProps,\n useNavigation,\n useTheme as useNavigationTheme,\n useRoute,\n} from '@react-navigation/native'\nimport moment from 'moment'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { FlatList, Platform, StyleSheet, View } from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Badge, Icon, Text } from '../components'\nimport {\n LeaderMessagesDisabledBanner,\n MemberMessagesDisabledBanner,\n} from '../components/conversation/messages_disabled_banners'\nimport { EmptyConversationBlankState } from '../components/conversation/empty_conversation_blank_state'\nimport BlankState from '../components/primitive/blank_state_primitive'\nimport { Message } from '../components/conversation/message'\nimport { MessageForm } from '../components/conversation/message_form'\nimport { TypingIndicator } from '../components/conversation/typing_indicator'\nimport { KeyboardView } from '../components/display/keyboard_view'\nimport { useTheme } from '../hooks'\nimport {\n normalizeAnalyticsMetadata,\n usePublishProductAnalyticsEvent,\n} from '../hooks/use_product_analytics'\nimport { useConversation } from '../hooks/use_conversation'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useConversationMessagesJoltEvents } from '../hooks/use_conversation_messages_jolt_events'\nimport { MessageResource } from '../types'\nimport { ConversationBadgeResource } from '../types/resources/conversation_badge'\nimport { getRelativeDateStatus } from '../utils/date'\nimport { useMarkLatestMessageRead } from '../hooks/use_mark_latest_message_read'\nimport { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../utils/styles'\nimport { useConversationJoltEvents } from '../hooks/use_conversation_jolt_events'\nimport { JumpToBottomButton } from '../components/conversation/jump_to_bottom_button'\nimport { ReplyShadowMessage } from '../components/conversation/reply_shadow_message'\nimport { availableFeatures, useFeatures } from '../hooks/use_features'\nimport { ConversationContextProvider } from '../contexts/conversation_context'\n\nexport type ConversationRouteProps = {\n conversation_id: number\n reply_root_id?: string | null\n reply_root_author_name?: string\n chat_group_graph_id?: string\n clear_input?: boolean\n editing_message_id?: number | null\n title?: string\n subtitle?: string\n badge?: ConversationBadgeResource\n deleted?: boolean\n}\n\nexport type ConversationScreenProps = StaticScreenProps<ConversationRouteProps>\n\nexport function ConversationScreen({ route }: ConversationScreenProps) {\n const { conversation_id, reply_root_id } = route.params\n\n const { data: conversation } = useConversation({ conversation_id })\n\n usePublishProductAnalyticsEvent('chat.mobile.conversations.show.opened', {\n reply_root_id,\n ...normalizeAnalyticsMetadata(conversation),\n })\n\n return (\n <ConversationContextProvider\n conversationId={conversation_id}\n currentPageReplyRootId={reply_root_id ?? null}\n >\n <ConversationScreenContent route={route} />\n </ConversationContextProvider>\n )\n}\n\nfunction ConversationScreenContent({ route }: ConversationScreenProps) {\n const styles = useStyles()\n const navigation = useNavigation()\n const { conversation_id, editing_message_id, reply_root_id, reply_root_author_name } =\n route.params\n const { data: conversation } = useConversation(route.params)\n const { messages, refetch, isRefetching, fetchNextPage } = useConversationMessages({\n conversation_id,\n reply_root_id,\n })\n useConversationJoltEvents({ conversationId: conversation_id })\n useConversationMessagesJoltEvents({ conversationId: conversation_id })\n useEnsureConversationsRouteExists()\n useMarkLatestMessageRead({ conversation, messages })\n const { featureEnabled } = useFeatures()\n const repliesEnabled = featureEnabled(availableFeatures.threaded_replies)\n const messagesWithSeparators = groupMessages({\n ms: messages,\n inReplyScreen: !!reply_root_id,\n repliesEnabled,\n })\n const noMessages = messagesWithSeparators.length === 0\n\n const { repliesDisabled, memberAbility, badges, title } = conversation\n const canReply = memberAbility?.canReply\n const showLeaderDisabledReplyBanner = canReply && repliesDisabled\n const canDeleteNonAuthoredMessages = memberAbility?.canDeleteNonAuthoredMessages ?? false\n const currentlyEditingMessage = messages.find(m => String(m.id) === String(editing_message_id))\n const replyRootAuthorFirstName = reply_root_author_name?.split(' ')[0]\n const replyHeaderTitle = replyRootAuthorFirstName\n ? `Reply to ${replyRootAuthorFirstName}`\n : 'Reply'\n\n const listRef = useRef<FlatList>(null)\n const [showJumpToBottomButton, setShowJumpToBottomButton] = useState(false)\n\n const trackScroll = (event: any) => {\n const offsetY = event.nativeEvent.contentOffset.y\n setShowJumpToBottomButton(offsetY > 200)\n }\n\n const handleReturnToBottom = useCallback(() => {\n listRef.current?.scrollToOffset({\n offset: 0,\n })\n }, [])\n\n useEffect(() => {\n if (reply_root_id) {\n navigation.setParams({\n title: replyHeaderTitle,\n })\n } else {\n navigation.setParams({\n title: title,\n badge: badges?.[0],\n deleted: conversation?.deleted,\n })\n }\n }, [navigation, title, badges, conversation?.deleted, reply_root_id, replyHeaderTitle])\n\n if (!conversation || conversation.deleted) {\n return (\n <View style={styles.container}>\n <BlankState.Root>\n <BlankState.Imagery name=\"general.outlinedTextMessage\" />\n <BlankState.Content>\n <BlankState.Heading>This conversation has been deleted</BlankState.Heading>\n </BlankState.Content>\n <BlankState.Button\n onPress={navigation.goBack}\n title=\"Back to conversations\"\n accessibilityHint=\"Navigates back to the conversations list\"\n accessibilityRole=\"link\"\n />\n </BlankState.Root>\n </View>\n )\n }\n\n return (\n <View style={styles.container}>\n <KeyboardView>\n {noMessages ? (\n <EmptyConversationBlankState />\n ) : (\n <FlatList\n inverted\n ref={listRef}\n contentContainerStyle={styles.listContainer}\n refreshing={isRefetching}\n onRefresh={refetch}\n data={messagesWithSeparators}\n keyExtractor={item => item.id}\n onScroll={trackScroll}\n scrollEventThrottle={10}\n renderItem={({ item }) => {\n if (item.type === 'DateSeparator') {\n return <InlineDateSeparator {...item} />\n }\n\n if (item.type === 'ReplyShadowMessage') {\n return (\n <ReplyShadowMessage\n {...item}\n conversation_id={conversation_id}\n inReplyScreen={!!reply_root_id}\n />\n )\n }\n\n return (\n <Message\n {...item}\n canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages}\n conversation_id={conversation_id}\n latestReadMessageSortKey={conversation?.latestReadMessageSortKey}\n inReplyScreen={!!reply_root_id}\n repliesEnabled={repliesEnabled}\n />\n )\n }}\n onEndReached={() => fetchNextPage()}\n ListHeaderComponent={<View style={styles.listHeader} />}\n />\n )}\n <JumpToBottomButton onPress={handleReturnToBottom} visible={showJumpToBottomButton} />\n {!noMessages && <TypingIndicator />}\n {showLeaderDisabledReplyBanner && <LeaderMessagesDisabledBanner />}\n {canReply ? (\n <MessageForm.Root\n replyRootAuthorFirstName={replyRootAuthorFirstName}\n conversation={conversation}\n replyRootId={reply_root_id}\n currentlyEditingMessage={currentlyEditingMessage}\n // We use a separate key so that it remounts component when switching between new\n // and edit message. This simplifies internal state handling.\n key={\n currentlyEditingMessage\n ? `edit-message-form-${currentlyEditingMessage.id}`\n : 'new-message-form'\n }\n >\n <MessageForm.AttachmentPicker />\n <MessageForm.Commands />\n <MessageForm.TextInput />\n <MessageForm.SubmitButton />\n </MessageForm.Root>\n ) : (\n <MemberMessagesDisabledBanner />\n )}\n </KeyboardView>\n </View>\n )\n}\n\nexport type DateSeparator = { type: 'DateSeparator'; id: string; date: string }\n\nfunction InlineDateSeparator({ date }: DateSeparator) {\n const styles = useDateSeparatorStyles()\n const { isThisYear } = getRelativeDateStatus(date)\n const showYear = !isThisYear\n const dateStamp = formatDate(date, { style: 'long', year: showYear })\n\n return (\n <View style={styles.container}>\n <View style={styles.separator} />\n <Text variant=\"footnote\" style={styles.dateText}>\n {dateStamp}\n </Text>\n <View style={styles.separator} />\n </View>\n )\n}\n\nconst useDateSeparatorStyles = () => {\n const theme = useTheme()\n return StyleSheet.create({\n container: {\n alignItems: 'center',\n flexDirection: 'row',\n paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,\n paddingVertical: 16,\n },\n separator: {\n flex: 1,\n height: 1,\n borderTopWidth: 1,\n borderTopColor: theme.colors.borderColorDefaultBase,\n },\n dateText: {\n paddingHorizontal: 8,\n },\n })\n}\n\ntype ReplyShadowMessage = {\n type: 'ReplyShadowMessage'\n id: string\n messageId: string\n isReplyShadowMessage: boolean\n nextRendersAuthor: boolean\n}\n\ninterface GroupMessagesProps {\n ms: MessageResource[]\n inReplyScreen?: boolean\n repliesEnabled?: boolean\n}\n\nexport const groupMessages = ({\n ms,\n inReplyScreen,\n repliesEnabled = false,\n}: GroupMessagesProps) => {\n let enrichedMessages: (MessageResource | DateSeparator | ReplyShadowMessage)[] = []\n let encounteredOneOfMyMessages = false\n\n ms.forEach((message, i) => {\n const prevMessage = ms[i + 1]\n const nextMessage = ms[i - 1]\n const date = moment(message.createdAt).format('YYYY-MM-DD')\n const inThread = message.replyRootId !== null\n const nextMessageInThread = nextMessage?.replyRootId !== null\n const threadRoot = message.replyRootId === message.id\n const nextMessageThreadRoot = nextMessage?.replyRootId === nextMessage?.id\n const prevMessageDifferentThread = message.replyRootId !== prevMessage?.replyRootId\n const nextMessageDifferentThread = message.replyRootId !== nextMessage?.replyRootId\n const prevMessageDifferentAuthor = message.author?.id !== prevMessage?.author?.id\n const nextMessageDifferentAuthor = message.author?.id !== nextMessage?.author?.id\n const prevMessageMoreThan5Minutes =\n prevMessage &&\n new Date(message.createdAt).getTime() - new Date(prevMessage.createdAt).getTime() > 60000 * 5\n const nextMessageMoreThan5Minutes =\n nextMessage &&\n new Date(nextMessage.createdAt).getTime() - new Date(message.createdAt).getTime() > 60000 * 5\n const prevMessageIsDateSeparator =\n prevMessage && date !== moment(prevMessage.createdAt).format('YYYY-MM-DD')\n const nextMessageIsDateSeparator =\n nextMessage && date !== moment(nextMessage.createdAt).format('YYYY-MM-DD')\n const insertReplyShadowMessage =\n message.replyRootId &&\n !threadRoot &&\n (prevMessageDifferentThread || prevMessageIsDateSeparator)\n const lastInGroup =\n !nextMessage ||\n nextMessageDifferentAuthor ||\n nextMessageMoreThan5Minutes ||\n nextMessageDifferentThread ||\n nextMessageIsDateSeparator\n const renderAuthor =\n !message.mine &&\n (!prevMessage ||\n prevMessageDifferentAuthor ||\n prevMessageMoreThan5Minutes ||\n prevMessageDifferentThread ||\n prevMessageIsDateSeparator)\n const nextIsReplyShadowMessage =\n repliesEnabled &&\n nextMessageInThread &&\n !nextMessageThreadRoot &&\n (nextMessageDifferentThread || nextMessageIsDateSeparator)\n\n if (message.mine && !encounteredOneOfMyMessages) {\n encounteredOneOfMyMessages = true\n message.myLatestInConversation = true\n } else {\n message.myLatestInConversation = false\n }\n message.lastInGroup = lastInGroup\n message.renderAuthor = renderAuthor\n message.threadPosition = null\n message.nextRendersAuthor = nextMessage?.renderAuthor\n message.isReplyShadowMessage = false\n message.nextIsReplyShadowMessage = nextIsReplyShadowMessage\n\n if (!inReplyScreen && inThread) {\n message.prevIsMyReply = prevMessage?.mine\n message.nextIsMyReply = nextMessage?.mine\n\n const firstInThread = threadRoot\n const lastInThread = nextMessageDifferentThread || nextMessageIsDateSeparator\n\n if (firstInThread && lastInThread)\n message.threadPosition = null // ensures we don't render a connector for root replies that aren't immediately followed up a reply\n else if (firstInThread) message.threadPosition = 'first'\n else if (lastInThread) message.threadPosition = 'last'\n else message.threadPosition = 'center'\n }\n\n enrichedMessages.push(message)\n\n if (insertReplyShadowMessage && repliesEnabled) {\n enrichedMessages.push({\n type: 'ReplyShadowMessage',\n id: `${message.id}-${message.replyRootId}`,\n messageId: message.replyRootId!,\n isReplyShadowMessage: true,\n nextRendersAuthor: message?.renderAuthor,\n })\n }\n\n if (!prevMessage || date !== moment(prevMessage.createdAt).format('YYYY-MM-DD')) {\n enrichedMessages.push({ type: 'DateSeparator', id: `day-divider-${message.id}`, date })\n }\n })\n\n return enrichedMessages\n}\ninterface ConversationScreenTitleProps extends HeaderTitleProps {\n conversation_id: number\n badge?: ConversationBadgeResource\n deleted?: boolean\n}\n\nexport const ConversationScreenTitle = ({\n conversation_id,\n badge,\n children,\n style,\n deleted,\n}: ConversationScreenTitleProps) => {\n const styles = usePressableHeaderStyle()\n const navigation = useNavigation()\n const resourceType = badge?.pcoResourceType || ''\n const productName = badge?.appName\n const name = badge?.text || undefined\n\n return (\n <PlatformPressable\n accessibilityHint=\"Opens details about members and settings\"\n style={styles.container}\n onPress={() => {\n if (deleted) return\n\n navigation.navigate('ConversationDetails', { conversation_id })\n }}\n >\n <View style={styles.titleWrapper}>\n <HeaderTitle maxFontSizeMultiplier={1} style={style}>\n {children}\n </HeaderTitle>\n {!deleted && <Icon name=\"general.downChevron\" size={12} />}\n </View>\n <Badge\n variant=\"metaSubtle\"\n productLogoName={productName}\n label={resourceType}\n metaLabel={name}\n style={styles.badge}\n maxFontSizeMultiplier={1}\n />\n </PlatformPressable>\n )\n}\n\nconst usePressableHeaderStyle = () => {\n return StyleSheet.create({\n container: {\n alignItems: Platform.select({ android: 'flex-start', default: 'center' }),\n marginRight: Platform.select({ ios: 20, default: 16 }),\n },\n titleWrapper: {\n alignItems: 'center',\n columnGap: 4,\n flexDirection: 'row',\n flexShrink: 1,\n },\n badge: {\n alignSelf: Platform.select({ android: 'flex-start', default: 'center' }),\n marginTop: 2,\n },\n })\n}\n\nconst useStyles = () => {\n const navigationTheme = useNavigationTheme()\n const { bottom } = useSafeAreaInsets()\n\n return StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n backgroundColor: navigationTheme.colors.card,\n paddingBottom: bottom,\n },\n listContainer: {\n paddingVertical: 12,\n },\n listHeader: {\n // Just whitespace to provide space where the typing indicator can be\n height: 16,\n },\n })\n}\n\n/**\n * useEnsureConversationsRouteExists\n */\nconst useEnsureConversationsRouteExists = () => {\n const navigation = useNavigation()\n const { params } = useRoute<RouteProp<ConversationScreenProps['route']>>()\n\n useEffect(() => {\n const navigationState = navigation.getState()\n const routes = navigationState?.routes || []\n const conversationsRoute = routes.find(r => r.name === 'Conversations')\n\n if (conversationsRoute) return\n\n navigation.dispatch(state => {\n return CommonActions.reset({\n ...state,\n routes: [\n { name: 'Conversations', params: { chat_group_graph_id: params?.chat_group_graph_id } },\n ...routes,\n ],\n index: state.index + 1,\n })\n })\n }, [navigation, params?.chat_group_graph_id])\n}\n"]}
1
+ {"version":3,"file":"conversation_screen.js","sourceRoot":"","sources":["../../src/screens/conversation_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAE,WAAW,EAAoB,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC7F,OAAO,EACL,aAAa,EAGb,aAAa,EACb,QAAQ,IAAI,kBAAkB,EAC9B,QAAQ,GACT,MAAM,0BAA0B,CAAA;AACjC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,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a,CAAC,KAAK,CAAC;gBACzB,GAAG,KAAK;gBACR,MAAM,EAAE;oBACN,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,mBAAmB,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE;oBACvF,GAAG,MAAM;iBACV;gBACD,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC;aACvB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAA;AAC/C,CAAC,CAAA","sourcesContent":["import { date as formatDate } from '@planningcenter/datetime-fmt'\nimport { HeaderTitle, HeaderTitleProps, PlatformPressable } from '@react-navigation/elements'\nimport {\n CommonActions,\n RouteProp,\n StaticScreenProps,\n useNavigation,\n useTheme as useNavigationTheme,\n useRoute,\n} from '@react-navigation/native'\nimport moment from 'moment'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { FlatList, Platform, StyleSheet, View } from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Badge, Icon, Text } from '../components'\nimport {\n LeaderMessagesDisabledBanner,\n MemberMessagesDisabledBanner,\n} from '../components/conversation/messages_disabled_banners'\nimport { EmptyConversationBlankState } from '../components/conversation/empty_conversation_blank_state'\nimport BlankState from '../components/primitive/blank_state_primitive'\nimport { Message } from '../components/conversation/message'\nimport { MessageForm } from '../components/conversation/message_form'\nimport { TypingIndicator } from '../components/conversation/typing_indicator'\nimport { KeyboardView } from '../components/display/keyboard_view'\nimport { useTheme } from '../hooks'\nimport {\n normalizeAnalyticsMetadata,\n usePublishProductAnalyticsEvent,\n} from '../hooks/use_product_analytics'\nimport { useConversation } from '../hooks/use_conversation'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useConversationMessagesJoltEvents } from '../hooks/use_conversation_messages_jolt_events'\nimport { MessageResource } from '../types'\nimport { ConversationBadgeResource } from '../types/resources/conversation_badge'\nimport { getRelativeDateStatus } from '../utils/date'\nimport { useMarkLatestMessageRead } from '../hooks/use_mark_latest_message_read'\nimport { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../utils/styles'\nimport { useConversationJoltEvents } from '../hooks/use_conversation_jolt_events'\nimport { JumpToBottomButton } from '../components/conversation/jump_to_bottom_button'\nimport { ReplyShadowMessage } from '../components/conversation/reply_shadow_message'\nimport { availableFeatures, useFeatures } from '../hooks/use_features'\nimport { ConversationContextProvider } from '../contexts/conversation_context'\n\nexport type ConversationRouteProps = {\n conversation_id: number\n reply_root_id?: string | null\n reply_root_author_name?: string\n chat_group_graph_id?: string\n clear_input?: boolean\n editing_message_id?: number | null\n title?: string\n subtitle?: string\n badge?: ConversationBadgeResource\n deleted?: boolean\n muted?: boolean\n}\n\nexport type ConversationScreenProps = StaticScreenProps<ConversationRouteProps>\n\nexport function ConversationScreen({ route }: ConversationScreenProps) {\n const { conversation_id, reply_root_id } = route.params\n\n const { data: conversation } = useConversation({ conversation_id })\n\n usePublishProductAnalyticsEvent('chat.mobile.conversations.show.opened', {\n reply_root_id,\n ...normalizeAnalyticsMetadata(conversation),\n })\n\n return (\n <ConversationContextProvider\n conversationId={conversation_id}\n currentPageReplyRootId={reply_root_id ?? null}\n >\n <ConversationScreenContent route={route} />\n </ConversationContextProvider>\n )\n}\n\nfunction ConversationScreenContent({ route }: ConversationScreenProps) {\n const styles = useStyles()\n const navigation = useNavigation()\n const { conversation_id, editing_message_id, reply_root_id, reply_root_author_name } =\n route.params\n const { data: conversation } = useConversation(route.params)\n const { messages, refetch, isRefetching, fetchNextPage } = useConversationMessages({\n conversation_id,\n reply_root_id,\n })\n useConversationJoltEvents({ conversationId: conversation_id })\n useConversationMessagesJoltEvents({ conversationId: conversation_id })\n useEnsureConversationsRouteExists()\n useMarkLatestMessageRead({ conversation, messages })\n const { featureEnabled } = useFeatures()\n const repliesEnabled = featureEnabled(availableFeatures.threaded_replies)\n const messagesWithSeparators = groupMessages({\n ms: messages,\n inReplyScreen: !!reply_root_id,\n repliesEnabled,\n })\n const noMessages = messagesWithSeparators.length === 0\n\n const { repliesDisabled, memberAbility, badges, title } = conversation\n const canReply = memberAbility?.canReply\n const showLeaderDisabledReplyBanner = canReply && repliesDisabled\n const canDeleteNonAuthoredMessages = memberAbility?.canDeleteNonAuthoredMessages ?? false\n const currentlyEditingMessage = messages.find(m => String(m.id) === String(editing_message_id))\n const replyRootAuthorFirstName = reply_root_author_name?.split(' ')[0]\n const replyHeaderTitle = replyRootAuthorFirstName\n ? `Reply to ${replyRootAuthorFirstName}`\n : 'Reply'\n // Prefer the membership for optimistic updates.\n const muted = conversation.conversationMembership?.muted ?? conversation.muted\n\n const listRef = useRef<FlatList>(null)\n const [showJumpToBottomButton, setShowJumpToBottomButton] = useState(false)\n\n const trackScroll = (event: any) => {\n const offsetY = event.nativeEvent.contentOffset.y\n setShowJumpToBottomButton(offsetY > 200)\n }\n\n const handleReturnToBottom = useCallback(() => {\n listRef.current?.scrollToOffset({\n offset: 0,\n })\n }, [])\n\n useEffect(() => {\n if (reply_root_id) {\n navigation.setParams({\n title: replyHeaderTitle,\n })\n } else {\n navigation.setParams({\n title: title,\n badge: badges?.[0],\n deleted: conversation?.deleted,\n muted,\n })\n }\n }, [navigation, title, badges, conversation?.deleted, reply_root_id, replyHeaderTitle, muted])\n\n if (!conversation || conversation.deleted) {\n return (\n <View style={styles.container}>\n <BlankState.Root>\n <BlankState.Imagery name=\"general.outlinedTextMessage\" />\n <BlankState.Content>\n <BlankState.Heading>This conversation has been deleted</BlankState.Heading>\n </BlankState.Content>\n <BlankState.Button\n onPress={navigation.goBack}\n title=\"Back to conversations\"\n accessibilityHint=\"Navigates back to the conversations list\"\n accessibilityRole=\"link\"\n />\n </BlankState.Root>\n </View>\n )\n }\n\n return (\n <View style={styles.container}>\n <KeyboardView>\n {noMessages ? (\n <EmptyConversationBlankState />\n ) : (\n <FlatList\n inverted\n ref={listRef}\n contentContainerStyle={styles.listContainer}\n refreshing={isRefetching}\n onRefresh={refetch}\n data={messagesWithSeparators}\n keyExtractor={item => item.id}\n onScroll={trackScroll}\n scrollEventThrottle={10}\n renderItem={({ item }) => {\n if (item.type === 'DateSeparator') {\n return <InlineDateSeparator {...item} />\n }\n\n if (item.type === 'ReplyShadowMessage') {\n return (\n <ReplyShadowMessage\n {...item}\n conversation_id={conversation_id}\n inReplyScreen={!!reply_root_id}\n />\n )\n }\n\n return (\n <Message\n {...item}\n canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages}\n conversation_id={conversation_id}\n latestReadMessageSortKey={conversation?.latestReadMessageSortKey}\n inReplyScreen={!!reply_root_id}\n repliesEnabled={repliesEnabled}\n />\n )\n }}\n onEndReached={() => fetchNextPage()}\n ListHeaderComponent={<View style={styles.listHeader} />}\n />\n )}\n <JumpToBottomButton onPress={handleReturnToBottom} visible={showJumpToBottomButton} />\n {!noMessages && <TypingIndicator />}\n {showLeaderDisabledReplyBanner && <LeaderMessagesDisabledBanner />}\n {canReply ? (\n <MessageForm.Root\n replyRootAuthorFirstName={replyRootAuthorFirstName}\n conversation={conversation}\n replyRootId={reply_root_id}\n currentlyEditingMessage={currentlyEditingMessage}\n // We use a separate key so that it remounts component when switching between new\n // and edit message. This simplifies internal state handling.\n key={\n currentlyEditingMessage\n ? `edit-message-form-${currentlyEditingMessage.id}`\n : 'new-message-form'\n }\n >\n <MessageForm.AttachmentPicker />\n <MessageForm.Commands />\n <MessageForm.TextInput />\n <MessageForm.SubmitButton />\n </MessageForm.Root>\n ) : (\n <MemberMessagesDisabledBanner />\n )}\n </KeyboardView>\n </View>\n )\n}\n\nexport type DateSeparator = { type: 'DateSeparator'; id: string; date: string }\n\nfunction InlineDateSeparator({ date }: DateSeparator) {\n const styles = useDateSeparatorStyles()\n const { isThisYear } = getRelativeDateStatus(date)\n const showYear = !isThisYear\n const dateStamp = formatDate(date, { style: 'long', year: showYear })\n\n return (\n <View style={styles.container}>\n <View style={styles.separator} />\n <Text variant=\"footnote\" style={styles.dateText}>\n {dateStamp}\n </Text>\n <View style={styles.separator} />\n </View>\n )\n}\n\nconst useDateSeparatorStyles = () => {\n const theme = useTheme()\n return StyleSheet.create({\n container: {\n alignItems: 'center',\n flexDirection: 'row',\n paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,\n paddingVertical: 16,\n },\n separator: {\n flex: 1,\n height: 1,\n borderTopWidth: 1,\n borderTopColor: theme.colors.borderColorDefaultBase,\n },\n dateText: {\n paddingHorizontal: 8,\n },\n })\n}\n\ntype ReplyShadowMessage = {\n type: 'ReplyShadowMessage'\n id: string\n messageId: string\n isReplyShadowMessage: boolean\n nextRendersAuthor: boolean\n}\n\ninterface GroupMessagesProps {\n ms: MessageResource[]\n inReplyScreen?: boolean\n repliesEnabled?: boolean\n}\n\nexport const groupMessages = ({\n ms,\n inReplyScreen,\n repliesEnabled = false,\n}: GroupMessagesProps) => {\n let enrichedMessages: (MessageResource | DateSeparator | ReplyShadowMessage)[] = []\n let encounteredOneOfMyMessages = false\n\n ms.forEach((message, i) => {\n const prevMessage = ms[i + 1]\n const nextMessage = ms[i - 1]\n const date = moment(message.createdAt).format('YYYY-MM-DD')\n const inThread = message.replyRootId !== null\n const nextMessageInThread = nextMessage?.replyRootId !== null\n const threadRoot = message.replyRootId === message.id\n const nextMessageThreadRoot = nextMessage?.replyRootId === nextMessage?.id\n const prevMessageDifferentThread = message.replyRootId !== prevMessage?.replyRootId\n const nextMessageDifferentThread = message.replyRootId !== nextMessage?.replyRootId\n const prevMessageDifferentAuthor = message.author?.id !== prevMessage?.author?.id\n const nextMessageDifferentAuthor = message.author?.id !== nextMessage?.author?.id\n const prevMessageMoreThan5Minutes =\n prevMessage &&\n new Date(message.createdAt).getTime() - new Date(prevMessage.createdAt).getTime() > 60000 * 5\n const nextMessageMoreThan5Minutes =\n nextMessage &&\n new Date(nextMessage.createdAt).getTime() - new Date(message.createdAt).getTime() > 60000 * 5\n const prevMessageIsDateSeparator =\n prevMessage && date !== moment(prevMessage.createdAt).format('YYYY-MM-DD')\n const nextMessageIsDateSeparator =\n nextMessage && date !== moment(nextMessage.createdAt).format('YYYY-MM-DD')\n const insertReplyShadowMessage =\n message.replyRootId &&\n !threadRoot &&\n (prevMessageDifferentThread || prevMessageIsDateSeparator)\n const lastInGroup =\n !nextMessage ||\n nextMessageDifferentAuthor ||\n nextMessageMoreThan5Minutes ||\n nextMessageDifferentThread ||\n nextMessageIsDateSeparator\n const renderAuthor =\n !message.mine &&\n (!prevMessage ||\n prevMessageDifferentAuthor ||\n prevMessageMoreThan5Minutes ||\n prevMessageDifferentThread ||\n prevMessageIsDateSeparator)\n const nextIsReplyShadowMessage =\n repliesEnabled &&\n nextMessageInThread &&\n !nextMessageThreadRoot &&\n (nextMessageDifferentThread || nextMessageIsDateSeparator)\n\n if (message.mine && !encounteredOneOfMyMessages) {\n encounteredOneOfMyMessages = true\n message.myLatestInConversation = true\n } else {\n message.myLatestInConversation = false\n }\n message.lastInGroup = lastInGroup\n message.renderAuthor = renderAuthor\n message.threadPosition = null\n message.nextRendersAuthor = nextMessage?.renderAuthor\n message.isReplyShadowMessage = false\n message.nextIsReplyShadowMessage = nextIsReplyShadowMessage\n\n if (!inReplyScreen && inThread) {\n message.prevIsMyReply = prevMessage?.mine\n message.nextIsMyReply = nextMessage?.mine\n\n const firstInThread = threadRoot\n const lastInThread = nextMessageDifferentThread || nextMessageIsDateSeparator\n\n if (firstInThread && lastInThread)\n message.threadPosition = null // ensures we don't render a connector for root replies that aren't immediately followed up a reply\n else if (firstInThread) message.threadPosition = 'first'\n else if (lastInThread) message.threadPosition = 'last'\n else message.threadPosition = 'center'\n }\n\n enrichedMessages.push(message)\n\n if (insertReplyShadowMessage && repliesEnabled) {\n enrichedMessages.push({\n type: 'ReplyShadowMessage',\n id: `${message.id}-${message.replyRootId}`,\n messageId: message.replyRootId!,\n isReplyShadowMessage: true,\n nextRendersAuthor: message?.renderAuthor,\n })\n }\n\n if (!prevMessage || date !== moment(prevMessage.createdAt).format('YYYY-MM-DD')) {\n enrichedMessages.push({ type: 'DateSeparator', id: `day-divider-${message.id}`, date })\n }\n })\n\n return enrichedMessages\n}\ninterface ConversationScreenTitleProps extends HeaderTitleProps {\n conversation_id: number\n badge?: ConversationBadgeResource\n deleted?: boolean\n muted?: boolean\n}\n\nexport const ConversationScreenTitle = ({\n conversation_id,\n badge,\n children,\n style,\n deleted,\n muted,\n}: ConversationScreenTitleProps) => {\n const styles = usePressableHeaderStyle()\n const navigation = useNavigation()\n const resourceType = badge?.pcoResourceType || ''\n const productName = badge?.appName\n const name = badge?.text || undefined\n\n return (\n <PlatformPressable\n accessibilityHint=\"Opens details about members and settings\"\n style={styles.container}\n onPress={() => {\n if (deleted) return\n\n navigation.navigate('ConversationDetails', { conversation_id })\n }}\n >\n <View style={styles.titleWrapper}>\n <View style={styles.titleTextContainer}>\n <HeaderTitle maxFontSizeMultiplier={1} style={style}>\n {children}\n </HeaderTitle>\n </View>\n {muted && <Icon name=\"general.bellMuted\" size={12} />}\n {!deleted && <Icon name=\"general.downChevron\" size={12} />}\n </View>\n <Badge\n variant=\"metaSubtle\"\n productLogoName={productName}\n label={resourceType}\n metaLabel={name}\n style={styles.badge}\n maxFontSizeMultiplier={1}\n />\n </PlatformPressable>\n )\n}\n\nconst usePressableHeaderStyle = () => {\n return StyleSheet.create({\n container: {\n alignItems: Platform.select({ android: 'flex-start', default: 'center' }),\n marginRight: Platform.select({ ios: 20, default: 16 }),\n flex: 1,\n },\n titleWrapper: {\n alignItems: 'center',\n columnGap: 4,\n flexDirection: 'row',\n flexShrink: 1,\n },\n titleTextContainer: {\n flexShrink: 1,\n minWidth: 0,\n },\n badge: {\n alignSelf: Platform.select({ android: 'flex-start', default: 'center' }),\n marginTop: 2,\n },\n })\n}\n\nconst useStyles = () => {\n const navigationTheme = useNavigationTheme()\n const { bottom } = useSafeAreaInsets()\n\n return StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n backgroundColor: navigationTheme.colors.card,\n paddingBottom: bottom,\n },\n listContainer: {\n paddingVertical: 12,\n },\n listHeader: {\n // Just whitespace to provide space where the typing indicator can be\n height: 16,\n },\n })\n}\n\n/**\n * useEnsureConversationsRouteExists\n */\nconst useEnsureConversationsRouteExists = () => {\n const navigation = useNavigation()\n const { params } = useRoute<RouteProp<ConversationScreenProps['route']>>()\n\n useEffect(() => {\n const navigationState = navigation.getState()\n const routes = navigationState?.routes || []\n const conversationsRoute = routes.find(r => r.name === 'Conversations')\n\n if (conversationsRoute) return\n\n navigation.dispatch(state => {\n return CommonActions.reset({\n ...state,\n routes: [\n { name: 'Conversations', params: { chat_group_graph_id: params?.chat_group_graph_id } },\n ...routes,\n ],\n index: state.index + 1,\n })\n })\n }, [navigation, params?.chat_group_graph_id])\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { StaticScreenProps } from '@react-navigation/native';
2
+ import React from 'react';
3
+ export declare const GroupNotificationLevelSelectScreenOptions: import("@react-navigation/native-stack").NativeStackNavigationOptions;
4
+ export type GroupNotificationLevelSelectScreenProps = StaticScreenProps<{
5
+ groupId: number | string;
6
+ }>;
7
+ export declare function GroupNotificationLevelSelectScreen({ route, }: GroupNotificationLevelSelectScreenProps): React.JSX.Element;
8
+ //# sourceMappingURL=group_notification_level_select_screen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group_notification_level_select_screen.d.ts","sourceRoot":"","sources":["../../src/screens/group_notification_level_select_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,eAAO,MAAM,yCAAyC,uEAGpD,CAAA;AAEF,MAAM,MAAM,uCAAuC,GAAG,iBAAiB,CAAC;IACtE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CACzB,CAAC,CAAA;AAEF,wBAAgB,kCAAkC,CAAC,EACjD,KAAK,GACN,EAAE,uCAAuC,qBA+BzC"}
@@ -0,0 +1,40 @@
1
+ import { useNavigation } from '@react-navigation/native';
2
+ import React from 'react';
3
+ import { StyleSheet } from 'react-native';
4
+ import { PressableRow } from '../components';
5
+ import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet';
6
+ import { useTheme } from '../hooks';
7
+ import { useGroup, useGroupMembershipUpdate } from './notification_settings/hooks/groups';
8
+ export const GroupNotificationLevelSelectScreenOptions = getFormSheetScreenOptions({
9
+ headerTitle: 'Notification level',
10
+ sheetAllowedDetents: [0.35],
11
+ });
12
+ export function GroupNotificationLevelSelectScreen({ route, }) {
13
+ const { groupId } = route.params;
14
+ const navigation = useNavigation();
15
+ const styles = useStyles();
16
+ const { colors } = useTheme();
17
+ const { data: group } = useGroup({ groupId });
18
+ const { mutate: updateNotificationLevel } = useGroupMembershipUpdate({ groupId });
19
+ const notificationLevelOptions = group.myGroupMembership?.notificationLevelOptions ?? [];
20
+ const handleSelect = (value, isActive) => {
21
+ if (!isActive) {
22
+ updateNotificationLevel({ notificationLevel: value });
23
+ }
24
+ navigation.goBack();
25
+ };
26
+ return (<FormSheet.Root contentStyle={styles.content}>
27
+ {notificationLevelOptions.map(option => (<PressableRow key={option.value} text={option.description} isActive={option.enabled} onPress={() => handleSelect(option.value, option.enabled)} iconColor={colors.statusSuccessIcon} style={styles.row}/>))}
28
+ </FormSheet.Root>);
29
+ }
30
+ const useStyles = () => {
31
+ return StyleSheet.create({
32
+ content: {
33
+ paddingTop: 20,
34
+ },
35
+ row: {
36
+ borderBottomWidth: 0,
37
+ },
38
+ });
39
+ };
40
+ //# sourceMappingURL=group_notification_level_select_screen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group_notification_level_select_screen.js","sourceRoot":"","sources":["../../src/screens/group_notification_level_select_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,E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C;MAAA,CAAC,wBAAwB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CACtC,CAAC,YAAY,CACX,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAClB,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CACzB,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CACzB,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAC1D,SAAS,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CACpC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAClB,CACH,CAAC,CACJ;IAAA,EAAE,SAAS,CAAC,IAAI,CAAC,CAClB,CAAA;AACH,CAAC;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,OAAO,EAAE;YACP,UAAU,EAAE,EAAE;SACf;QACD,GAAG,EAAE;YACH,iBAAiB,EAAE,CAAC;SACrB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { StaticScreenProps, useNavigation } from '@react-navigation/native'\nimport React from 'react'\nimport { StyleSheet } from 'react-native'\nimport { PressableRow } from '../components'\nimport FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'\nimport { useTheme } from '../hooks'\nimport { useGroup, useGroupMembershipUpdate } from './notification_settings/hooks/groups'\n\nexport const GroupNotificationLevelSelectScreenOptions = getFormSheetScreenOptions({\n headerTitle: 'Notification level',\n sheetAllowedDetents: [0.35],\n})\n\nexport type GroupNotificationLevelSelectScreenProps = StaticScreenProps<{\n groupId: number | string\n}>\n\nexport function GroupNotificationLevelSelectScreen({\n route,\n}: GroupNotificationLevelSelectScreenProps) {\n const { groupId } = route.params\n const navigation = useNavigation()\n const styles = useStyles()\n const { colors } = useTheme()\n const { data: group } = useGroup({ groupId })\n const { mutate: updateNotificationLevel } = useGroupMembershipUpdate({ groupId })\n\n const notificationLevelOptions = group.myGroupMembership?.notificationLevelOptions ?? []\n\n const handleSelect = (value: string, isActive: boolean) => {\n if (!isActive) {\n updateNotificationLevel({ notificationLevel: value })\n }\n navigation.goBack()\n }\n\n return (\n <FormSheet.Root contentStyle={styles.content}>\n {notificationLevelOptions.map(option => (\n <PressableRow\n key={option.value}\n text={option.description}\n isActive={option.enabled}\n onPress={() => handleSelect(option.value, option.enabled)}\n iconColor={colors.statusSuccessIcon}\n style={styles.row}\n />\n ))}\n </FormSheet.Root>\n )\n}\n\nconst useStyles = () => {\n return StyleSheet.create({\n content: {\n paddingTop: 20,\n },\n row: {\n borderBottomWidth: 0,\n },\n })\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"group_notification_settings_screen.d.ts","sourceRoot":"","sources":["../../src/screens/group_notification_settings_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAoB,MAAM,OAAO,CAAA;AAOxC,MAAM,MAAM,oCAAoC,GAAG,iBAAiB,CAAC;IACnE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;CACd,CAAC,CAAA;AAEF,wBAAgB,+BAA+B,CAAC,EAAE,KAAK,EAAE,EAAE,oCAAoC,qBAuC9F"}
1
+ {"version":3,"file":"group_notification_settings_screen.d.ts","sourceRoot":"","sources":["../../src/screens/group_notification_settings_screen.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,0BAA0B,CAAA;AAE3E,OAAO,KAAoB,MAAM,OAAO,CAAA;AAYxC,MAAM,MAAM,oCAAoC,GAAG,iBAAiB,CAAC;IACnE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;CACd,CAAC,CAAA;AAEF,wBAAgB,+BAA+B,CAAC,EAAE,KAAK,EAAE,EAAE,oCAAoC,qBA0D9F"}
@@ -1,25 +1,24 @@
1
+ import { PlatformPressable } from '@react-navigation/elements';
1
2
  import { useNavigation } from '@react-navigation/native';
2
3
  import React, { useEffect } from 'react';
3
- import { StyleSheet, View } from 'react-native';
4
- import { Heading, Switch, Text } from '../components';
4
+ import { Platform, StyleSheet, View } from 'react-native';
5
+ import { Heading, Icon, Text } from '../components';
5
6
  import { useTheme } from '../hooks';
6
7
  import { platformFontWeightBold } from '../utils/styles';
7
- import { useGroup, useGroupMembershipUpdate } from './notification_settings/hooks/groups';
8
+ import { useGroup } from './notification_settings/hooks/groups';
8
9
  export function GroupNotificationSettingsScreen({ route }) {
9
10
  const { groupId, title } = route.params;
10
11
  const navigation = useNavigation();
11
12
  const styles = useStyles();
12
13
  const { data: group } = useGroup({ groupId });
13
- const { mutate: updateNotificationLevel } = useGroupMembershipUpdate({ groupId });
14
- const notificationsEnabled = group.myGroupMembership?.notificationLevel === 'everything';
14
+ const notificationLevelDescription = group.myGroupMembership?.notificationLevelDescription;
15
15
  useEffect(() => {
16
16
  if (!group.name || title === group.name)
17
17
  return;
18
18
  navigation.setOptions({ title: group.name });
19
19
  }, [group.name, title, navigation]);
20
- const handleToggle = (value) => {
21
- const notificationLevel = value ? 'everything' : 'nothing';
22
- updateNotificationLevel(notificationLevel);
20
+ const handleOpenSelector = () => {
21
+ navigation.navigate('GroupNotificationLevelSelect', { groupId });
23
22
  };
24
23
  return (<View style={styles.container}>
25
24
  <View style={styles.sectionOuter}>
@@ -33,10 +32,15 @@ export function GroupNotificationSettingsScreen({ route }) {
33
32
  </Text>
34
33
  </View>
35
34
  </View>
36
- <View style={styles.settingRow}>
37
- <Text>Enable notifications</Text>
38
- <Switch value={notificationsEnabled} onValueChange={handleToggle}/>
39
- </View>
35
+ <PlatformPressable style={styles.settingRowPressable} onPress={handleOpenSelector} accessibilityRole="button" accessibilityLabel="Notify me for" accessibilityHint={`Currently set to ${notificationLevelDescription}. Tap to change.`}>
36
+ <View style={styles.settingRowInner}>
37
+ <View style={styles.settingRowText}>
38
+ <Text>Notify me for</Text>
39
+ {Boolean(notificationLevelDescription) && (<Text variant="tertiary">{notificationLevelDescription}</Text>)}
40
+ </View>
41
+ {Platform.OS === 'ios' && (<Icon name="general.rightChevron" size={16} style={styles.chevron} accessibilityElementsHidden/>)}
42
+ </View>
43
+ </PlatformPressable>
40
44
  </View>);
41
45
  }
42
46
  const useStyles = () => {
@@ -52,7 +56,7 @@ const useStyles = () => {
52
56
  },
53
57
  sectionInner: {
54
58
  paddingRight: 16,
55
- paddingTop: 16,
59
+ paddingTop: 24,
56
60
  paddingBottom: 12,
57
61
  borderBottomWidth: 1,
58
62
  borderBottomColor: colors.borderColorDefaultBase,
@@ -66,13 +70,22 @@ const useStyles = () => {
66
70
  groupNameBold: {
67
71
  fontWeight: platformFontWeightBold,
68
72
  },
69
- settingRow: {
73
+ settingRowPressable: {
74
+ paddingLeft: 16,
75
+ },
76
+ settingRowInner: {
70
77
  flexDirection: 'row',
71
- justifyContent: 'space-between',
72
78
  alignItems: 'center',
73
- paddingHorizontal: 16,
79
+ justifyContent: 'space-between',
80
+ paddingRight: 16,
74
81
  paddingVertical: 12,
75
- backgroundColor: colors.surfaceColor100,
82
+ },
83
+ settingRowText: {
84
+ flex: 1,
85
+ gap: 2,
86
+ },
87
+ chevron: {
88
+ color: colors.iconColorDefaultDisabled,
76
89
  },
77
90
  });
78
91
  };
@@ -1 +1 @@
1
- {"version":3,"file":"group_notification_settings_screen.js","sourceRoot":"","sources":["../../src/screens/group_notification_settings_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe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Aa,EAAE,EAAE;YACjB,iBAAiB,EAAE,CAAC;YACpB,iBAAiB,EAAE,MAAM,CAAC,sBAAsB;SACjD;QACD,cAAc,EAAE;YACd,aAAa,EAAE,CAAC;SACjB;QACD,eAAe,EAAE;YACf,KAAK,EAAE,MAAM,CAAC,yBAAyB;SACxC;QACD,aAAa,EAAE;YACb,UAAU,EAAE,sBAAsB;SACnC;QACD,UAAU,EAAE;YACV,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,eAAe;YAC/B,UAAU,EAAE,QAAQ;YACpB,iBAAiB,EAAE,EAAE;YACrB,eAAe,EAAE,EAAE;YACnB,eAAe,EAAE,MAAM,CAAC,eAAe;SACxC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { StaticScreenProps, useNavigation } from '@react-navigation/native'\nimport React, { useEffect } from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { Heading, Switch, Text } from '../components'\nimport { useTheme } from '../hooks'\nimport { platformFontWeightBold } from '../utils/styles'\nimport { useGroup, useGroupMembershipUpdate } from './notification_settings/hooks/groups'\n\nexport type GroupNotificationSettingsScreenProps = StaticScreenProps<{\n groupId: number | string\n title: string\n}>\n\nexport function GroupNotificationSettingsScreen({ route }: GroupNotificationSettingsScreenProps) {\n const { groupId, title } = route.params\n const navigation = useNavigation()\n const styles = useStyles()\n const { data: group } = useGroup({ groupId })\n const { mutate: updateNotificationLevel } = useGroupMembershipUpdate({ groupId })\n\n const notificationsEnabled = group.myGroupMembership?.notificationLevel === 'everything'\n\n useEffect(() => {\n if (!group.name || title === group.name) return\n\n navigation.setOptions({ title: group.name })\n }, [group.name, title, navigation])\n\n const handleToggle = (value: boolean) => {\n const notificationLevel = value ? 'everything' : 'nothing'\n updateNotificationLevel(notificationLevel)\n }\n\n return (\n <View style={styles.container}>\n <View style={styles.sectionOuter}>\n <View style={styles.sectionInner}>\n <Heading variant=\"h3\" style={styles.sectionHeading}>\n Group notification settings\n </Heading>\n <Text variant=\"tertiary\" style={styles.sectionSubtitle}>\n The settings are applied to all conversations in{' '}\n <Text style={styles.groupNameBold}>{group.name || title}</Text>\n </Text>\n </View>\n </View>\n <View style={styles.settingRow}>\n <Text>Enable notifications</Text>\n <Switch value={notificationsEnabled} onValueChange={handleToggle} />\n </View>\n </View>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n container: {\n flex: 1,\n backgroundColor: colors.surfaceColor100,\n },\n sectionOuter: {\n paddingLeft: 16,\n backgroundColor: colors.surfaceColor100,\n },\n sectionInner: {\n paddingRight: 16,\n paddingTop: 16,\n paddingBottom: 12,\n borderBottomWidth: 1,\n borderBottomColor: colors.borderColorDefaultBase,\n },\n sectionHeading: {\n paddingBottom: 4,\n },\n sectionSubtitle: {\n color: colors.textColorDefaultSecondary,\n },\n groupNameBold: {\n fontWeight: platformFontWeightBold,\n },\n settingRow: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n paddingHorizontal: 16,\n paddingVertical: 12,\n backgroundColor: colors.surfaceColor100,\n },\n })\n}\n"]}
1
+ {"version":3,"file":"group_notification_settings_screen.js","sourceRoot":"","sources":["../../src/screens/group_notification_settings_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAqB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE3E,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAA;AAY/D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C,MAAM,CAAC;QACvB,SAAS,EAAE;YACT,IAAI,EAAE,CAAC;YACP,eAAe,EAAE,MAAM,CAAC,eAAe;SACxC;QACD,YAAY,EAAE;YACZ,WAAW,EAAE,EAAE;YACf,eAAe,EAAE,MAAM,CAAC,eAAe;SACxC;QACD,YAAY,EAAE;YACZ,YAAY,EAAE,EAAE;YAChB,UAAU,EAAE,EAAE;YACd,aAAa,EAAE,EAAE;YACjB,iBAAiB,EAAE,CAAC;YACpB,iBAAiB,EAAE,MAAM,CAAC,sBAAsB;SACjD;QACD,cAAc,EAAE;YACd,aAAa,EAAE,CAAC;SACjB;QACD,eAAe,EAAE;YACf,KAAK,EAAE,MAAM,CAAC,yBAAyB;SACxC;QACD,aAAa,EAAE;YACb,UAAU,EAAE,sBAAsB;SACnC;QACD,mBAAmB,EAAE;YACnB,WAAW,EAAE,EAAE;SAChB;QACD,eAAe,EAAE;YACf,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,eAAe;YAC/B,YAAY,EAAE,EAAE;YAChB,eAAe,EAAE,EAAE;SACpB;QACD,cAAc,EAAE;YACd,IAAI,EAAE,CAAC;YACP,GAAG,EAAE,CAAC;SACP;QACD,OAAO,EAAE;YACP,KAAK,EAAE,MAAM,CAAC,wBAAwB;SACvC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements'\nimport { StaticScreenProps, useNavigation } from '@react-navigation/native'\nimport type { NativeStackNavigationProp } from '@react-navigation/native-stack'\nimport React, { useEffect } from 'react'\nimport { Platform, StyleSheet, View } from 'react-native'\nimport { Heading, Icon, Text } from '../components'\nimport { useTheme } from '../hooks'\nimport { platformFontWeightBold } from '../utils/styles'\nimport { useGroup } from './notification_settings/hooks/groups'\nimport type { GroupNotificationLevelSelectScreenProps } from './group_notification_level_select_screen'\n\ntype GroupNotificationSettingsStackParamList = {\n GroupNotificationLevelSelect: GroupNotificationLevelSelectScreenProps['route']['params']\n}\n\nexport type GroupNotificationSettingsScreenProps = StaticScreenProps<{\n groupId: number | string\n title: string\n}>\n\nexport function GroupNotificationSettingsScreen({ route }: GroupNotificationSettingsScreenProps) {\n const { groupId, title } = route.params\n const navigation =\n useNavigation<NativeStackNavigationProp<GroupNotificationSettingsStackParamList>>()\n const styles = useStyles()\n const { data: group } = useGroup({ groupId })\n\n const notificationLevelDescription = group.myGroupMembership?.notificationLevelDescription\n\n useEffect(() => {\n if (!group.name || title === group.name) return\n\n navigation.setOptions({ title: group.name })\n }, [group.name, title, navigation])\n\n const handleOpenSelector = () => {\n navigation.navigate('GroupNotificationLevelSelect', { groupId })\n }\n\n return (\n <View style={styles.container}>\n <View style={styles.sectionOuter}>\n <View style={styles.sectionInner}>\n <Heading variant=\"h3\" style={styles.sectionHeading}>\n Group notification settings\n </Heading>\n <Text variant=\"tertiary\" style={styles.sectionSubtitle}>\n The settings are applied to all conversations in{' '}\n <Text style={styles.groupNameBold}>{group.name || title}</Text>\n </Text>\n </View>\n </View>\n <PlatformPressable\n style={styles.settingRowPressable}\n onPress={handleOpenSelector}\n accessibilityRole=\"button\"\n accessibilityLabel=\"Notify me for\"\n accessibilityHint={`Currently set to ${notificationLevelDescription}. Tap to change.`}\n >\n <View style={styles.settingRowInner}>\n <View style={styles.settingRowText}>\n <Text>Notify me for</Text>\n {Boolean(notificationLevelDescription) && (\n <Text variant=\"tertiary\">{notificationLevelDescription}</Text>\n )}\n </View>\n {Platform.OS === 'ios' && (\n <Icon\n name=\"general.rightChevron\"\n size={16}\n style={styles.chevron}\n accessibilityElementsHidden\n />\n )}\n </View>\n </PlatformPressable>\n </View>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n container: {\n flex: 1,\n backgroundColor: colors.surfaceColor100,\n },\n sectionOuter: {\n paddingLeft: 16,\n backgroundColor: colors.surfaceColor100,\n },\n sectionInner: {\n paddingRight: 16,\n paddingTop: 24,\n paddingBottom: 12,\n borderBottomWidth: 1,\n borderBottomColor: colors.borderColorDefaultBase,\n },\n sectionHeading: {\n paddingBottom: 4,\n },\n sectionSubtitle: {\n color: colors.textColorDefaultSecondary,\n },\n groupNameBold: {\n fontWeight: platformFontWeightBold,\n },\n settingRowPressable: {\n paddingLeft: 16,\n },\n settingRowInner: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n paddingRight: 16,\n paddingVertical: 12,\n },\n settingRowText: {\n flex: 1,\n gap: 2,\n },\n chevron: {\n color: colors.iconColorDefaultDisabled,\n },\n })\n}\n"]}
@@ -1,4 +1,5 @@
1
- import { ApiResource } from '../../../types';
1
+ import { InfiniteData } from '@tanstack/react-query';
2
+ import { ApiCollection, ApiResource } from '../../../types';
2
3
  import { GroupMembership, GroupResourceWithMembership } from '../../../types/resources';
3
4
  export declare const getGroupsRequestArgs: () => {
4
5
  url: string;
@@ -48,10 +49,10 @@ export declare const useGroups: () => {
48
49
  isPaused: boolean;
49
50
  isRefetching: boolean;
50
51
  isStale: boolean;
51
- refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("../../../types").ApiCollection<GroupResourceWithMembership>, unknown>, Response>>;
52
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<InfiniteData<ApiCollection<GroupResourceWithMembership>, unknown>, Response>>;
52
53
  fetchStatus: import("@tanstack/react-query").FetchStatus;
53
- fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("../../../types").ApiCollection<GroupResourceWithMembership>, unknown>, Response>>;
54
- fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("../../../types").ApiCollection<GroupResourceWithMembership>, unknown>, Response>>;
54
+ fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<InfiniteData<ApiCollection<GroupResourceWithMembership>, unknown>, Response>>;
55
+ fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<InfiniteData<ApiCollection<GroupResourceWithMembership>, unknown>, Response>>;
55
56
  hasNextPage: boolean;
56
57
  hasPreviousPage: boolean;
57
58
  isFetchNextPageError: boolean;
@@ -90,5 +91,5 @@ export declare const useGroup: ({ groupId }: {
90
91
  };
91
92
  export declare const useGroupMembershipUpdate: ({ groupId }: {
92
93
  groupId: number | string;
93
- }) => import("@tanstack/react-query").UseMutationResult<ApiResource<GroupMembership>, Error, string, void>;
94
+ }) => import("@tanstack/react-query").UseMutationResult<ApiResource<GroupMembership>, Error, Partial<GroupMembership>, void>;
94
95
  //# sourceMappingURL=groups.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"groups.d.ts","sourceRoot":"","sources":["../../../../src/screens/notification_settings/hooks/groups.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AAGvF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;CAY/B,CAAA;AAEF,eAAO,MAAM,mBAAmB,gBAAiB;IAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE;;;;;;;;;CAS3E,CAAA;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIrB,CAAA;AAED,eAAO,MAAM,QAAQ,gBAAiB;IAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;CAIjE,CAAA;AAED,eAAO,MAAM,wBAAwB,gBAAiB;IAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,yGAwDjF,CAAA"}
1
+ {"version":3,"file":"groups.d.ts","sourceRoot":"","sources":["../../../../src/screens/notification_settings/hooks/groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA+B,MAAM,uBAAuB,CAAA;AAIjF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AAIvF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;CAgB/B,CAAA;AAEF,eAAO,MAAM,mBAAmB,gBAAiB;IAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE;;;;;;;;;CAa3E,CAAA;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIrB,CAAA;AAED,eAAO,MAAM,QAAQ,gBAAiB;IAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;CAIjE,CAAA;AAID,eAAO,MAAM,wBAAwB,gBAAiB;IAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,2HAmFjF,CAAA"}
@@ -1,7 +1,9 @@
1
1
  import { useMutation, useQueryClient } from '@tanstack/react-query';
2
+ import { merge } from 'lodash';
2
3
  import { getRequestQueryKey, useApiClient } from '../../../hooks';
3
4
  import { useSuspenseGet, useSuspensePaginator } from '../../../hooks';
4
5
  import { throwResponseError } from '../../../utils/response_error';
6
+ import { updateRecordInPagesData } from '../../../utils';
5
7
  export const getGroupsRequestArgs = () => ({
6
8
  url: '/me/groups',
7
9
  data: {
@@ -10,7 +12,11 @@ export const getGroupsRequestArgs = () => ({
10
12
  filter: 'user_settable_notification_level',
11
13
  fields: {
12
14
  Group: [],
13
- GroupMembership: ['notification_level', 'notification_level_description'],
15
+ GroupMembership: [
16
+ 'notification_level',
17
+ 'notification_level_description',
18
+ 'notification_level_options',
19
+ ],
14
20
  },
15
21
  order: 'name',
16
22
  },
@@ -21,7 +27,11 @@ export const getGroupRequestArgs = ({ groupId }) => ({
21
27
  include: ['my_group_membership'],
22
28
  fields: {
23
29
  Group: ['name', 'source_app_name', 'source_type', 'my_group_membership'],
24
- GroupMembership: ['notification_level', 'notification_level_description'],
30
+ GroupMembership: [
31
+ 'notification_level',
32
+ 'notification_level_description',
33
+ 'notification_level_options',
34
+ ],
25
35
  },
26
36
  },
27
37
  });
@@ -31,48 +41,63 @@ export const useGroups = () => {
31
41
  };
32
42
  export const useGroup = ({ groupId }) => {
33
43
  const args = getGroupRequestArgs({ groupId });
34
- return useSuspenseGet(args);
44
+ return useSuspenseGet(args, { refetchOnMount: false });
35
45
  };
36
46
  export const useGroupMembershipUpdate = ({ groupId }) => {
37
47
  const apiClient = useApiClient();
38
48
  const queryClient = useQueryClient();
39
- const requestArgs = getGroupRequestArgs({ groupId });
40
- const queryKey = getRequestQueryKey(requestArgs);
49
+ const groupRequestArgs = getGroupRequestArgs({ groupId });
50
+ const groupsRequestArgs = getGroupsRequestArgs();
51
+ const groupQueryKey = getRequestQueryKey(groupRequestArgs);
52
+ const enrichGroupMembership = (membership) => {
53
+ const cachedGroup = queryClient.getQueryData(groupQueryKey);
54
+ const currentOptions = cachedGroup?.data.myGroupMembership?.notificationLevelOptions ?? [];
55
+ const { notificationLevel } = membership;
56
+ const selectedOption = notificationLevel
57
+ ? currentOptions.find(o => o.value === notificationLevel)
58
+ : undefined;
59
+ const notificationLevelDescription = membership.notificationLevelDescription ?? selectedOption?.description;
60
+ return {
61
+ ...membership,
62
+ notificationLevelDescription,
63
+ ...(notificationLevel && {
64
+ notificationLevelOptions: currentOptions.map(o => ({
65
+ ...o,
66
+ enabled: o.value === notificationLevel,
67
+ })),
68
+ }),
69
+ };
70
+ };
71
+ const updateGroupsMembershipCache = (membership) => {
72
+ queryClient.setQueryData(getRequestQueryKey(groupsRequestArgs), prev => updateRecordInPagesData({
73
+ data: prev,
74
+ record: { id: groupId },
75
+ processRecord: (_record, current) => merge({}, current, { myGroupMembership: membership }),
76
+ }));
77
+ };
78
+ const updateGroupMembershipCache = (membership) => {
79
+ queryClient.setQueryData(groupQueryKey, groupData => {
80
+ if (!groupData?.data.myGroupMembership)
81
+ return groupData;
82
+ return merge({}, groupData, { data: { myGroupMembership: membership } });
83
+ });
84
+ };
41
85
  return useMutation({
42
86
  throwOnError: true,
43
- onMutate: notificationLevel => {
44
- queryClient.setQueryData(queryKey, groupData => {
45
- if (!groupData?.data.myGroupMembership)
46
- return groupData;
47
- return {
48
- ...groupData,
49
- data: {
50
- ...groupData.data,
51
- myGroupMembership: {
52
- ...groupData.data.myGroupMembership,
53
- notificationLevel,
54
- },
55
- },
56
- };
57
- });
87
+ onMutate: membership => {
88
+ const enriched = enrichGroupMembership(membership);
89
+ updateGroupsMembershipCache(enriched);
90
+ updateGroupMembershipCache(enriched);
58
91
  },
59
92
  onSuccess: response => {
60
- queryClient.setQueryData(queryKey, groupData => {
61
- if (!groupData?.data.myGroupMembership)
62
- return groupData;
63
- return {
64
- ...groupData,
65
- data: {
66
- ...groupData.data,
67
- myGroupMembership: {
68
- ...groupData.data.myGroupMembership,
69
- ...response.data,
70
- },
71
- },
72
- };
73
- });
93
+ const enriched = enrichGroupMembership(response.data);
94
+ updateGroupsMembershipCache(enriched);
95
+ updateGroupMembershipCache(enriched);
96
+ // Updating conversations without access to the current filters
97
+ // is a hard itch to scratch so we just need to refetch.
98
+ queryClient.invalidateQueries({ queryKey: ['/me/conversations'] });
74
99
  },
75
- mutationFn: (notificationLevel) => {
100
+ mutationFn: (membership) => {
76
101
  return apiClient.chat
77
102
  .patch({
78
103
  url: `/me/groups/${groupId}/my_group_membership`,
@@ -80,7 +105,9 @@ export const useGroupMembershipUpdate = ({ groupId }) => {
80
105
  data: {
81
106
  type: 'GroupMembership',
82
107
  attributes: {
83
- notification_level: notificationLevel,
108
+ ...(membership.notificationLevel !== undefined && {
109
+ notification_level: membership.notificationLevel,
110
+ }),
84
111
  },
85
112
  },
86
113
  },
@@ -1 +1 @@
1
- {"version":3,"file":"groups.js","sourceRoot":"","sources":["../../../../src/screens/notification_settings/hooks/groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAGrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAElE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAAC,CAAC;IACzC,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE;QACJ,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,CAAC,qBAAqB,CAAC;QAChC,MAAM,EAAE,kCAAkC;QAC1C,MAAM,EAAE;YACN,KAAK,EAAE,EAAE;YACT,eAAe,EAAE,CAAC,oBAAoB,EAAE,gCAAgC,CAAC;SAC1E;QACD,KAAK,EAAE,MAAM;KACd;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAE,OAAO,EAAgC,EAAE,EAAE,CAAC,CAAC;IACjF,GAAG,EAAE,cAAc,OAAO,EAAE;IAC5B,IAAI,EAAE;QACJ,OAAO,EAAE,CAAC,qBAAqB,CAAC;QAChC,MAAM,EAAE;YACN,KAAK,EAAE,CAAC,MAAM,EAAE,iBAAiB,EAAE,aAAa,EAAE,qBAAqB,CAAC;YACxE,eAAe,EAAE,CAAC,oBAAoB,EAAE,gCAAgC,CAAC;SAC1E;KACF;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,IAAI,GAAG,oBAAoB,EAAE,CAAA;IAEnC,OAAO,oBAAoB,CAA8B,IAAI,CAAC,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B,iBAAiB,EAAE;4BACjB,GAAG,SAAS,CAAC,IAAI,CAAC,iBAAiB;4BACnC,GAAG,QAAQ,CAAC,IAAI;yBACjB;qBACF;iBACF,CAAA;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,UAAU,EAAE,CAAC,iBAAyB,EAAE,EAAE;YACxC,OAAO,SAAS,CAAC,IAAI;iBAClB,KAAK,CAA+B;gBACnC,GAAG,EAAE,cAAc,OAAO,sBAAsB;gBAChD,IAAI,EAAE;oBACJ,IAAI,EAAE;wBACJ,IAAI,EAAE,iBAAiB;wBACvB,UAAU,EAAE;4BACV,kBAAkB,EAAE,iBAAiB;yBACtC;qBACF;iBACF;aACF,CAAC;iBACD,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAC9B,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useMutation, useQueryClient } from '@tanstack/react-query'\nimport { getRequestQueryKey, useApiClient } from '../../../hooks'\nimport { useSuspenseGet, useSuspensePaginator } from '../../../hooks'\nimport { ApiResource } from '../../../types'\nimport { GroupMembership, GroupResourceWithMembership } from '../../../types/resources'\nimport { throwResponseError } from '../../../utils/response_error'\n\nexport const getGroupsRequestArgs = () => ({\n url: '/me/groups',\n data: {\n perPage: 100,\n include: ['my_group_membership'],\n filter: 'user_settable_notification_level',\n fields: {\n Group: [],\n GroupMembership: ['notification_level', 'notification_level_description'],\n },\n order: 'name',\n },\n})\n\nexport const getGroupRequestArgs = ({ groupId }: { groupId: number | string }) => ({\n url: `/me/groups/${groupId}`,\n data: {\n include: ['my_group_membership'],\n fields: {\n Group: ['name', 'source_app_name', 'source_type', 'my_group_membership'],\n GroupMembership: ['notification_level', 'notification_level_description'],\n },\n },\n})\n\nexport const useGroups = () => {\n const args = getGroupsRequestArgs()\n\n return useSuspensePaginator<GroupResourceWithMembership>(args)\n}\n\nexport const useGroup = ({ groupId }: { groupId: number | string }) => {\n const args = getGroupRequestArgs({ groupId })\n\n return useSuspenseGet<GroupResourceWithMembership>(args)\n}\n\nexport const useGroupMembershipUpdate = ({ groupId }: { groupId: number | string }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getGroupRequestArgs({ groupId })\n const queryKey = getRequestQueryKey(requestArgs)\n\n return useMutation({\n throwOnError: true,\n onMutate: notificationLevel => {\n queryClient.setQueryData<ApiResource<GroupResourceWithMembership>>(queryKey, groupData => {\n if (!groupData?.data.myGroupMembership) return groupData\n\n return {\n ...groupData,\n data: {\n ...groupData.data,\n myGroupMembership: {\n ...groupData.data.myGroupMembership,\n notificationLevel,\n },\n },\n }\n })\n },\n onSuccess: response => {\n queryClient.setQueryData<ApiResource<GroupResourceWithMembership>>(queryKey, groupData => {\n if (!groupData?.data.myGroupMembership) return groupData\n\n return {\n ...groupData,\n data: {\n ...groupData.data,\n myGroupMembership: {\n ...groupData.data.myGroupMembership,\n ...response.data,\n },\n },\n }\n })\n },\n mutationFn: (notificationLevel: string) => {\n return apiClient.chat\n .patch<ApiResource<GroupMembership>>({\n url: `/me/groups/${groupId}/my_group_membership`,\n data: {\n data: {\n type: 'GroupMembership',\n attributes: {\n notification_level: notificationLevel,\n },\n },\n },\n })\n .catch(throwResponseError)\n },\n })\n}\n"]}
1
+ {"version":3,"file":"groups.js","sourceRoot":"","sources":["../../../../src/screens/notification_settings/hooks/groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACjF,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAGrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAExD,MAAM,CAAC,MAAM,oBAAoB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wBACJ,IAAI,EAAE,iBAAiB;wBACvB,UAAU,EAAE;4BACV,GAAG,CAAC,UAAU,CAAC,iBAAiB,KAAK,SAAS,IAAI;gCAChD,kBAAkB,EAAE,UAAU,CAAC,iBAAiB;6BACjD,CAAC;yBACH;qBACF;iBACF;aACF,CAAC;iBACD,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAC9B,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { InfiniteData, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { merge } from 'lodash'\nimport { getRequestQueryKey, useApiClient } from '../../../hooks'\nimport { useSuspenseGet, useSuspensePaginator } from '../../../hooks'\nimport { ApiCollection, ApiResource } from '../../../types'\nimport { GroupMembership, GroupResourceWithMembership } from '../../../types/resources'\nimport { throwResponseError } from '../../../utils/response_error'\nimport { updateRecordInPagesData } from '../../../utils'\n\nexport const getGroupsRequestArgs = () => ({\n url: '/me/groups',\n data: {\n perPage: 100,\n include: ['my_group_membership'],\n filter: 'user_settable_notification_level',\n fields: {\n Group: [],\n GroupMembership: [\n 'notification_level',\n 'notification_level_description',\n 'notification_level_options',\n ],\n },\n order: 'name',\n },\n})\n\nexport const getGroupRequestArgs = ({ groupId }: { groupId: number | string }) => ({\n url: `/me/groups/${groupId}`,\n data: {\n include: ['my_group_membership'],\n fields: {\n Group: ['name', 'source_app_name', 'source_type', 'my_group_membership'],\n GroupMembership: [\n 'notification_level',\n 'notification_level_description',\n 'notification_level_options',\n ],\n },\n },\n})\n\nexport const useGroups = () => {\n const args = getGroupsRequestArgs()\n\n return useSuspensePaginator<GroupResourceWithMembership>(args)\n}\n\nexport const useGroup = ({ groupId }: { groupId: number | string }) => {\n const args = getGroupRequestArgs({ groupId })\n\n return useSuspenseGet<GroupResourceWithMembership>(args, { refetchOnMount: false })\n}\n\ntype GroupsQueryData = InfiniteData<ApiCollection<GroupResourceWithMembership>>\n\nexport const useGroupMembershipUpdate = ({ groupId }: { groupId: number | string }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const groupRequestArgs = getGroupRequestArgs({ groupId })\n const groupsRequestArgs = getGroupsRequestArgs()\n const groupQueryKey = getRequestQueryKey(groupRequestArgs)\n\n const enrichGroupMembership = (\n membership: Partial<GroupMembership>\n ): Partial<GroupMembership> => {\n const cachedGroup =\n queryClient.getQueryData<ApiResource<GroupResourceWithMembership>>(groupQueryKey)\n const currentOptions = cachedGroup?.data.myGroupMembership?.notificationLevelOptions ?? []\n const { notificationLevel } = membership\n const selectedOption = notificationLevel\n ? currentOptions.find(o => o.value === notificationLevel)\n : undefined\n const notificationLevelDescription =\n membership.notificationLevelDescription ?? selectedOption?.description\n\n return {\n ...membership,\n notificationLevelDescription,\n ...(notificationLevel && {\n notificationLevelOptions: currentOptions.map(o => ({\n ...o,\n enabled: o.value === notificationLevel,\n })),\n }),\n }\n }\n\n const updateGroupsMembershipCache = (membership: Partial<GroupMembership>) => {\n queryClient.setQueryData<GroupsQueryData>(getRequestQueryKey(groupsRequestArgs), prev =>\n updateRecordInPagesData({\n data: prev,\n record: { id: groupId } as GroupResourceWithMembership,\n processRecord: (_record, current) => merge({}, current, { myGroupMembership: membership }),\n })\n )\n }\n\n const updateGroupMembershipCache = (membership: Partial<GroupMembership>) => {\n queryClient.setQueryData<ApiResource<GroupResourceWithMembership>>(groupQueryKey, groupData => {\n if (!groupData?.data.myGroupMembership) return groupData\n return merge({}, groupData, { data: { myGroupMembership: membership } })\n })\n }\n\n return useMutation({\n throwOnError: true,\n onMutate: membership => {\n const enriched = enrichGroupMembership(membership)\n updateGroupsMembershipCache(enriched)\n updateGroupMembershipCache(enriched)\n },\n onSuccess: response => {\n const enriched = enrichGroupMembership(response.data)\n updateGroupsMembershipCache(enriched)\n updateGroupMembershipCache(enriched)\n\n // Updating conversations without access to the current filters\n // is a hard itch to scratch so we just need to refetch.\n queryClient.invalidateQueries({ queryKey: ['/me/conversations'] })\n },\n mutationFn: (membership: Partial<GroupMembership>) => {\n return apiClient.chat\n .patch<ApiResource<GroupMembership>>({\n url: `/me/groups/${groupId}/my_group_membership`,\n data: {\n data: {\n type: 'GroupMembership',\n attributes: {\n ...(membership.notificationLevel !== undefined && {\n notification_level: membership.notificationLevel,\n }),\n },\n },\n },\n })\n .catch(throwResponseError)\n },\n })\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"notification_settings_screen.d.ts","sourceRoot":"","sources":["../../src/screens/notification_settings_screen.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,0BAA0B,CAAA;AAE3E,OAAO,KAAiD,MAAM,OAAO,CAAA;AAiDrE,MAAM,MAAM,+BAA+B,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAA;AAEnE,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,+BAA+B,qBAiK7E"}
1
+ {"version":3,"file":"notification_settings_screen.d.ts","sourceRoot":"","sources":["../../src/screens/notification_settings_screen.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAiD,MAAM,OAAO,CAAA;AA0CrE,MAAM,MAAM,+BAA+B,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAA;AAEnE,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,+BAA+B,qBAmK7E"}