@planningcenter/chat-react-native 3.14.0-rc.3 → 3.14.0-rc.5
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/empty_conversation_blank_state.d.ts.map +1 -1
- package/build/components/conversation/empty_conversation_blank_state.js +10 -2
- package/build/components/conversation/empty_conversation_blank_state.js.map +1 -1
- package/build/components/conversations/conversation_actions.js +3 -3
- package/build/components/conversations/conversation_actions.js.map +1 -1
- package/build/components/conversations/conversations.d.ts.map +1 -1
- package/build/components/conversations/conversations.js +7 -2
- package/build/components/conversations/conversations.js.map +1 -1
- package/build/components/conversations/{action_toggle_button.d.ts → swipeable_toggle_button.d.ts} +3 -3
- package/build/components/conversations/swipeable_toggle_button.d.ts.map +1 -0
- package/build/components/conversations/{action_toggle_button.js → swipeable_toggle_button.js} +7 -3
- package/build/components/conversations/swipeable_toggle_button.js.map +1 -0
- package/build/components/display/index.d.ts +0 -1
- package/build/components/display/index.d.ts.map +1 -1
- package/build/components/display/index.js +0 -1
- package/build/components/display/index.js.map +1 -1
- package/build/components/primitive/blank_state_primitive.d.ts +38 -0
- package/build/components/primitive/blank_state_primitive.d.ts.map +1 -0
- package/build/components/primitive/blank_state_primitive.js +88 -0
- package/build/components/primitive/blank_state_primitive.js.map +1 -0
- package/build/hooks/use_conversation.d.ts.map +1 -1
- package/build/hooks/use_conversation.js +2 -0
- package/build/hooks/use_conversation.js.map +1 -1
- package/build/hooks/use_message_create_or_update.d.ts.map +1 -1
- package/build/hooks/use_message_create_or_update.js +2 -1
- package/build/hooks/use_message_create_or_update.js.map +1 -1
- package/build/screens/attachment_actions/hooks/useDeleteAttachment.d.ts.map +1 -1
- package/build/screens/attachment_actions/hooks/useDeleteAttachment.js +2 -0
- package/build/screens/attachment_actions/hooks/useDeleteAttachment.js.map +1 -1
- package/build/screens/bug_report_screen.d.ts.map +1 -1
- package/build/screens/bug_report_screen.js +13 -7
- package/build/screens/bug_report_screen.js.map +1 -1
- package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.d.ts.map +1 -1
- package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.js +8 -2
- package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.js.map +1 -1
- package/build/screens/conversation_new/components/groups_form.d.ts.map +1 -1
- package/build/screens/conversation_new/components/groups_form.js +2 -0
- package/build/screens/conversation_new/components/groups_form.js.map +1 -1
- package/build/screens/conversation_new/components/services_form.d.ts.map +1 -1
- package/build/screens/conversation_new/components/services_form.js +3 -0
- package/build/screens/conversation_new/components/services_form.js.map +1 -1
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +8 -7
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.d.ts.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.js +13 -3
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.js.map +1 -1
- package/build/screens/conversations/components/list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/list_header_component.js +2 -0
- package/build/screens/conversations/components/list_header_component.js.map +1 -1
- package/build/screens/design_system_screen.js +13 -8
- package/build/screens/design_system_screen.js.map +1 -1
- package/build/screens/message_actions_screen.d.ts.map +1 -1
- package/build/screens/message_actions_screen.js +1 -0
- package/build/screens/message_actions_screen.js.map +1 -1
- package/build/screens/send_giphy_screen.d.ts.map +1 -1
- package/build/screens/send_giphy_screen.js +10 -5
- package/build/screens/send_giphy_screen.js.map +1 -1
- package/package.json +2 -2
- package/src/components/conversation/empty_conversation_blank_state.tsx +10 -6
- package/src/components/conversations/conversation_actions.tsx +3 -3
- package/src/components/conversations/conversations.tsx +7 -2
- package/src/components/conversations/{action_toggle_button.tsx → swipeable_toggle_button.tsx} +9 -5
- package/src/components/display/index.ts +0 -1
- package/src/components/primitive/blank_state_primitive.tsx +194 -0
- package/src/hooks/use_conversation.ts +2 -0
- package/src/hooks/use_message_create_or_update.ts +3 -0
- package/src/screens/attachment_actions/hooks/useDeleteAttachment.tsx +2 -0
- package/src/screens/bug_report_screen.tsx +17 -15
- package/src/screens/conversation_filter_recipients/conversation_filter_recipients_screen.tsx +11 -2
- package/src/screens/conversation_new/components/groups_form.tsx +2 -0
- package/src/screens/conversation_new/components/services_form.tsx +2 -0
- package/src/screens/conversation_screen.tsx +13 -11
- package/src/screens/conversation_select_recipients/conversation_select_recipients_screen.tsx +17 -6
- package/src/screens/conversations/components/list_header_component.tsx +2 -0
- package/src/screens/design_system_screen.tsx +17 -13
- package/src/screens/message_actions_screen.tsx +1 -0
- package/src/screens/send_giphy_screen.tsx +10 -11
- package/build/components/conversations/action_toggle_button.d.ts.map +0 -1
- package/build/components/conversations/action_toggle_button.js.map +0 -1
- package/build/components/display/blank_state.d.ts +0 -18
- package/build/components/display/blank_state.d.ts.map +0 -1
- package/build/components/display/blank_state.js +0 -47
- package/build/components/display/blank_state.js.map +0 -1
- package/src/components/display/blank_state.tsx +0 -76
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"empty_conversation_blank_state.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/empty_conversation_blank_state.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"empty_conversation_blank_state.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/empty_conversation_blank_state.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B,mCAYvC,CAAA"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BlankState from '../primitive/blank_state_primitive';
|
|
2
2
|
export const EmptyConversationBlankState = () => {
|
|
3
|
-
return (<BlankState
|
|
3
|
+
return (<BlankState.Root>
|
|
4
|
+
<BlankState.Imagery name="general.outlinedTextMessage"/>
|
|
5
|
+
<BlankState.Content>
|
|
6
|
+
<BlankState.Heading>No messages</BlankState.Heading>
|
|
7
|
+
<BlankState.Text>
|
|
8
|
+
Conversation is hidden from everyone until you send a message.
|
|
9
|
+
</BlankState.Text>
|
|
10
|
+
</BlankState.Content>
|
|
11
|
+
</BlankState.Root>);
|
|
4
12
|
};
|
|
5
13
|
//# sourceMappingURL=empty_conversation_blank_state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"empty_conversation_blank_state.js","sourceRoot":"","sources":["../../../src/components/conversation/empty_conversation_blank_state.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"empty_conversation_blank_state.js","sourceRoot":"","sources":["../../../src/components/conversation/empty_conversation_blank_state.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,oCAAoC,CAAA;AAE3D,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,EAAE;IAC9C,OAAO,CACL,CAAC,UAAU,CAAC,IAAI,CACd;MAAA,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,6BAA6B,EACtD;MAAA,CAAC,UAAU,CAAC,OAAO,CACjB;QAAA,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC,OAAO,CACnD;QAAA,CAAC,UAAU,CAAC,IAAI,CACd;;QACF,EAAE,UAAU,CAAC,IAAI,CACnB;MAAA,EAAE,UAAU,CAAC,OAAO,CACtB;IAAA,EAAE,UAAU,CAAC,IAAI,CAAC,CACnB,CAAA;AACH,CAAC,CAAA","sourcesContent":["import BlankState from '../primitive/blank_state_primitive'\n\nexport const EmptyConversationBlankState = () => {\n return (\n <BlankState.Root>\n <BlankState.Imagery name=\"general.outlinedTextMessage\" />\n <BlankState.Content>\n <BlankState.Heading>No messages</BlankState.Heading>\n <BlankState.Text>\n Conversation is hidden from everyone until you send a message.\n </BlankState.Text>\n </BlankState.Content>\n </BlankState.Root>\n )\n}\n"]}
|
|
@@ -6,7 +6,7 @@ import { useTheme, useCreateAndroidRippleColor } from '../../hooks';
|
|
|
6
6
|
import { useConversationsMarkRead, useConversationsMute, } from '../../hooks/use_conversations_actions';
|
|
7
7
|
import { platformPressedOpacityStyle } from '../../utils';
|
|
8
8
|
import { tokens } from '../../vendor/tapestry/tokens';
|
|
9
|
-
import {
|
|
9
|
+
import { SwipeableToggleButton } from './swipeable_toggle_button';
|
|
10
10
|
export function ConversationActions({ children, conversation, style, onPress, accessibilityLabel, }) {
|
|
11
11
|
const swipeableRef = useRef(null);
|
|
12
12
|
const styles = useStyles();
|
|
@@ -95,8 +95,8 @@ function LeftActions({ isConversationEmpty, handleMute, handleLatestMessageUnrea
|
|
|
95
95
|
false: { iconName: 'general.textMessageNotifications', label: 'Mark unread' },
|
|
96
96
|
};
|
|
97
97
|
return (<View style={styles.actionButtonContainer}>
|
|
98
|
-
<
|
|
99
|
-
<
|
|
98
|
+
<SwipeableToggleButton loading={isMarkReadPending} disabled={isConversationEmpty} toggled={!read} onPress={handleLatestMessageUnread} toggleContent={latestMessageUnreadToggleContent} backgroundColor={tokens.fillColorInteractionSwipeDefault}/>
|
|
99
|
+
<SwipeableToggleButton loading={isMutedPending} toggled={muted} onPress={handleMute} toggleContent={muteToggleContent} backgroundColor={tokens.fillColorInteractionSwipeSecondary}/>
|
|
100
100
|
</View>);
|
|
101
101
|
}
|
|
102
102
|
const ACTION_BUTTON_WIDTH = 120;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation_actions.js","sourceRoot":"","sources":["../../../src/components/conversations/conversation_actions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAa,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClF,OAAO,EAEL,QAAQ,EACR,SAAS,EAET,UAAU,EACV,IAAI,GAEL,MAAM,cAAc,CAAA;AACrB,OAAO,mBAEN,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AAC9E,OAAO,EAAE,QAAQ,EAAE,2BAA2B,EAAE,MAAM,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,EAAE;KACrE,CAAA;IAEV,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,CACxC;MAAA,CAAC,kBAAkB,CACjB,OAAO,CAAC,CAAC,iBAAiB,CAAC,CAC3B,QAAQ,CAAC,CAAC,mBAAmB,CAAC,CAC9B,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CACf,OAAO,CAAC,CAAC,yBAAyB,CAAC,CACnC,aAAa,CAAC,CAAC,gCAAgC,CAAC,CAChD,eAAe,CAAC,CAAC,MAAM,CAAC,gCAAgC,CAAC,EAE3D;MAAA,CAAC,kBAAkB,CACjB,OAAO,CAAC,CAAC,cAAc,CAAC,CACxB,OAAO,CAAC,CAAC,KAAK,CAAC,CACf,OAAO,CAAC,CAAC,UAAU,CAAC,CACpB,aAAa,CAAC,CAAC,iBAAiB,CAAC,CACjC,eAAe,CAAC,CAAC,MAAM,CAAC,kCAAkC,CAAC,EAE/D;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC;AAED,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAC/B,MAAM,mBAAmB,GAAG,CAAC,CAAA;AAE7B,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAC7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,uBAAuB,EAAE;YACvB,eAAe,EAAE,MAAM,CAAC,eAAe;SACxC;QACD,qBAAqB,EAAE;YACrB,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,KAAK,EAAE,mBAAmB,GAAG,mBAAmB;YAChD,YAAY,EAAE,SAAS;SACxB;QACD,kBAAkB,EAAE;YAClB,eAAe,EAAE,MAAM,CAAC,eAAe;SACxC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React, { ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport {\n AccessibilityActionEvent,\n Platform,\n Pressable,\n StyleProp,\n StyleSheet,\n View,\n ViewStyle,\n} from 'react-native'\nimport ReanimatedSwipeable, {\n SwipeableMethods,\n} from 'react-native-gesture-handler/ReanimatedSwipeable'\nimport { useConversationsContext } from '../../contexts/conversations_context'\nimport { useTheme, useCreateAndroidRippleColor } from '../../hooks'\nimport {\n useConversationsMarkRead,\n useConversationsMute,\n} from '../../hooks/use_conversations_actions'\nimport { ConversationResource } from '../../types'\nimport { platformPressedOpacityStyle } from '../../utils'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { ActionToggleButton } from './action_toggle_button'\n\nexport function ConversationActions({\n children,\n conversation,\n style,\n onPress,\n accessibilityLabel,\n}: {\n children: ReactNode\n conversation: ConversationResource\n onPress: () => void\n style?: StyleProp<ViewStyle>\n accessibilityLabel?: string\n}) {\n const swipeableRef = useRef<SwipeableMethods>(null)\n const styles = useStyles()\n const { activeConversationId, setActiveConversationId } = useConversationsContext()\n const [disabled, setDisabled] = useState(false)\n const overshootLeft = Platform.OS === 'ios'\n const androidRippleColor = useCreateAndroidRippleColor({\n color: styles.swipeableChildContainer.backgroundColor,\n })\n const { muted, setMuted, isPending: isMutedPending } = useConversationsMute({ conversation })\n const {\n read,\n markRead,\n isPending: isMarkReadPending,\n } = useConversationsMarkRead({\n conversation,\n })\n\n const isConversationEmpty = conversation.lastMessageCreatedAt === null\n\n const handleSwipeableClose = useCallback(() => {\n setDisabled(false)\n swipeableRef.current?.close()\n }, [setDisabled])\n\n const handleSwipeableOpen = () => {\n setDisabled(true)\n setActiveConversationId(conversation.id)\n }\n\n const handlePress = useCallback(() => {\n if (disabled || !onPress) return\n onPress()\n }, [disabled, onPress])\n\n const handleMute = useCallback(() => {\n setMuted(!muted)\n handleSwipeableClose()\n }, [muted, handleSwipeableClose, setMuted])\n\n const handleLatestMessageUnread = useCallback(() => {\n markRead(!read)\n handleSwipeableClose()\n }, [read, handleSwipeableClose, markRead])\n\n const readAccessibilityAction = !isConversationEmpty\n ? [\n {\n name: read ? 'markUnread' : 'markRead',\n label: read ? 'Mark unread' : 'Mark read',\n },\n ]\n : []\n\n const accessibilityActions = [\n {\n name: muted ? 'unmute' : 'mute',\n label: muted ? 'Unmute' : 'Mute',\n },\n ...readAccessibilityAction,\n ]\n\n const handleAccessibilityAction = useCallback(\n (event: AccessibilityActionEvent) => {\n switch (event.nativeEvent.actionName) {\n case 'markRead':\n handleLatestMessageUnread()\n break\n case 'markUnread':\n handleLatestMessageUnread()\n break\n case 'mute':\n handleMute()\n break\n case 'unmute':\n handleMute()\n break\n }\n },\n [handleLatestMessageUnread, handleMute]\n )\n\n useEffect(() => {\n if (activeConversationId === conversation.id) return\n\n handleSwipeableClose()\n }, [activeConversationId, conversation.id, handleSwipeableClose])\n\n return (\n <ReanimatedSwipeable\n ref={swipeableRef}\n childrenContainerStyle={styles.swipeableChildContainer}\n containerStyle={styles.swipeableContainer}\n overshootFriction={8}\n overshootLeft={overshootLeft}\n overshootRight={false}\n onSwipeableOpenStartDrag={handleSwipeableOpen}\n onSwipeableClose={() => setDisabled(false)}\n renderRightActions={() => <></>}\n renderLeftActions={() => (\n <LeftActions\n isConversationEmpty={isConversationEmpty}\n handleMute={handleMute}\n handleLatestMessageUnread={handleLatestMessageUnread}\n muted={muted}\n read={read}\n isMutedPending={isMutedPending}\n isMarkReadPending={isMarkReadPending}\n />\n )}\n >\n <Pressable\n onPress={handlePress}\n style={({ pressed }) => [style, pressed && platformPressedOpacityStyle]}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n accessibilityLabel={accessibilityLabel}\n accessibilityRole=\"button\"\n accessibilityActions={accessibilityActions}\n onAccessibilityAction={handleAccessibilityAction}\n >\n {children}\n </Pressable>\n </ReanimatedSwipeable>\n )\n}\n\ninterface LeftActionsProps {\n isConversationEmpty: boolean\n handleMute: () => void\n handleLatestMessageUnread: () => void\n muted: boolean\n read: boolean\n isMutedPending: boolean\n isMarkReadPending: boolean\n}\n\nfunction LeftActions({\n isConversationEmpty,\n handleMute,\n handleLatestMessageUnread,\n muted,\n read,\n isMutedPending,\n isMarkReadPending,\n}: LeftActionsProps) {\n const styles = useStyles()\n\n const muteToggleContent = {\n true: { iconName: 'general.bell', label: 'Unmute' },\n false: { iconName: 'general.bellMuted', label: 'Mute' },\n } as const\n\n const latestMessageUnreadToggleContent = {\n true: { iconName: 'general.outlinedTextMessage', label: 'Mark read' },\n false: { iconName: 'general.textMessageNotifications', label: 'Mark unread' },\n } as const\n\n return (\n <View style={styles.actionButtonContainer}>\n <ActionToggleButton\n loading={isMarkReadPending}\n disabled={isConversationEmpty}\n toggled={!read}\n onPress={handleLatestMessageUnread}\n toggleContent={latestMessageUnreadToggleContent}\n backgroundColor={tokens.fillColorInteractionSwipeDefault}\n />\n <ActionToggleButton\n loading={isMutedPending}\n toggled={muted}\n onPress={handleMute}\n toggleContent={muteToggleContent}\n backgroundColor={tokens.fillColorInteractionSwipeSecondary}\n />\n </View>\n )\n}\n\nconst ACTION_BUTTON_WIDTH = 120\nconst ACTION_BUTTON_COUNT = 2\n\nconst useStyles = () => {\n const { colors } = useTheme()\n return StyleSheet.create({\n swipeableChildContainer: {\n backgroundColor: colors.surfaceColor100,\n },\n actionButtonContainer: {\n flexDirection: 'row',\n alignItems: 'center',\n width: ACTION_BUTTON_WIDTH * ACTION_BUTTON_COUNT,\n alignContent: 'stretch',\n },\n swipeableContainer: {\n backgroundColor: colors.surfaceColor090,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"conversation_actions.js","sourceRoot":"","sources":["../../../src/components/conversations/conversation_actions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAa,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClF,OAAO,EAEL,QAAQ,EACR,SAAS,EAET,UAAU,EACV,IAAI,GAEL,MAAM,cAAc,CAAA;AACrB,OAAO,mBAEN,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAAE,uBAAu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CAAA","sourcesContent":["import React, { ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport {\n AccessibilityActionEvent,\n Platform,\n Pressable,\n StyleProp,\n StyleSheet,\n View,\n ViewStyle,\n} from 'react-native'\nimport ReanimatedSwipeable, {\n SwipeableMethods,\n} from 'react-native-gesture-handler/ReanimatedSwipeable'\nimport { useConversationsContext } from '../../contexts/conversations_context'\nimport { useTheme, useCreateAndroidRippleColor } from '../../hooks'\nimport {\n useConversationsMarkRead,\n useConversationsMute,\n} from '../../hooks/use_conversations_actions'\nimport { ConversationResource } from '../../types'\nimport { platformPressedOpacityStyle } from '../../utils'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { SwipeableToggleButton } from './swipeable_toggle_button'\n\nexport function ConversationActions({\n children,\n conversation,\n style,\n onPress,\n accessibilityLabel,\n}: {\n children: ReactNode\n conversation: ConversationResource\n onPress: () => void\n style?: StyleProp<ViewStyle>\n accessibilityLabel?: string\n}) {\n const swipeableRef = useRef<SwipeableMethods>(null)\n const styles = useStyles()\n const { activeConversationId, setActiveConversationId } = useConversationsContext()\n const [disabled, setDisabled] = useState(false)\n const overshootLeft = Platform.OS === 'ios'\n const androidRippleColor = useCreateAndroidRippleColor({\n color: styles.swipeableChildContainer.backgroundColor,\n })\n const { muted, setMuted, isPending: isMutedPending } = useConversationsMute({ conversation })\n const {\n read,\n markRead,\n isPending: isMarkReadPending,\n } = useConversationsMarkRead({\n conversation,\n })\n\n const isConversationEmpty = conversation.lastMessageCreatedAt === null\n\n const handleSwipeableClose = useCallback(() => {\n setDisabled(false)\n swipeableRef.current?.close()\n }, [setDisabled])\n\n const handleSwipeableOpen = () => {\n setDisabled(true)\n setActiveConversationId(conversation.id)\n }\n\n const handlePress = useCallback(() => {\n if (disabled || !onPress) return\n onPress()\n }, [disabled, onPress])\n\n const handleMute = useCallback(() => {\n setMuted(!muted)\n handleSwipeableClose()\n }, [muted, handleSwipeableClose, setMuted])\n\n const handleLatestMessageUnread = useCallback(() => {\n markRead(!read)\n handleSwipeableClose()\n }, [read, handleSwipeableClose, markRead])\n\n const readAccessibilityAction = !isConversationEmpty\n ? [\n {\n name: read ? 'markUnread' : 'markRead',\n label: read ? 'Mark unread' : 'Mark read',\n },\n ]\n : []\n\n const accessibilityActions = [\n {\n name: muted ? 'unmute' : 'mute',\n label: muted ? 'Unmute' : 'Mute',\n },\n ...readAccessibilityAction,\n ]\n\n const handleAccessibilityAction = useCallback(\n (event: AccessibilityActionEvent) => {\n switch (event.nativeEvent.actionName) {\n case 'markRead':\n handleLatestMessageUnread()\n break\n case 'markUnread':\n handleLatestMessageUnread()\n break\n case 'mute':\n handleMute()\n break\n case 'unmute':\n handleMute()\n break\n }\n },\n [handleLatestMessageUnread, handleMute]\n )\n\n useEffect(() => {\n if (activeConversationId === conversation.id) return\n\n handleSwipeableClose()\n }, [activeConversationId, conversation.id, handleSwipeableClose])\n\n return (\n <ReanimatedSwipeable\n ref={swipeableRef}\n childrenContainerStyle={styles.swipeableChildContainer}\n containerStyle={styles.swipeableContainer}\n overshootFriction={8}\n overshootLeft={overshootLeft}\n overshootRight={false}\n onSwipeableOpenStartDrag={handleSwipeableOpen}\n onSwipeableClose={() => setDisabled(false)}\n renderRightActions={() => <></>}\n renderLeftActions={() => (\n <LeftActions\n isConversationEmpty={isConversationEmpty}\n handleMute={handleMute}\n handleLatestMessageUnread={handleLatestMessageUnread}\n muted={muted}\n read={read}\n isMutedPending={isMutedPending}\n isMarkReadPending={isMarkReadPending}\n />\n )}\n >\n <Pressable\n onPress={handlePress}\n style={({ pressed }) => [style, pressed && platformPressedOpacityStyle]}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n accessibilityLabel={accessibilityLabel}\n accessibilityRole=\"button\"\n accessibilityActions={accessibilityActions}\n onAccessibilityAction={handleAccessibilityAction}\n >\n {children}\n </Pressable>\n </ReanimatedSwipeable>\n )\n}\n\ninterface LeftActionsProps {\n isConversationEmpty: boolean\n handleMute: () => void\n handleLatestMessageUnread: () => void\n muted: boolean\n read: boolean\n isMutedPending: boolean\n isMarkReadPending: boolean\n}\n\nfunction LeftActions({\n isConversationEmpty,\n handleMute,\n handleLatestMessageUnread,\n muted,\n read,\n isMutedPending,\n isMarkReadPending,\n}: LeftActionsProps) {\n const styles = useStyles()\n\n const muteToggleContent = {\n true: { iconName: 'general.bell', label: 'Unmute' },\n false: { iconName: 'general.bellMuted', label: 'Mute' },\n } as const\n\n const latestMessageUnreadToggleContent = {\n true: { iconName: 'general.outlinedTextMessage', label: 'Mark read' },\n false: { iconName: 'general.textMessageNotifications', label: 'Mark unread' },\n } as const\n\n return (\n <View style={styles.actionButtonContainer}>\n <SwipeableToggleButton\n loading={isMarkReadPending}\n disabled={isConversationEmpty}\n toggled={!read}\n onPress={handleLatestMessageUnread}\n toggleContent={latestMessageUnreadToggleContent}\n backgroundColor={tokens.fillColorInteractionSwipeDefault}\n />\n <SwipeableToggleButton\n loading={isMutedPending}\n toggled={muted}\n onPress={handleMute}\n toggleContent={muteToggleContent}\n backgroundColor={tokens.fillColorInteractionSwipeSecondary}\n />\n </View>\n )\n}\n\nconst ACTION_BUTTON_WIDTH = 120\nconst ACTION_BUTTON_COUNT = 2\n\nconst useStyles = () => {\n const { colors } = useTheme()\n return StyleSheet.create({\n swipeableChildContainer: {\n backgroundColor: colors.surfaceColor100,\n },\n actionButtonContainer: {\n flexDirection: 'row',\n alignItems: 'center',\n width: ACTION_BUTTON_WIDTH * ACTION_BUTTON_COUNT,\n alignContent: 'stretch',\n },\n swipeableContainer: {\n backgroundColor: colors.surfaceColor090,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../../src/components/conversations/conversations.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAUtC,UAAU,kBAAkB;IAC1B,mBAAmB,CAAC,EAChB,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GACxB,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,GAClE,IAAI,GACJ,SAAS,CAAA;CACd;AAED,eAAO,MAAM,aAAa,4BAA6B,kBAAkB,
|
|
1
|
+
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../../src/components/conversations/conversations.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAUtC,UAAU,kBAAkB;IAC1B,mBAAmB,CAAC,EAChB,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GACxB,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,GAClE,IAAI,GACJ,SAAS,CAAA;CACd;AAED,eAAO,MAAM,aAAa,4BAA6B,kBAAkB,sBA8ExE,CAAA"}
|
|
@@ -5,7 +5,7 @@ import { StyleSheet, View } from 'react-native';
|
|
|
5
5
|
import { useConversationsContext } from '../../contexts/conversations_context';
|
|
6
6
|
import { useTheme } from '../../hooks';
|
|
7
7
|
import { throwResponseError } from '../../utils/response_error';
|
|
8
|
-
import
|
|
8
|
+
import BlankState from '../primitive/blank_state_primitive';
|
|
9
9
|
import { ConversationPreview, ConversationPreviewSkeleton } from './conversation_preview';
|
|
10
10
|
import { useConversationsJoltEvents } from '../../hooks/use_conversations_jolt_events';
|
|
11
11
|
export const Conversations = ({ ListHeaderComponent }) => {
|
|
@@ -29,7 +29,12 @@ export const Conversations = ({ ListHeaderComponent }) => {
|
|
|
29
29
|
useConversationsJoltEvents();
|
|
30
30
|
return (<View style={styles.container}>
|
|
31
31
|
<FlashList data={data} estimatedItemSize={97} keyExtractor={item => item.id.toString()} contentContainerStyle={styles.contentContainer} onRefresh={refetch} refreshing={!isFetched && isRefetching} ListHeaderComponent={ListHeaderComponent} ListEmptyComponent={<View style={styles.listEmpty}>
|
|
32
|
-
<BlankState
|
|
32
|
+
<BlankState.Root>
|
|
33
|
+
<BlankState.Imagery name="general.outlinedTextMessage"/>
|
|
34
|
+
<BlankState.Content>
|
|
35
|
+
<BlankState.Heading>No conversations</BlankState.Heading>
|
|
36
|
+
</BlankState.Content>
|
|
37
|
+
</BlankState.Root>
|
|
33
38
|
</View>} renderItem={({ item }) => {
|
|
34
39
|
if (item.type === 'loading') {
|
|
35
40
|
return <ConversationPreviewSkeleton />;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversations.js","sourceRoot":"","sources":["../../../src/components/conversations/conversations.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"conversations.js","sourceRoot":"","sources":["../../../src/components/conversations/conversations.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAA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,CACD,UAAU,CAAC,CAAC,UAAU,CAAC,EACvB,CACH,CAAA;YACH,CAAC;QACH,CAAC,CAAC,CACF,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC,aAAa,EAAE,CAAC,EAExC;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;QACtB,gBAAgB,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE;QACzC,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,mBAAmB,EAAE;QAC/C,SAAS,EAAE;YACT,IAAI,EAAE,CAAC;YACP,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,eAAe,EAAE,EAAE;SACpB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAaD,MAAM,kBAAkB,GAAoB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC/E,IAAI,EAAE,SAAS;IACf,EAAE,EAAE,UAAU,CAAC,EAAE;CAClB,CAAC,CAAC,CAAA","sourcesContent":["import { useNavigation } from '@react-navigation/native'\nimport { FlashList } from '@shopify/flash-list'\nimport React, { useMemo } from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { useConversationsContext } from '../../contexts/conversations_context'\nimport { useTheme } from '../../hooks'\nimport { ConversationResource } from '../../types'\nimport { throwResponseError } from '../../utils/response_error'\nimport BlankState from '../primitive/blank_state_primitive'\nimport { ConversationPreview, ConversationPreviewSkeleton } from './conversation_preview'\nimport { useConversationsJoltEvents } from '../../hooks/use_conversations_jolt_events'\n\ninterface ConversationsProps {\n ListHeaderComponent?:\n | React.ComponentType<any>\n | React.ReactElement<any, string | React.JSXElementConstructor<any>>\n | null\n | undefined\n}\n\nexport const Conversations = ({ ListHeaderComponent }: ConversationsProps) => {\n const styles = useStyles()\n const {\n conversations,\n isLoading,\n fetchNextPage,\n refetch,\n isRefetching,\n isFetched,\n isError,\n error,\n args: { chat_group_graph_id },\n } = useConversationsContext()\n const navigation = useNavigation()\n\n const showBadges = !chat_group_graph_id\n\n const data: FlashListItem[] = useMemo(() => {\n if (isLoading) {\n return loadingPlaceholder\n }\n return conversations.map(conversation => ({\n type: 'conversation' as const,\n id: conversation.id,\n resource: conversation,\n }))\n }, [conversations, isLoading])\n\n if (isError) {\n throwResponseError(error)\n }\n\n useConversationsJoltEvents()\n\n return (\n <View style={styles.container}>\n <FlashList\n data={data}\n estimatedItemSize={97}\n keyExtractor={item => item.id.toString()}\n contentContainerStyle={styles.contentContainer}\n onRefresh={refetch}\n refreshing={!isFetched && isRefetching}\n ListHeaderComponent={ListHeaderComponent}\n ListEmptyComponent={\n <View style={styles.listEmpty}>\n <BlankState.Root>\n <BlankState.Imagery name=\"general.outlinedTextMessage\" />\n <BlankState.Content>\n <BlankState.Heading>No conversations</BlankState.Heading>\n </BlankState.Content>\n </BlankState.Root>\n </View>\n }\n renderItem={({ item }) => {\n if (item.type === 'loading') {\n return <ConversationPreviewSkeleton />\n } else {\n return (\n <ConversationPreview\n conversation={item.resource}\n onPress={() =>\n navigation.navigate('Conversation', {\n conversation_id: item.resource.id,\n title: item.resource.title,\n badge: item.resource.badges?.[0],\n deleted: item.resource.deleted,\n })\n }\n showBadges={showBadges}\n />\n )\n }\n }}\n onEndReached={() => fetchNextPage()}\n />\n </View>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n container: { flex: 1 },\n contentContainer: { paddingVertical: 16 },\n listItem: { color: colors.fillColorNeutral020 },\n listEmpty: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n paddingVertical: 32,\n },\n })\n}\n\ninterface FlashListLoadingItem {\n type: 'loading'\n id: string\n}\ninterface FlashListConversationItem {\n type: 'conversation'\n resource: ConversationResource\n id: number\n}\ntype FlashListItem = FlashListLoadingItem | FlashListConversationItem\n\nconst loadingPlaceholder: FlashListItem[] = Array.from({ length: 5 }, (_, i) => ({\n type: 'loading',\n id: `loading${i}`,\n}))\n"]}
|
package/build/components/conversations/{action_toggle_button.d.ts → swipeable_toggle_button.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type PressableProps } from 'react-native-gesture-handler';
|
|
3
3
|
import { IconString } from '../display';
|
|
4
|
-
interface
|
|
4
|
+
interface SwipeableToggleButtonProps extends PressableProps {
|
|
5
5
|
backgroundColor: string;
|
|
6
6
|
toggled: boolean;
|
|
7
7
|
toggleContent: {
|
|
@@ -16,6 +16,6 @@ interface ActionToggleButtonProps extends PressableProps {
|
|
|
16
16
|
};
|
|
17
17
|
loading?: boolean;
|
|
18
18
|
}
|
|
19
|
-
export declare function
|
|
19
|
+
export declare function SwipeableToggleButton({ backgroundColor, onPress, toggleContent, disabled, toggled, loading, ...props }: SwipeableToggleButtonProps): React.JSX.Element;
|
|
20
20
|
export {};
|
|
21
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=swipeable_toggle_button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swipeable_toggle_button.d.ts","sourceRoot":"","sources":["../../../src/components/conversations/swipeable_toggle_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7E,OAAO,EAAQ,UAAU,EAAiB,MAAM,YAAY,CAAA;AAM5D,UAAU,0BAA2B,SAAQ,cAAc;IACzD,eAAe,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE;QACb,IAAI,EAAE;YAAE,QAAQ,EAAE,UAAU,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAA;QAC7C,KAAK,EAAE;YAAE,QAAQ,EAAE,UAAU,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAA;KAC/C,CAAA;IACD,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,eAAe,EACf,OAAO,EACP,aAAa,EACb,QAAgB,EAChB,OAAO,EACP,OAAe,EACf,GAAG,KAAK,EACT,EAAE,0BAA0B,qBAiC5B"}
|
package/build/components/conversations/{action_toggle_button.js → swipeable_toggle_button.js}
RENAMED
|
@@ -5,13 +5,17 @@ import { Icon, Spinner, Text } from '../display';
|
|
|
5
5
|
import { useCreateAndroidRippleColor, useTheme } from '../../hooks';
|
|
6
6
|
import { platformFontWeightMedium, platformPressedOpacityStyle } from '../../utils/styles';
|
|
7
7
|
import { tokens } from '../../vendor/tapestry/tokens';
|
|
8
|
-
|
|
8
|
+
import { Haptic } from '../../utils/native_adapters/configuration';
|
|
9
|
+
export function SwipeableToggleButton({ backgroundColor, onPress, toggleContent, disabled = false, toggled, loading = false, ...props }) {
|
|
9
10
|
const styles = useStyles({ backgroundColor, disabled });
|
|
10
11
|
const androidRippleColor = useCreateAndroidRippleColor({
|
|
11
12
|
color: backgroundColor,
|
|
12
13
|
});
|
|
13
14
|
const { iconName, label } = toggleContent[toggled ? 'true' : 'false'];
|
|
14
|
-
return (<Pressable onPress={
|
|
15
|
+
return (<Pressable onPress={event => {
|
|
16
|
+
Haptic.impactLight();
|
|
17
|
+
onPress?.(event);
|
|
18
|
+
}} style={({ pressed }) => [styles.button, pressed && platformPressedOpacityStyle]} android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }} disabled={disabled || loading} accessibilityRole="togglebutton" accessibilityState={{ checked: toggled }} {...props}>
|
|
15
19
|
{loading ? (<Spinner size={20}/>) : (<>
|
|
16
20
|
<Icon name={iconName} style={styles.icon} size={20}/>
|
|
17
21
|
<Text variant="footnote" style={styles.text}>
|
|
@@ -46,4 +50,4 @@ const useStyles = ({ backgroundColor, disabled }) => {
|
|
|
46
50
|
},
|
|
47
51
|
});
|
|
48
52
|
};
|
|
49
|
-
//# sourceMappingURL=
|
|
53
|
+
//# sourceMappingURL=swipeable_toggle_button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swipeable_toggle_button.js","sourceRoot":"","sources":["../../../src/components/conversations/swipeable_toggle_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,SAAS,EAAuB,MAAM,8BAA8B,CAAA;AAC7E,OAAO,EAAE,IAAI,EAAc,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAYlE,MAAM,UAAU,qBAAqB,CAAC,EACpC,eAAe,EACf,OAAO,EACP,aAAa,EACb,QAAQ,GAAG,KAAK,EAChB,OAAO,EACP,OAAO,GAAG,KAAK,EACf,GAAG,KAAK,EACmB;IAC3B,MAAM,MAAM,GAAG,SAAS,CAAC,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,CAAA;IACvD,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;QACrD,KAAK,EAAE,eAAe;KACvB,CAAC,CAAA;IAEF,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAErE,O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MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAA;IAC1F,MAAM,qBAAqB,GAAG,QAAQ;QACpC,CAAC,CAAC,MAAM,CAAC,mCAAmC;QAC5C,CAAC,CAAC,eAAe,CAAA;IAEnB,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,MAAM,EAAE;YACN,IAAI,EAAE,CAAC;YACP,aAAa,EAAE,QAAQ;YACvB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;YACxB,GAAG,EAAE,CAAC;YACN,MAAM,EAAE,MAAM;YACd,eAAe,EAAE,qBAAqB;SACvC;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,SAAS;YAChB,SAAS,EAAE,CAAC;SACb;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,SAAS;YAChB,UAAU,EAAE,wBAAwB;SACrC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { StyleSheet } from 'react-native'\nimport { Pressable, type PressableProps } from 'react-native-gesture-handler'\nimport { Icon, IconString, Spinner, Text } from '../display'\nimport { useCreateAndroidRippleColor, useTheme } from '../../hooks'\nimport { platformFontWeightMedium, platformPressedOpacityStyle } from '../../utils/styles'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { Haptic } from '../../utils/native_adapters/configuration'\n\ninterface SwipeableToggleButtonProps extends PressableProps {\n backgroundColor: string\n toggled: boolean\n toggleContent: {\n true: { iconName: IconString; label: string }\n false: { iconName: IconString; label: string }\n }\n loading?: boolean\n}\n\nexport function SwipeableToggleButton({\n backgroundColor,\n onPress,\n toggleContent,\n disabled = false,\n toggled,\n loading = false,\n ...props\n}: SwipeableToggleButtonProps) {\n const styles = useStyles({ backgroundColor, disabled })\n const androidRippleColor = useCreateAndroidRippleColor({\n color: backgroundColor,\n })\n\n const { iconName, label } = toggleContent[toggled ? 'true' : 'false']\n\n return (\n <Pressable\n onPress={event => {\n Haptic.impactLight()\n onPress?.(event)\n }}\n style={({ pressed }) => [styles.button, pressed && platformPressedOpacityStyle]}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n disabled={disabled || loading}\n accessibilityRole=\"togglebutton\"\n accessibilityState={{ checked: toggled }}\n {...props}\n >\n {loading ? (\n <Spinner size={20} />\n ) : (\n <>\n <Icon name={iconName} style={styles.icon} size={20} />\n <Text variant=\"footnote\" style={styles.text}>\n {label}\n </Text>\n </>\n )}\n </Pressable>\n )\n}\n\nconst useStyles = ({ backgroundColor, disabled }: Partial<SwipeableToggleButtonProps>) => {\n const { colors } = useTheme()\n const fillColor = disabled ? colors.textColorDefaultDisabled : tokens.colorNeutral100White\n const buttonBackgroundColor = disabled\n ? colors.fillColorButtonNeutralSolidDisabled\n : backgroundColor\n\n return StyleSheet.create({\n button: {\n flex: 1,\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 4,\n height: '100%',\n backgroundColor: buttonBackgroundColor,\n },\n icon: {\n color: fillColor,\n marginTop: 4,\n },\n text: {\n color: fillColor,\n fontWeight: platformFontWeightMedium,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,sBAAsB,CAAA;AACpC,cAAc,UAAU,CAAA;AACxB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,sBAAsB,CAAA;AACpC,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,QAAQ,CAAA;AACtB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,sBAAsB,CAAA;AACpC,cAAc,UAAU,CAAA;AACxB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,sBAAsB,CAAA;AACpC,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,QAAQ,CAAA;AACtB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA","sourcesContent":["export * from './avatar_group'\nexport * from './avatar'\nexport * from './badge'\nexport * from './banner_collapsible'\nexport * from './banner'\nexport * from './button'\nexport * from './child_notice'\nexport * from './heading'\nexport * from './icon_button'\nexport * from './icon'\nexport * from './image'\nexport * from './image_attachment_preview'\nexport * from './video_attachment_preview'\nexport * from './person'\nexport * from './spinner'\nexport * from './switch'\nexport * from './text_button'\nexport * from './text_inline_button'\nexport * from './text'\nexport * from './toggle_button'\nexport * from './keyboard_view'\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
3
|
+
import { type ButtonProps, type HeadingProps, type IconString, type IconStyle, type TextProps } from '../display';
|
|
4
|
+
type BlankStateComponents = {
|
|
5
|
+
Root: FC<BlankStateRootProps>;
|
|
6
|
+
Imagery: FC<BlankStateImageryProps>;
|
|
7
|
+
Content: FC<BlankStateContentProps>;
|
|
8
|
+
Heading: FC<BlankStateHeadingProps>;
|
|
9
|
+
Text: FC<BlankStateTextProps>;
|
|
10
|
+
Button: FC<BlankStateButtonProps>;
|
|
11
|
+
};
|
|
12
|
+
declare const _default: BlankStateComponents;
|
|
13
|
+
export default _default;
|
|
14
|
+
export type { BlankStateRootProps, BlankStateImageryProps, BlankStateContentProps, BlankStateHeadingProps, BlankStateTextProps, BlankStateButtonProps, };
|
|
15
|
+
interface BlankStateRootProps {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
style?: ViewStyle;
|
|
18
|
+
}
|
|
19
|
+
interface BlankStateImageryProps {
|
|
20
|
+
name: IconString;
|
|
21
|
+
size?: number;
|
|
22
|
+
style?: IconStyle;
|
|
23
|
+
}
|
|
24
|
+
interface BlankStateContentProps {
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
style?: ViewStyle;
|
|
27
|
+
}
|
|
28
|
+
interface BlankStateHeadingProps {
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
style?: HeadingProps['style'];
|
|
31
|
+
}
|
|
32
|
+
interface BlankStateTextProps {
|
|
33
|
+
children: ReactNode;
|
|
34
|
+
style?: TextProps['style'];
|
|
35
|
+
}
|
|
36
|
+
interface BlankStateButtonProps extends ButtonProps {
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=blank_state_primitive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blank_state_primitive.d.ts","sourceRoot":"","sources":["../../../src/components/primitive/blank_state_primitive.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAA;AAE1D,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,YAAY,CAAA;AAenB,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAA;IAC7B,OAAO,EAAE,EAAE,CAAC,sBAAsB,CAAC,CAAA;IACnC,OAAO,EAAE,EAAE,CAAC,sBAAsB,CAAC,CAAA;IACnC,OAAO,EAAE,EAAE,CAAC,sBAAsB,CAAC,CAAA;IACnC,IAAI,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAA;IAC7B,MAAM,EAAE,EAAE,CAAC,qBAAqB,CAAC,CAAA;CAClC,CAAA;wBAE4B,oBAAoB;AAAjD,wBAAiD;AACjD,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,GACtB,CAAA;AAMD,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,SAAS,CAAA;IACnB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAcD,UAAU,sBAAsB;IAC9B,IAAI,EAAE,UAAU,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAsBD,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,SAAS,CAAA;IACnB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAcD,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,SAAS,CAAA;IACnB,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAA;CAC9B;AAkBD,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,SAAS,CAAA;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;CAC3B;AAkBD,UAAU,qBAAsB,SAAQ,WAAW;CAAG"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
import { useTheme } from '../../hooks';
|
|
4
|
+
import { Button, Heading, Icon, Text, } from '../display';
|
|
5
|
+
// ========================================
|
|
6
|
+
// ====== Exports =========================
|
|
7
|
+
// ========================================
|
|
8
|
+
const BlankState = {
|
|
9
|
+
Root: BlankStateRoot,
|
|
10
|
+
Imagery: BlankStateImagery,
|
|
11
|
+
Content: BlankStateContent,
|
|
12
|
+
Heading: BlankStateHeading,
|
|
13
|
+
Text: BlankStateText,
|
|
14
|
+
Button: BlankStateButton,
|
|
15
|
+
};
|
|
16
|
+
export default BlankState;
|
|
17
|
+
function BlankStateRoot({ children, style }) {
|
|
18
|
+
const styles = useStyles();
|
|
19
|
+
return <View style={[styles.container, style]}>{children}</View>;
|
|
20
|
+
}
|
|
21
|
+
BlankStateRoot.displayName = 'BlankState.Root';
|
|
22
|
+
function BlankStateImagery({ name, size = 32, style }) {
|
|
23
|
+
const styles = useStyles();
|
|
24
|
+
/*
|
|
25
|
+
NOTE:
|
|
26
|
+
BlankState.Imagery will eventually return more then just an Icon component
|
|
27
|
+
Eventually it will need to return SVG illustrations from the theme or internally for Services Mobile.
|
|
28
|
+
This first step of using a more abstract component just allows us to keep this component open to change, without being overly perscriptive on how the change should be implomented.
|
|
29
|
+
|
|
30
|
+
*/
|
|
31
|
+
return <Icon name={name} size={size} style={[styles.imagery, style]}/>;
|
|
32
|
+
}
|
|
33
|
+
BlankStateImagery.displayName = 'BlankState.Imagery';
|
|
34
|
+
function BlankStateContent({ children, style }) {
|
|
35
|
+
const styles = useStyles();
|
|
36
|
+
return <View style={[styles.content, style]}>{children}</View>;
|
|
37
|
+
}
|
|
38
|
+
BlankStateContent.displayName = 'BlankState.Content';
|
|
39
|
+
function BlankStateHeading({ children, style }) {
|
|
40
|
+
const styles = useStyles();
|
|
41
|
+
return (<Heading variant="h3" style={[styles.heading, style]}>
|
|
42
|
+
{children}
|
|
43
|
+
</Heading>);
|
|
44
|
+
}
|
|
45
|
+
BlankStateHeading.displayName = 'BlankState.Heading';
|
|
46
|
+
function BlankStateText({ children, style }) {
|
|
47
|
+
const styles = useStyles();
|
|
48
|
+
return (<Text variant="tertiary" style={[styles.text, style]}>
|
|
49
|
+
{children}
|
|
50
|
+
</Text>);
|
|
51
|
+
}
|
|
52
|
+
BlankStateText.displayName = 'BlankState.Text';
|
|
53
|
+
function BlankStateButton(props) {
|
|
54
|
+
return <Button variant="outline" size="sm" {...props}/>;
|
|
55
|
+
}
|
|
56
|
+
BlankStateButton.displayName = 'BlankState.Button';
|
|
57
|
+
// ========================================
|
|
58
|
+
// ====== Styles ==========================
|
|
59
|
+
// ========================================
|
|
60
|
+
const useStyles = () => {
|
|
61
|
+
const { colors } = useTheme();
|
|
62
|
+
return StyleSheet.create({
|
|
63
|
+
container: {
|
|
64
|
+
flex: 1,
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
justifyContent: 'center',
|
|
67
|
+
gap: 16,
|
|
68
|
+
padding: 16,
|
|
69
|
+
},
|
|
70
|
+
imagery: {
|
|
71
|
+
color: colors.iconColorDefaultDisabled,
|
|
72
|
+
},
|
|
73
|
+
content: {
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
gap: 4,
|
|
76
|
+
maxWidth: 250,
|
|
77
|
+
},
|
|
78
|
+
heading: {
|
|
79
|
+
textAlign: 'center',
|
|
80
|
+
color: colors.textColorDefaultSecondary,
|
|
81
|
+
},
|
|
82
|
+
text: {
|
|
83
|
+
textAlign: 'center',
|
|
84
|
+
color: colors.textColorDefaultSecondary,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=blank_state_primitive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blank_state_primitive.js","sourceRoot":"","sources":["../../../src/components/primitive/blank_state_primitive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAa,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EACL,MAAM,EACN,OAAO,EACP,IAAI,EACJ,IAAI,GAML,MAAM,YAAY,CAAA;AAEnB,2CAA2C;AAC3C,2CAA2C;AAC3C,2CAA2C;AAE3C,MAAM,UAAU,GAAG;IACjB,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,iBAAiB;IAC1B,IAAI,EAAE,cAAc;IACpB,MAAM,EAAE,gBAAgB;CAChB,CAAA;AAWV,eAAe,UAAkC,CAAA;AAmBjD,SAAS,cAAc,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAuB;IAC9D,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAE1B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAA;AAClE,CAAC;AAED,cAAc,CAAC,WAAW,GAAG,iBAAiB,CAAA;AAY9C,SAAS,iBAAiB,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,EAA0B;IAC3E,MAAM,MAAM,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ACH,CAAC;AAED,cAAc,CAAC,WAAW,GAAG,iBAAiB,CAAA;AAQ9C,SAAS,gBAAgB,CAAC,KAA4B;IACpD,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,EAAG,CAAA;AAC1D,CAAC;AAED,gBAAgB,CAAC,WAAW,GAAG,mBAAmB,CAAA;AAElD,2CAA2C;AAC3C,2CAA2C;AAC3C,2CAA2C;AAE3C,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,SAAS,EAAE;YACT,IAAI,EAAE,CAAC;YACP,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;YACxB,GAAG,EAAE,EAAE;YACP,OAAO,EAAE,EAAE;SACZ;QACD,OAAO,EAAE;YACP,KAAK,EAAE,MAAM,CAAC,wBAAwB;SACvC;QACD,OAAO,EAAE;YACP,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,CAAC;YACN,QAAQ,EAAE,GAAG;SACd;QACD,OAAO,EAAE;YACP,SAAS,EAAE,QAAQ;YACnB,KAAK,EAAE,MAAM,CAAC,yBAAyB;SACxC;QACD,IAAI,EAAE;YACJ,SAAS,EAAE,QAAQ;YACnB,KAAK,EAAE,MAAM,CAAC,yBAAyB;SACxC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React, { FC, ReactNode } from 'react'\nimport { View, StyleSheet, ViewStyle } from 'react-native'\nimport { useTheme } from '../../hooks'\nimport {\n Button,\n Heading,\n Icon,\n Text,\n type ButtonProps,\n type HeadingProps,\n type IconString,\n type IconStyle,\n type TextProps,\n} from '../display'\n\n// ========================================\n// ====== Exports =========================\n// ========================================\n\nconst BlankState = {\n Root: BlankStateRoot,\n Imagery: BlankStateImagery,\n Content: BlankStateContent,\n Heading: BlankStateHeading,\n Text: BlankStateText,\n Button: BlankStateButton,\n} as const\n\ntype BlankStateComponents = {\n Root: FC<BlankStateRootProps>\n Imagery: FC<BlankStateImageryProps>\n Content: FC<BlankStateContentProps>\n Heading: FC<BlankStateHeadingProps>\n Text: FC<BlankStateTextProps>\n Button: FC<BlankStateButtonProps>\n}\n\nexport default BlankState as BlankStateComponents\nexport type {\n BlankStateRootProps,\n BlankStateImageryProps,\n BlankStateContentProps,\n BlankStateHeadingProps,\n BlankStateTextProps,\n BlankStateButtonProps,\n}\n\n// ========================================\n// ====== BlankStateRoot ==================\n// ========================================\n\ninterface BlankStateRootProps {\n children: ReactNode\n style?: ViewStyle\n}\n\nfunction BlankStateRoot({ children, style }: BlankStateRootProps) {\n const styles = useStyles()\n\n return <View style={[styles.container, style]}>{children}</View>\n}\n\nBlankStateRoot.displayName = 'BlankState.Root'\n\n// ========================================\n// ====== BlankStateImagery ===============\n// ========================================\n\ninterface BlankStateImageryProps {\n name: IconString\n size?: number\n style?: IconStyle\n}\n\nfunction BlankStateImagery({ name, size = 32, style }: BlankStateImageryProps) {\n const styles = useStyles()\n\n /*\n NOTE:\n BlankState.Imagery will eventually return more then just an Icon component\n Eventually it will need to return SVG illustrations from the theme or internally for Services Mobile.\n This first step of using a more abstract component just allows us to keep this component open to change, without being overly perscriptive on how the change should be implomented.\n\n*/\n\n return <Icon name={name} size={size} style={[styles.imagery, style]} />\n}\n\nBlankStateImagery.displayName = 'BlankState.Imagery'\n\n// ========================================\n// ====== BlankStateContent ===============\n// ========================================\n\ninterface BlankStateContentProps {\n children: ReactNode\n style?: ViewStyle\n}\n\nfunction BlankStateContent({ children, style }: BlankStateContentProps) {\n const styles = useStyles()\n\n return <View style={[styles.content, style]}>{children}</View>\n}\n\nBlankStateContent.displayName = 'BlankState.Content'\n\n// ========================================\n// ====== BlankStateHeading ===============\n// ========================================\n\ninterface BlankStateHeadingProps {\n children: ReactNode\n style?: HeadingProps['style']\n}\n\nfunction BlankStateHeading({ children, style }: BlankStateHeadingProps) {\n const styles = useStyles()\n\n return (\n <Heading variant=\"h3\" style={[styles.heading, style]}>\n {children}\n </Heading>\n )\n}\n\nBlankStateHeading.displayName = 'BlankState.Heading'\n\n// ========================================\n// ====== BlankStateText ==================\n// ========================================\n\ninterface BlankStateTextProps {\n children: ReactNode\n style?: TextProps['style']\n}\n\nfunction BlankStateText({ children, style }: BlankStateTextProps) {\n const styles = useStyles()\n\n return (\n <Text variant=\"tertiary\" style={[styles.text, style]}>\n {children}\n </Text>\n )\n}\n\nBlankStateText.displayName = 'BlankState.Text'\n\n// ========================================\n// ====== BlankStateButton ================\n// ========================================\n\ninterface BlankStateButtonProps extends ButtonProps {}\n\nfunction BlankStateButton(props: BlankStateButtonProps) {\n return <Button variant=\"outline\" size=\"sm\" {...props} />\n}\n\nBlankStateButton.displayName = 'BlankState.Button'\n\n// ========================================\n// ====== Styles ==========================\n// ========================================\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n container: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n gap: 16,\n padding: 16,\n },\n imagery: {\n color: colors.iconColorDefaultDisabled,\n },\n content: {\n alignItems: 'center',\n gap: 4,\n maxWidth: 250,\n },\n heading: {\n textAlign: 'center',\n color: colors.textColorDefaultSecondary,\n },\n text: {\n textAlign: 'center',\n color: colors.textColorDefaultSecondary,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_conversation.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"use_conversation.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAO5D,eAAO,MAAM,0BAA0B,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;CAmCzF,CAAA;AAEF,eAAO,MAAM,eAAe,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;CAE/E,CAAA;AAED,eAAO,MAAM,mBAAmB,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CnF,CAAA;AAED,eAAO,MAAM,qBAAqB,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,qIA+BrF,CAAA;AAED,eAAO,MAAM,qBAAqB,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,iFAiBrF,CAAA;AAED,eAAO,MAAM,6BAA6B,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6C7F,CAAA"}
|
|
@@ -4,6 +4,7 @@ import { transformGetToPost } from '../utils/client/request_helpers';
|
|
|
4
4
|
import { useApiClient } from './use_api_client';
|
|
5
5
|
import { getRequestQueryKey, useSuspenseGet } from './use_suspense_api';
|
|
6
6
|
import { getConversationsRequestArgs } from '../utils/request/conversation';
|
|
7
|
+
import { Haptic } from '../utils/native_adapters';
|
|
7
8
|
export const getConversationRequestArgs = ({ conversation_id }) => ({
|
|
8
9
|
url: `/me/conversations/${conversation_id}`,
|
|
9
10
|
data: {
|
|
@@ -126,6 +127,7 @@ export const useConversationDelete = ({ conversation_id }) => {
|
|
|
126
127
|
},
|
|
127
128
|
onSuccess: () => {
|
|
128
129
|
queryClient.invalidateQueries({ queryKey: [url] });
|
|
130
|
+
Haptic.notificationSuccess();
|
|
129
131
|
},
|
|
130
132
|
});
|
|
131
133
|
};
|
|
@@ -1 +1 @@
|
|
|
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,KAAK,CAAoC;gBAC7D,GAAG,EAAE,qBAAqB,eAAe,EAAE;gBAC3C,IAAI,EAAE;oBACJ,IAAI,EAAE;wBACJ,IAAI,EAAE,cAAc;wBACpB,UAAU,EAAE;4BACV,gBAAgB,EAAE,eAAe;yBAClC;qBACF;iBACF;aACF,CAAC,CAAA;QACJ,CAAC;QACD,SAAS,EAAE,CAAC,QAA2C,EAAE,EAAE;YACzD,WAAW,CAAC,YAAY,CAAoC,QAAQ,EAAE,IAAI,CAAC,EAAE;gBAC3E,IAAI,CAAC,IAAI,EAAE,IAAI;oBAAE,OAAO,IAAI,CAAA;gBAE5B,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAA;gBACzD,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;gBAEvC,OAAO,IAAI,CAAA;YACb,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,kBAAkB,EAAE,GAAG,QAAQ,EAAE,CAAA;AACpE,CAAC,CAAA","sourcesContent":["import { useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useState } from 'react'\nimport { ApiResource, ConversationResource } from '../types'\nimport { transformGetToPost } from '../utils/client/request_helpers'\nimport { useApiClient } from './use_api_client'\nimport { getRequestQueryKey, useSuspenseGet } from './use_suspense_api'\nimport { getConversationsRequestArgs } from '../utils/request/conversation'\n\nexport const getConversationRequestArgs = ({ conversation_id }: { conversation_id: number }) => ({\n url: `/me/conversations/${conversation_id}`,\n data: {\n fields: {\n Conversation: [\n 'created_at',\n 'badges',\n 'conversation_membership',\n 'groups',\n 'last_message_author_id',\n 'last_message_author_name',\n 'last_message_created_at',\n 'last_message_text_preview',\n 'latest_read_message_sort_key',\n 'preview_avatar_urls',\n 'member_ability',\n 'muted',\n 'replies_disabled',\n 'title',\n 'unread_count',\n 'updated_at',\n ],\n MemberAbility: [\n 'can_update',\n 'can_delete',\n 'leader',\n 'can_reply',\n 'can_delete_non_authored_messages',\n ],\n ConversationMembership: ['last_read_message_sort_key'],\n ConversationBadge: ['app_name', 'pco_resource_type', 'text'],\n Group: ['type', 'id', 'links', 'name', 'source_app_name', 'source_type'],\n },\n include: ['badges', 'conversation_membership', 'member_ability', 'groups'],\n },\n})\n\nexport const useConversation = ({ conversation_id }: { conversation_id: number }) => {\n return useSuspenseGet<ConversationResource>(getConversationRequestArgs({ conversation_id }))\n}\n\nexport const useConversationMute = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n const { data: conversation } = useConversation({ conversation_id })\n const [value, setValue] = useState<boolean>(conversation.muted)\n\n const { mutate: setMuted, ...mutation } = useMutation({\n onMutate: async (muted: boolean) => {\n return queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n setValue(muted)\n prev.data.muted = muted\n\n return prev\n })\n },\n mutationKey: ['muteConversation'],\n mutationFn: async (muted: boolean) => {\n const action = muted ? 'mute' : 'unmute'\n\n return apiClient.chat.post<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}/${action}`,\n data: { data: { type: '', attributes: {} }, fields: { Conversation: 'muted' } },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\n queryClient.invalidateQueries({ queryKey: ['/me/conversations'] })\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n // Posting to the mute action endpoint can't return all the fields\n // so we need to set only the fields we require\n prev.data.muted = response.data.muted\n setValue(response.data.muted)\n\n return prev\n })\n },\n })\n\n return { muted: value, setMuted, ...mutation }\n}\n\nexport const useConversationUpdate = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n\n return useMutation({\n onMutate: async (update: Partial<ConversationResource>) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (prev?.data) {\n prev.data = {\n ...prev.data,\n ...update,\n }\n }\n\n return prev\n })\n },\n mutationKey: ['mutateConversation'],\n mutationFn: async (update: Partial<ConversationResource>) => {\n const postArgs = transformGetToPost(requestArgs).data\n return apiClient.chat.patch<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}/`,\n data: { data: { type: '', attributes: update }, ...postArgs },\n })\n },\n onSuccess: response => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, () => response)\n },\n })\n}\n\nexport const useConversationDelete = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const { url } = getConversationsRequestArgs()\n\n return useMutation({\n mutationKey: ['deleteConversation'],\n mutationFn: async () => {\n return apiClient.chat.delete({\n url: `/me/conversations/${conversation_id}`,\n })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [url] })\n },\n })\n}\n\nexport const useConversationDisableReplies = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n const { data: conversation } = useConversation({ conversation_id })\n const [value, setValue] = useState<boolean>(conversation.repliesDisabled)\n\n const { mutate: setRepliesDisabled, ...mutation } = useMutation({\n onMutate: async (repliesDisabled: boolean) => {\n return queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n setValue(repliesDisabled)\n prev.data.repliesDisabled = repliesDisabled\n\n return prev\n })\n },\n mutationKey: ['disableRepliesConversation'],\n mutationFn: async (repliesDisabled: boolean) => {\n return apiClient.chat.patch<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}`,\n data: {\n data: {\n type: 'Conversation',\n attributes: {\n replies_disabled: repliesDisabled,\n },\n },\n },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n prev.data.repliesDisabled = response.data.repliesDisabled\n setValue(response.data.repliesDisabled)\n\n return prev\n })\n },\n })\n\n return { repliesDisabled: value, setRepliesDisabled, ...mutation }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use_conversation.js","sourceRoot":"","sources":["../../src/hooks/use_conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAA;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAEjD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EAAE,eAAe,EAA+B,EAAE,EAAE,CAAC,CAAC;IAC/F,GAAG,EAAE,qBAAqB,eAAe,EAAE;IAC3C,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,YAAY,EAAE;gBACZ,YAAY;gBACZ,QAAQ;gBACR,yBAAyB;gBACzB,QAAQ;gBACR,wBAAwB;gBACxB,0BAA0B;gBAC1B,yBAAyB;gBACzB,2BAA2B;gBAC3B,8BAA8B;gBAC9B,qBAAqB;gBACrB,gBAAgB;gBAChB,OAAO;gBACP,kBAAkB;gBAClB,OAAO;gBACP,cAAc;gBACd,YAAY;aACb;YACD,aAAa,EAAE;gBACb,YAAY;gBACZ,YAAY;gBACZ,QAAQ;gBACR,WAAW;gBACX,kCAAkC;aACnC;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AE;gBAClF,IAAI,CAAC,IAAI,EAAE,IAAI;oBAAE,OAAO,IAAI,CAAA;gBAC5B,QAAQ,CAAC,eAAe,CAAC,CAAA;gBACzB,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;gBAE3C,OAAO,IAAI,CAAA;YACb,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,WAAW,EAAE,CAAC,4BAA4B,CAAC;QAC3C,UAAU,EAAE,KAAK,EAAE,eAAwB,EAAE,EAAE;YAC7C,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAoC;gBAC7D,GAAG,EAAE,qBAAqB,eAAe,EAAE;gBAC3C,IAAI,EAAE;oBACJ,IAAI,EAAE;wBACJ,IAAI,EAAE,cAAc;wBACpB,UAAU,EAAE;4BACV,gBAAgB,EAAE,eAAe;yBAClC;qBACF;iBACF;aACF,CAAC,CAAA;QACJ,CAAC;QACD,SAAS,EAAE,CAAC,QAA2C,EAAE,EAAE;YACzD,WAAW,CAAC,YAAY,CAAoC,QAAQ,EAAE,IAAI,CAAC,EAAE;gBAC3E,IAAI,CAAC,IAAI,EAAE,IAAI;oBAAE,OAAO,IAAI,CAAA;gBAE5B,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAA;gBACzD,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;gBAEvC,OAAO,IAAI,CAAA;YACb,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,kBAAkB,EAAE,GAAG,QAAQ,EAAE,CAAA;AACpE,CAAC,CAAA","sourcesContent":["import { useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useState } from 'react'\nimport { ApiResource, ConversationResource } from '../types'\nimport { transformGetToPost } from '../utils/client/request_helpers'\nimport { useApiClient } from './use_api_client'\nimport { getRequestQueryKey, useSuspenseGet } from './use_suspense_api'\nimport { getConversationsRequestArgs } from '../utils/request/conversation'\nimport { Haptic } from '../utils/native_adapters'\n\nexport const getConversationRequestArgs = ({ conversation_id }: { conversation_id: number }) => ({\n url: `/me/conversations/${conversation_id}`,\n data: {\n fields: {\n Conversation: [\n 'created_at',\n 'badges',\n 'conversation_membership',\n 'groups',\n 'last_message_author_id',\n 'last_message_author_name',\n 'last_message_created_at',\n 'last_message_text_preview',\n 'latest_read_message_sort_key',\n 'preview_avatar_urls',\n 'member_ability',\n 'muted',\n 'replies_disabled',\n 'title',\n 'unread_count',\n 'updated_at',\n ],\n MemberAbility: [\n 'can_update',\n 'can_delete',\n 'leader',\n 'can_reply',\n 'can_delete_non_authored_messages',\n ],\n ConversationMembership: ['last_read_message_sort_key'],\n ConversationBadge: ['app_name', 'pco_resource_type', 'text'],\n Group: ['type', 'id', 'links', 'name', 'source_app_name', 'source_type'],\n },\n include: ['badges', 'conversation_membership', 'member_ability', 'groups'],\n },\n})\n\nexport const useConversation = ({ conversation_id }: { conversation_id: number }) => {\n return useSuspenseGet<ConversationResource>(getConversationRequestArgs({ conversation_id }))\n}\n\nexport const useConversationMute = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n const { data: conversation } = useConversation({ conversation_id })\n const [value, setValue] = useState<boolean>(conversation.muted)\n\n const { mutate: setMuted, ...mutation } = useMutation({\n onMutate: async (muted: boolean) => {\n return queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n setValue(muted)\n prev.data.muted = muted\n\n return prev\n })\n },\n mutationKey: ['muteConversation'],\n mutationFn: async (muted: boolean) => {\n const action = muted ? 'mute' : 'unmute'\n\n return apiClient.chat.post<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}/${action}`,\n data: { data: { type: '', attributes: {} }, fields: { Conversation: 'muted' } },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\n queryClient.invalidateQueries({ queryKey: ['/me/conversations'] })\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n // Posting to the mute action endpoint can't return all the fields\n // so we need to set only the fields we require\n prev.data.muted = response.data.muted\n setValue(response.data.muted)\n\n return prev\n })\n },\n })\n\n return { muted: value, setMuted, ...mutation }\n}\n\nexport const useConversationUpdate = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n\n return useMutation({\n onMutate: async (update: Partial<ConversationResource>) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (prev?.data) {\n prev.data = {\n ...prev.data,\n ...update,\n }\n }\n\n return prev\n })\n },\n mutationKey: ['mutateConversation'],\n mutationFn: async (update: Partial<ConversationResource>) => {\n const postArgs = transformGetToPost(requestArgs).data\n return apiClient.chat.patch<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}/`,\n data: { data: { type: '', attributes: update }, ...postArgs },\n })\n },\n onSuccess: response => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, () => response)\n },\n })\n}\n\nexport const useConversationDelete = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const { url } = getConversationsRequestArgs()\n\n return useMutation({\n mutationKey: ['deleteConversation'],\n mutationFn: async () => {\n return apiClient.chat.delete({\n url: `/me/conversations/${conversation_id}`,\n })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [url] })\n Haptic.notificationSuccess()\n },\n })\n}\n\nexport const useConversationDisableReplies = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n const { data: conversation } = useConversation({ conversation_id })\n const [value, setValue] = useState<boolean>(conversation.repliesDisabled)\n\n const { mutate: setRepliesDisabled, ...mutation } = useMutation({\n onMutate: async (repliesDisabled: boolean) => {\n return queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n setValue(repliesDisabled)\n prev.data.repliesDisabled = repliesDisabled\n\n return prev\n })\n },\n mutationKey: ['disableRepliesConversation'],\n mutationFn: async (repliesDisabled: boolean) => {\n return apiClient.chat.patch<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}`,\n data: {\n data: {\n type: 'Conversation',\n attributes: {\n replies_disabled: repliesDisabled,\n },\n },\n },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n prev.data.repliesDisabled = response.data.repliesDisabled\n setValue(response.data.repliesDisabled)\n\n return prev\n })\n },\n })\n\n return { repliesDisabled: value, setRepliesDisabled, ...mutation }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_message_create_or_update.d.ts","sourceRoot":"","sources":["../../src/hooks/use_message_create_or_update.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"use_message_create_or_update.d.ts","sourceRoot":"","sources":["../../src/hooks/use_message_create_or_update.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAQtE,OAAO,EAAE,uCAAuC,EAAE,MAAM,gEAAgE,CAAA;AAMxH,UAAU,KAAK;IACb,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,eAAe,CAAA;CAC1B;AAED,wBAAgB,wBAAwB,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE,KAAK;UAiD/D,MAAM;kBACE,uCAAuC,EAAE;;;GAuE5D;AAED,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAEvE;AACD,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAE/D"}
|
|
@@ -2,7 +2,7 @@ import { useMutation } from '@tanstack/react-query';
|
|
|
2
2
|
import { getMessagesQueryKey, getMessagesRequestArgs } from './use_conversation_messages';
|
|
3
3
|
import { useApiClient } from './use_api_client';
|
|
4
4
|
import { chatQueryClient } from '../contexts/api_provider';
|
|
5
|
-
import { deleteRecordInPagesData, updateOrCreateRecordInPagesData, updateRecordInPagesData, } from '../utils';
|
|
5
|
+
import { deleteRecordInPagesData, Haptic, updateOrCreateRecordInPagesData, updateRecordInPagesData, } from '../utils';
|
|
6
6
|
import { useCurrentPerson } from './use_current_person';
|
|
7
7
|
import { optimisticallyUpdateMessage } from '../utils/cache/optimistically_update_message';
|
|
8
8
|
import { optimisticallyCreateMessage } from '../utils/cache/optimistically_create_message';
|
|
@@ -63,6 +63,7 @@ export function useMessageCreateOrUpdate({ conversationId, message }) {
|
|
|
63
63
|
},
|
|
64
64
|
onError: (error, variables, context) => {
|
|
65
65
|
const { message: optimisticMessage } = context || {};
|
|
66
|
+
Haptic.notificationError();
|
|
66
67
|
// Add error to the optimistic message from the cache on error
|
|
67
68
|
if (optimisticMessage) {
|
|
68
69
|
const queryKey = getMessagesQueryKey({ conversation_id: conversationId });
|