@planningcenter/chat-react-native 3.21.2-rc.5 → 3.22.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/conversation/attachments/attachment_card.js +1 -0
- package/build/components/conversation/attachments/attachment_card.js.map +1 -1
- package/build/components/conversation/attachments/attachment_deleting_overlay.d.ts +3 -0
- package/build/components/conversation/attachments/attachment_deleting_overlay.d.ts.map +1 -0
- package/build/components/conversation/attachments/attachment_deleting_overlay.js +29 -0
- package/build/components/conversation/attachments/attachment_deleting_overlay.js.map +1 -0
- package/build/components/conversation/attachments/audio_attachment.d.ts +2 -1
- package/build/components/conversation/attachments/audio_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/audio_attachment.js +5 -3
- package/build/components/conversation/attachments/audio_attachment.js.map +1 -1
- package/build/components/conversation/attachments/generic_file_attachment.d.ts +2 -1
- package/build/components/conversation/attachments/generic_file_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/generic_file_attachment.js +4 -2
- package/build/components/conversation/attachments/generic_file_attachment.js.map +1 -1
- package/build/components/conversation/attachments/image_attachment.d.ts +2 -1
- package/build/components/conversation/attachments/image_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/image_attachment.js +9 -4
- package/build/components/conversation/attachments/image_attachment.js.map +1 -1
- package/build/components/conversation/attachments/video_attachment.d.ts +2 -1
- package/build/components/conversation/attachments/video_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/video_attachment.js +5 -3
- package/build/components/conversation/attachments/video_attachment.js.map +1 -1
- package/build/components/conversation/message_attachments.d.ts.map +1 -1
- package/build/components/conversation/message_attachments.js +8 -6
- package/build/components/conversation/message_attachments.js.map +1 -1
- package/build/hooks/index.d.ts +1 -0
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use_deleting_ids.d.ts +4 -0
- package/build/hooks/use_deleting_ids.d.ts.map +1 -0
- package/build/hooks/use_deleting_ids.js +19 -0
- package/build/hooks/use_deleting_ids.js.map +1 -0
- package/build/screens/attachment_actions/attachment_actions_screen.d.ts.map +1 -1
- package/build/screens/attachment_actions/attachment_actions_screen.js +9 -2
- package/build/screens/attachment_actions/attachment_actions_screen.js.map +1 -1
- package/build/screens/attachment_actions/hooks/useDeleteAttachment.d.ts.map +1 -1
- package/build/screens/attachment_actions/hooks/useDeleteAttachment.js +1 -3
- package/build/screens/attachment_actions/hooks/useDeleteAttachment.js.map +1 -1
- package/package.json +2 -2
- package/src/components/conversation/attachments/attachment_card.tsx +1 -0
- package/src/components/conversation/attachments/attachment_deleting_overlay.tsx +34 -0
- package/src/components/conversation/attachments/audio_attachment.tsx +7 -2
- package/src/components/conversation/attachments/generic_file_attachment.tsx +6 -1
- package/src/components/conversation/attachments/image_attachment.tsx +11 -3
- package/src/components/conversation/attachments/video_attachment.tsx +7 -2
- package/src/components/conversation/message_attachments.tsx +9 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use_deleting_ids.ts +22 -0
- package/src/screens/attachment_actions/attachment_actions_screen.tsx +9 -2
- package/src/screens/attachment_actions/hooks/useDeleteAttachment.tsx +1 -3
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DenormalizedMessageAttachmentResource } from '../../../types/resources/denormalized_attachment_resource';
|
|
3
|
-
export declare function VideoAttachment({ attachment, onMessageAttachmentLongPress, }: {
|
|
3
|
+
export declare function VideoAttachment({ attachment, onMessageAttachmentLongPress, isDeleting, }: {
|
|
4
4
|
attachment: DenormalizedMessageAttachmentResource;
|
|
5
5
|
onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void;
|
|
6
|
+
isDeleting: boolean;
|
|
6
7
|
}): React.JSX.Element;
|
|
7
8
|
//# sourceMappingURL=video_attachment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video_attachment.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/video_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,OAAO,EAAE,qCAAqC,EAAE,MAAM,2DAA2D,CAAA;
|
|
1
|
+
{"version":3,"file":"video_attachment.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/video_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,OAAO,EAAE,qCAAqC,EAAE,MAAM,2DAA2D,CAAA;AASjH,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,4BAA4B,EAC5B,UAAU,GACX,EAAE;IACD,UAAU,EAAE,qCAAqC,CAAA;IACjD,4BAA4B,EAAE,CAAC,UAAU,EAAE,qCAAqC,KAAK,IAAI,CAAA;IACzF,UAAU,EAAE,OAAO,CAAA;CACpB,qBA4DA"}
|
|
@@ -6,7 +6,8 @@ import { Video } from '../../../utils/native_adapters';
|
|
|
6
6
|
import { PlatformPressable } from '@react-navigation/elements';
|
|
7
7
|
import { useTheme } from '../../../hooks';
|
|
8
8
|
import { tokens } from '../../../vendor/tapestry/tokens';
|
|
9
|
-
|
|
9
|
+
import { AttachmentDeletingOverlay } from './attachment_deleting_overlay';
|
|
10
|
+
export function VideoAttachment({ attachment, onMessageAttachmentLongPress, isDeleting, }) {
|
|
10
11
|
const { colors } = useTheme();
|
|
11
12
|
const styles = useStyles();
|
|
12
13
|
const { attributes } = attachment;
|
|
@@ -27,14 +28,15 @@ export function VideoAttachment({ attachment, onMessageAttachmentLongPress, }) {
|
|
|
27
28
|
}
|
|
28
29
|
const viewRef = useRef(null);
|
|
29
30
|
return (<View style={styles.container} ref={viewRef}>
|
|
30
|
-
<PlatformPressable onPress={openVideo} onLongPress={() => onMessageAttachmentLongPress(attachment)} android_ripple={{ color: colors.androidRippleNeutral, foreground: true }} accessibilityLabel="Play Video" accessibilityHint="Press to play video. Long press for more options">
|
|
31
|
+
<PlatformPressable onPress={openVideo} onLongPress={() => !isDeleting && onMessageAttachmentLongPress(attachment)} android_ripple={{ color: colors.androidRippleNeutral, foreground: true }} accessibilityLabel="Play Video" accessibilityHint="Press to play video. Long press for more options" disabled={isDeleting}>
|
|
31
32
|
<View style={styles.thumbnailOverlay}/>
|
|
32
33
|
<Video.Player ref={videoRef} source={{ uri: url }} aspectRatio={width / height} style={styles.video} onFullscreenPlayerWillDismiss={onFullscreenPlayerWillDismiss}/>
|
|
33
|
-
{!isOpen && (<View style={styles.playContainer}>
|
|
34
|
+
{!isOpen && !isDeleting && (<View style={styles.playContainer}>
|
|
34
35
|
<View style={styles.playCircle}>
|
|
35
36
|
<Icon name="services.play" style={styles.playIcon} accessibilityElementsHidden={true}/>
|
|
36
37
|
</View>
|
|
37
38
|
</View>)}
|
|
39
|
+
{isDeleting && <AttachmentDeletingOverlay />}
|
|
38
40
|
</PlatformPressable>
|
|
39
41
|
</View>);
|
|
40
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video_attachment.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/video_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACpC,OAAO,EAAE,KAAK,EAAqB,MAAM,gCAAgC,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"video_attachment.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/video_attachment.ts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EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE;YACV,YAAY,EAAE,EAAE;YAChB,eAAe,EAAE,MAAM,CAAC,2BAA2B;YACnD,WAAW,EAAE,MAAM,CAAC,sBAAsB;YAC1C,WAAW,EAAE,CAAC;SACf;QACD,QAAQ,EAAE;YACR,QAAQ,EAAE,EAAE;SACb;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React, { useRef, useState } from 'react'\nimport { View, StyleSheet } from 'react-native'\nimport { DenormalizedMessageAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'\nimport { MESSAGE_ATTACHMENT_WIDTH_SINGLE } from './constants'\nimport { Icon } from '../../display'\nimport { Video, VideoPlayerHandle } from '../../../utils/native_adapters'\nimport { PlatformPressable } from '@react-navigation/elements'\nimport { useTheme } from '../../../hooks'\nimport { tokens } from '../../../vendor/tapestry/tokens'\nimport { AttachmentDeletingOverlay } from './attachment_deleting_overlay'\n\nexport function VideoAttachment({\n attachment,\n onMessageAttachmentLongPress,\n isDeleting,\n}: {\n attachment: DenormalizedMessageAttachmentResource\n onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void\n isDeleting: boolean\n}) {\n const { colors } = useTheme()\n const styles = useStyles()\n\n const { attributes } = attachment\n const { width = MESSAGE_ATTACHMENT_WIDTH_SINGLE, height = MESSAGE_ATTACHMENT_WIDTH_SINGLE } =\n attributes.metadata || {}\n const { url } = attributes\n\n const videoRef = useRef<VideoPlayerHandle>(null)\n const [isOpen, setIsOpen] = useState(false)\n\n function openVideo() {\n if (!isOpen && videoRef.current) {\n videoRef.current.presentFullscreenPlayer()\n videoRef.current.play()\n setIsOpen(true)\n }\n }\n\n function onFullscreenPlayerWillDismiss() {\n videoRef.current?.pause()\n setIsOpen(false)\n }\n\n const viewRef = useRef<View>(null)\n\n return (\n <View style={styles.container} ref={viewRef}>\n <PlatformPressable\n onPress={openVideo}\n onLongPress={() => !isDeleting && onMessageAttachmentLongPress(attachment)}\n android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}\n accessibilityLabel=\"Play Video\"\n accessibilityHint=\"Press to play video. Long press for more options\"\n disabled={isDeleting}\n >\n <View style={styles.thumbnailOverlay} />\n <Video.Player\n ref={videoRef}\n source={{ uri: url }}\n aspectRatio={width / height}\n style={styles.video}\n onFullscreenPlayerWillDismiss={onFullscreenPlayerWillDismiss}\n />\n {!isOpen && !isDeleting && (\n <View style={styles.playContainer}>\n <View style={styles.playCircle}>\n <Icon\n name=\"services.play\"\n style={styles.playIcon}\n accessibilityElementsHidden={true}\n />\n </View>\n </View>\n )}\n {isDeleting && <AttachmentDeletingOverlay />}\n </PlatformPressable>\n </View>\n )\n}\nconst OVERLAY_Z_INDEX = 1\n\nconst useStyles = () => {\n const { colors } = useTheme()\n const overlayBackgroundColor =\n colors.name === 'light'\n ? tokens.fillColorTransparencyDark010\n : tokens.fillColorTransparencyDark030\n\n return StyleSheet.create({\n container: {\n borderRadius: 8,\n overflow: 'hidden',\n },\n video: {\n width: '100%',\n backgroundColor: colors.fillColorNeutral070,\n },\n thumbnailOverlay: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n backgroundColor: overlayBackgroundColor,\n zIndex: OVERLAY_Z_INDEX,\n },\n playContainer: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n justifyContent: 'center',\n alignItems: 'center',\n zIndex: OVERLAY_Z_INDEX + 1,\n },\n playCircle: {\n justifyContent: 'center',\n alignItems: 'center',\n width: 42,\n height: 42,\n borderRadius: 25,\n backgroundColor: colors.fillColorNeutral100Inverted,\n borderColor: colors.borderColorDefaultBase,\n borderWidth: 1,\n },\n playIcon: {\n fontSize: 20,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_attachments.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_attachments.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EACL,8BAA8B,EAC9B,qCAAqC,EACtC,MAAM,wDAAwD,CAAA;AAM/D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"message_attachments.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_attachments.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EACL,8BAA8B,EAC9B,qCAAqC,EACtC,MAAM,wDAAwD,CAAA;AAM/D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAGhF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,WAAW,EAAE,8BAA8B,EAAE,CAAA;IAC7C,SAAS,EAAE,SAAS,CAAA;IACpB,4BAA4B,EAAE,CAAC,UAAU,EAAE,qCAAqC,KAAK,IAAI,CAAA;IACzF,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B,4BA8DA"}
|
|
@@ -6,9 +6,11 @@ import { GiphyAttachment } from './attachments/giphy_attachment';
|
|
|
6
6
|
import { GenericFileAttachment } from './attachments/generic_file_attachment';
|
|
7
7
|
import { ExpandedLink } from './attachments/expanded_link';
|
|
8
8
|
import { ImageAttachment } from './attachments/image_attachment';
|
|
9
|
+
import { useDeletingIds } from '../../hooks';
|
|
9
10
|
export function MessageAttachments(props) {
|
|
10
11
|
const styles = useStyles();
|
|
11
12
|
const { attachments, metaProps, onMessageAttachmentLongPress, onMessageLongPress } = props;
|
|
13
|
+
const deletingAttachmentIds = useDeletingIds('deleteAttachment');
|
|
12
14
|
if (!attachments || attachments.length === 0)
|
|
13
15
|
return null;
|
|
14
16
|
const imageAttachments = attachments.filter(attachment => attachment.type === 'MessageAttachment' &&
|
|
@@ -16,12 +18,12 @@ export function MessageAttachments(props) {
|
|
|
16
18
|
const showImageAttachmentGroup = imageAttachments.length > 0;
|
|
17
19
|
return (<View style={styles.attachmentsContainer}>
|
|
18
20
|
{showImageAttachmentGroup &&
|
|
19
|
-
imageAttachments.map((image, index) => (<ImageAttachment key={`${image.id}-${index}`} attachment={image} imageAttachments={imageAttachments} currentImageIndex={index} metaProps={metaProps} onMessageAttachmentLongPress={onMessageAttachmentLongPress}/>))}
|
|
21
|
+
imageAttachments.map((image, index) => (<ImageAttachment key={`${image.id}-${index}`} attachment={image} imageAttachments={imageAttachments} currentImageIndex={index} metaProps={metaProps} onMessageAttachmentLongPress={onMessageAttachmentLongPress} isDeleting={deletingAttachmentIds.has(image.id)}/>))}
|
|
20
22
|
|
|
21
23
|
{attachments.map((attachment, index) => {
|
|
22
24
|
switch (attachment.type) {
|
|
23
25
|
case 'MessageAttachment':
|
|
24
|
-
return (<MessageAttachment key={`${attachment.id}-${index}`} attachment={attachment} onMessageAttachmentLongPress={onMessageAttachmentLongPress}/>);
|
|
26
|
+
return (<MessageAttachment key={`${attachment.id}-${index}`} attachment={attachment} onMessageAttachmentLongPress={onMessageAttachmentLongPress} isDeleting={deletingAttachmentIds.has(attachment.id)}/>);
|
|
25
27
|
case 'giphy':
|
|
26
28
|
return (<GiphyAttachment key={`${attachment.id || attachment.titleLink}-${index}`} attachment={attachment} onMessageLongPress={onMessageLongPress}/>);
|
|
27
29
|
case 'ExpandedLink':
|
|
@@ -32,17 +34,17 @@ export function MessageAttachments(props) {
|
|
|
32
34
|
})}
|
|
33
35
|
</View>);
|
|
34
36
|
}
|
|
35
|
-
function MessageAttachment({ attachment, onMessageAttachmentLongPress, }) {
|
|
37
|
+
function MessageAttachment({ attachment, onMessageAttachmentLongPress, isDeleting, }) {
|
|
36
38
|
const { attributes } = attachment;
|
|
37
39
|
const contentType = attributes?.contentType;
|
|
38
40
|
const basicType = contentType ? contentType.split('/')[0] : '';
|
|
39
41
|
switch (basicType) {
|
|
40
42
|
case 'video':
|
|
41
|
-
return (<VideoAttachment attachment={attachment} onMessageAttachmentLongPress={onMessageAttachmentLongPress}/>);
|
|
43
|
+
return (<VideoAttachment attachment={attachment} onMessageAttachmentLongPress={onMessageAttachmentLongPress} isDeleting={isDeleting}/>);
|
|
42
44
|
case 'audio':
|
|
43
|
-
return (<AudioAttachment attachment={attachment} onMessageAttachmentLongPress={onMessageAttachmentLongPress}/>);
|
|
45
|
+
return (<AudioAttachment attachment={attachment} onMessageAttachmentLongPress={onMessageAttachmentLongPress} isDeleting={isDeleting}/>);
|
|
44
46
|
case 'application':
|
|
45
|
-
return (<GenericFileAttachment attachment={attachment} onMessageAttachmentLongPress={onMessageAttachmentLongPress}/>);
|
|
47
|
+
return (<GenericFileAttachment attachment={attachment} onMessageAttachmentLongPress={onMessageAttachmentLongPress} isDeleting={isDeleting}/>);
|
|
46
48
|
default:
|
|
47
49
|
return null;
|
|
48
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_attachments.js","sourceRoot":"","sources":["../../../src/components/conversation/message_attachments.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAK/C,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAkB,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"message_attachments.js","sourceRoot":"","sources":["../../../src/components/conversation/message_attachments.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAK/C,OAAO,EAAE,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S,iBAAiB,CAAC,EACzB,UAAU,EACV,4BAA4B,EAC5B,UAAU,GAKX;IACC,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAAA;IACjC,MAAM,WAAW,GAAG,UAAU,EAAE,WAAW,CAAA;IAC3C,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAE9D,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,CACL,CAAC,eAAe,CACd,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,4BAA4B,CAAC,CAAC,4BAA4B,CAAC,CAC3D,UAAU,CAAC,CAAC,UAAU,CAAC,EACvB,CACH,CAAA;QACH,KAAK,OAAO;YACV,OAAO,CACL,CAAC,eAAe,CACd,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,4BAA4B,CAAC,CAAC,4BAA4B,CAAC,CAC3D,UAAU,CAAC,CAAC,UAAU,CAAC,EACvB,CACH,CAAA;QACH,KAAK,aAAa;YAChB,OAAO,CACL,CAAC,qBAAqB,CACpB,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,4BAA4B,CAAC,CAAC,4BAA4B,CAAC,CAC3D,UAAU,CAAC,CAAC,UAAU,CAAC,EACvB,CACH,CAAA;QACH;YACE,OAAO,IAAI,CAAA;IACf,CAAC;AACH,CAAC;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,oBAAoB,EAAE;YACpB,GAAG,EAAE,CAAC;YACN,OAAO,EAAE,CAAC;SACX;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { View, StyleSheet } from 'react-native'\nimport {\n DenormalizedAttachmentResource,\n DenormalizedMessageAttachmentResource,\n} from '../../types/resources/denormalized_attachment_resource'\nimport { AudioAttachment } from './attachments/audio_attachment'\nimport { VideoAttachment } from './attachments/video_attachment'\nimport { GiphyAttachment } from './attachments/giphy_attachment'\nimport { GenericFileAttachment } from './attachments/generic_file_attachment'\nimport { ExpandedLink } from './attachments/expanded_link'\nimport { ImageAttachment, type MetaProps } from './attachments/image_attachment'\nimport { useDeletingIds } from '../../hooks'\n\nexport function MessageAttachments(props: {\n attachments: DenormalizedAttachmentResource[]\n metaProps: MetaProps\n onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void\n onMessageLongPress: () => void\n}) {\n const styles = useStyles()\n const { attachments, metaProps, onMessageAttachmentLongPress, onMessageLongPress } = props\n const deletingAttachmentIds = useDeletingIds('deleteAttachment')\n if (!attachments || attachments.length === 0) return null\n\n const imageAttachments = attachments.filter(\n attachment =>\n attachment.type === 'MessageAttachment' &&\n attachment.attributes?.contentType?.startsWith('image/')\n ) as DenormalizedMessageAttachmentResource[]\n\n const showImageAttachmentGroup = imageAttachments.length > 0\n\n return (\n <View style={styles.attachmentsContainer}>\n {showImageAttachmentGroup &&\n imageAttachments.map((image, index) => (\n <ImageAttachment\n key={`${image.id}-${index}`}\n attachment={image}\n imageAttachments={imageAttachments}\n currentImageIndex={index}\n metaProps={metaProps}\n onMessageAttachmentLongPress={onMessageAttachmentLongPress}\n isDeleting={deletingAttachmentIds.has(image.id)}\n />\n ))}\n\n {attachments.map((attachment, index) => {\n switch (attachment.type) {\n case 'MessageAttachment':\n return (\n <MessageAttachment\n key={`${attachment.id}-${index}`}\n attachment={attachment}\n onMessageAttachmentLongPress={onMessageAttachmentLongPress}\n isDeleting={deletingAttachmentIds.has(attachment.id)}\n />\n )\n case 'giphy':\n return (\n <GiphyAttachment\n key={`${attachment.id || attachment.titleLink}-${index}`}\n attachment={attachment}\n onMessageLongPress={onMessageLongPress}\n />\n )\n case 'ExpandedLink':\n return (\n <ExpandedLink\n key={`${attachment.id}-${index}`}\n attachment={attachment}\n onMessageLongPress={onMessageLongPress}\n />\n )\n default:\n return null\n }\n })}\n </View>\n )\n}\n\nfunction MessageAttachment({\n attachment,\n onMessageAttachmentLongPress,\n isDeleting,\n}: {\n attachment: DenormalizedMessageAttachmentResource\n onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void\n isDeleting: boolean\n}) {\n const { attributes } = attachment\n const contentType = attributes?.contentType\n const basicType = contentType ? contentType.split('/')[0] : ''\n\n switch (basicType) {\n case 'video':\n return (\n <VideoAttachment\n attachment={attachment}\n onMessageAttachmentLongPress={onMessageAttachmentLongPress}\n isDeleting={isDeleting}\n />\n )\n case 'audio':\n return (\n <AudioAttachment\n attachment={attachment}\n onMessageAttachmentLongPress={onMessageAttachmentLongPress}\n isDeleting={isDeleting}\n />\n )\n case 'application':\n return (\n <GenericFileAttachment\n attachment={attachment}\n onMessageAttachmentLongPress={onMessageAttachmentLongPress}\n isDeleting={isDeleting}\n />\n )\n default:\n return null\n }\n}\n\nconst useStyles = () => {\n return StyleSheet.create({\n attachmentsContainer: {\n gap: 2,\n padding: 2,\n },\n })\n}\n"]}
|
package/build/hooks/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './use_animated_message_background_color';
|
|
|
3
3
|
export * from './use_theme';
|
|
4
4
|
export * from './use_suspense_api';
|
|
5
5
|
export * from './use_current_person';
|
|
6
|
+
export * from './use_deleting_ids';
|
|
6
7
|
export * from './use_font_scale';
|
|
7
8
|
export * from './use_create_android_ripple_color';
|
|
8
9
|
export * from './use_chat_permissions';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yCAAyC,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yCAAyC,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA"}
|
package/build/hooks/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from './use_animated_message_background_color';
|
|
|
3
3
|
export * from './use_theme';
|
|
4
4
|
export * from './use_suspense_api';
|
|
5
5
|
export * from './use_current_person';
|
|
6
|
+
export * from './use_deleting_ids';
|
|
6
7
|
export * from './use_font_scale';
|
|
7
8
|
export * from './use_create_android_ripple_color';
|
|
8
9
|
export * from './use_chat_permissions';
|
package/build/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yCAAyC,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA","sourcesContent":["export * from './use_async_storage'\nexport * from './use_animated_message_background_color'\nexport * from './use_theme'\nexport * from './use_suspense_api'\nexport * from './use_current_person'\nexport * from './use_font_scale'\nexport * from './use_create_android_ripple_color'\nexport * from './use_chat_permissions'\nexport * from './use_api_client'\nexport * from './use_groups_groups'\nexport * from './use_groups'\nexport * from './use_api'\nexport * from './use_api_client'\nexport * from './use_message_reaction_toggle'\nexport * from './use_interaction_ghost_color'\nexport * from './use_at_font_scale_breakpoint'\nexport * from './use_qualified_by_age'\nexport * from './use_scalable_number_of_lines'\nexport * from './use_submit_age_check'\nexport * from './use_organization'\nexport * from './use_product_analytics'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yCAAyC,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA","sourcesContent":["export * from './use_async_storage'\nexport * from './use_animated_message_background_color'\nexport * from './use_theme'\nexport * from './use_suspense_api'\nexport * from './use_current_person'\nexport * from './use_deleting_ids'\nexport * from './use_font_scale'\nexport * from './use_create_android_ripple_color'\nexport * from './use_chat_permissions'\nexport * from './use_api_client'\nexport * from './use_groups_groups'\nexport * from './use_groups'\nexport * from './use_api'\nexport * from './use_api_client'\nexport * from './use_message_reaction_toggle'\nexport * from './use_interaction_ghost_color'\nexport * from './use_at_font_scale_breakpoint'\nexport * from './use_qualified_by_age'\nexport * from './use_scalable_number_of_lines'\nexport * from './use_submit_age_check'\nexport * from './use_organization'\nexport * from './use_product_analytics'\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_deleting_ids.d.ts","sourceRoot":"","sources":["../../src/hooks/use_deleting_ids.ts"],"names":[],"mappings":"AAGA,KAAK,sBAAsB,GAAG,kBAAkB,CAAA;AAEhD,wBAAgB,cAAc,CAAC,KAAK,EAAE,sBAAsB,GAAG,GAAG,CAAC,MAAM,CAAC,CAgBzE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useMutationState } from '@tanstack/react-query';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
export function useDeletingIds(event) {
|
|
4
|
+
const ids = useMutationState({
|
|
5
|
+
filters: {
|
|
6
|
+
mutationKey: [event],
|
|
7
|
+
status: 'pending',
|
|
8
|
+
},
|
|
9
|
+
select: mutation => {
|
|
10
|
+
// Extract the item ID from the mutation key: [ event, id ]
|
|
11
|
+
const key = mutation.options.mutationKey;
|
|
12
|
+
return key && Array.isArray(key) && typeof key[1] === 'string' ? key[1] : null;
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
return useMemo(() => {
|
|
16
|
+
return new Set(ids.filter(id => id !== null));
|
|
17
|
+
}, [ids]);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=use_deleting_ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_deleting_ids.js","sourceRoot":"","sources":["../../src/hooks/use_deleting_ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAI/B,MAAM,UAAU,cAAc,CAAC,KAA6B;IAC1D,MAAM,GAAG,GAAG,gBAAgB,CAAC;QAC3B,OAAO,EAAE;YACP,WAAW,EAAE,CAAC,KAAK,CAAC;YACpB,MAAM,EAAE,SAAS;SAClB;QACD,MAAM,EAAE,QAAQ,CAAC,EAAE;YACjB,2DAA2D;YAC3D,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAA;YACxC,OAAO,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAChF,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAA;IAC/C,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;AACX,CAAC","sourcesContent":["import { useMutationState } from '@tanstack/react-query'\nimport { useMemo } from 'react'\n\ntype DeletableResourceEvent = 'deleteAttachment'\n\nexport function useDeletingIds(event: DeletableResourceEvent): Set<string> {\n const ids = useMutationState({\n filters: {\n mutationKey: [event],\n status: 'pending',\n },\n select: mutation => {\n // Extract the item ID from the mutation key: [ event, id ]\n const key = mutation.options.mutationKey\n return key && Array.isArray(key) && typeof key[1] === 'string' ? key[1] : null\n },\n })\n\n return useMemo(() => {\n return new Set(ids.filter(id => id !== null))\n }, [ids])\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment_actions_screen.d.ts","sourceRoot":"","sources":["../../../src/screens/attachment_actions/attachment_actions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAsB,MAAM,OAAO,CAAA;AAK1C,eAAO,MAAM,8BAA8B,uEAEzC,CAAA;AAEF,MAAM,MAAM,4BAA4B,GAAG,iBAAiB,CAAC;IAC3D,YAAY,EAAE,MAAM,CAAA;IACpB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,4BAA4B,EAAE,OAAO,CAAA;IACrC,SAAS,EAAE,OAAO,CAAA;CACnB,CAAC,CAAA;AAEF,wBAAgB,uBAAuB,CAAC,EAAE,KAAK,EAAE,EAAE,4BAA4B,
|
|
1
|
+
{"version":3,"file":"attachment_actions_screen.d.ts","sourceRoot":"","sources":["../../../src/screens/attachment_actions/attachment_actions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAsB,MAAM,OAAO,CAAA;AAK1C,eAAO,MAAM,8BAA8B,uEAEzC,CAAA;AAEF,MAAM,MAAM,4BAA4B,GAAG,iBAAiB,CAAC;IAC3D,YAAY,EAAE,MAAM,CAAA;IACpB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,4BAA4B,EAAE,OAAO,CAAA;IACrC,SAAS,EAAE,OAAO,CAAA;CACnB,CAAC,CAAA;AAEF,wBAAgB,uBAAuB,CAAC,EAAE,KAAK,EAAE,EAAE,4BAA4B,qBAgE9E"}
|
|
@@ -20,9 +20,16 @@ export function AttachmentActionsScreen({ route }) {
|
|
|
20
20
|
const handleDeleteConfirm = useCallback(() => {
|
|
21
21
|
Alert.alert(`Delete ${attachmentName}`, 'Are you sure you want to permanently delete this attachment?', [
|
|
22
22
|
{ text: 'Cancel', style: 'cancel' },
|
|
23
|
-
{
|
|
23
|
+
{
|
|
24
|
+
text: 'Delete',
|
|
25
|
+
style: 'destructive',
|
|
26
|
+
onPress: () => {
|
|
27
|
+
handleDeleteAttachment();
|
|
28
|
+
navigation.goBack();
|
|
29
|
+
},
|
|
30
|
+
},
|
|
24
31
|
]);
|
|
25
|
-
}, [attachmentName, handleDeleteAttachment]);
|
|
32
|
+
}, [attachmentName, handleDeleteAttachment, navigation]);
|
|
26
33
|
const handleOpenInBrowser = () => {
|
|
27
34
|
Linking.openURL(attachmentUrl);
|
|
28
35
|
navigation.goBack();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment_actions_screen.js","sourceRoot":"","sources":["../../../src/screens/attachment_actions/attachment_actions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,SAAS,EAAE,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAA;AAC5F,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEjE,MAAM,CAAC,MAAM,8BAA8B,GAAG,yBAAyB,CAAC;IACtE,WAAW,EAAE,oBAAoB;CAClC,CAAC,CAAA;AAWF,MAAM,UAAU,uBAAuB,CAAC,EAAE,KAAK,EAAgC;IAC7E,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,EACJ,YAAY,EACZ,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,4BAA4B,EAC5B,SAAS,GACV,GAAG,KAAK,CAAC,MAAM,CAAA;IAEhB,MAAM,cAAc,GAAG,sBAAsB,CAAC,qBAAqB,CAAC,CAAA;IACpE,MAAM,SAAS,GAAG,SAAS,IAAI,4BAA4B,CAAA;IAC3D,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAE1B,MAAM,EAAE,sBAAsB,EAAE,GAAG,mBAAmB,CAAC;QACrD,eAAe;QACf,YAAY;QACZ,cAAc;KACf,CAAC,CAAA;IAEF,MAAM,mBAAmB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC3C,KAAK,CAAC,KAAK,CACT,UAAU,cAAc,EAAE,EAC1B,8DAA8D,EAC9D;YACE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;YACnC,
|
|
1
|
+
{"version":3,"file":"attachment_actions_screen.js","sourceRoot":"","sources":["../../../src/screens/attachment_actions/attachment_actions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cA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O,EAAE,CAAA;AACX,CAAC","sourcesContent":["import { StaticScreenProps, useNavigation } from '@react-navigation/native'\nimport React, { useCallback } from 'react'\nimport { Alert, Linking, StyleSheet } from 'react-native'\nimport FormSheet, { getFormSheetScreenOptions } from '../../components/primitive/form_sheet'\nimport { useDeleteAttachment } from './hooks/useDeleteAttachment'\n\nexport const AttachmentActionsScreenOptions = getFormSheetScreenOptions({\n headerTitle: 'Attachment actions',\n})\n\nexport type AttachmentActionsScreenProps = StaticScreenProps<{\n attachmentId: string\n attachmentContentType: string\n attachmentUrl: string\n conversation_id: number\n canDeleteNonAuthoredMessages: boolean\n myMessage: boolean\n}>\n\nexport function AttachmentActionsScreen({ route }: AttachmentActionsScreenProps) {\n const navigation = useNavigation()\n const {\n attachmentId,\n attachmentContentType,\n attachmentUrl,\n conversation_id,\n canDeleteNonAuthoredMessages,\n myMessage,\n } = route.params\n\n const attachmentName = getAttachmentLabelName(attachmentContentType)\n const canDelete = myMessage || canDeleteNonAuthoredMessages\n const styles = useStyles()\n\n const { handleDeleteAttachment } = useDeleteAttachment({\n conversation_id,\n attachmentId,\n attachmentName,\n })\n\n const handleDeleteConfirm = useCallback(() => {\n Alert.alert(\n `Delete ${attachmentName}`,\n 'Are you sure you want to permanently delete this attachment?',\n [\n { text: 'Cancel', style: 'cancel' },\n {\n text: 'Delete',\n style: 'destructive',\n onPress: () => {\n handleDeleteAttachment()\n navigation.goBack()\n },\n },\n ]\n )\n }, [attachmentName, handleDeleteAttachment, navigation])\n\n const handleOpenInBrowser = () => {\n Linking.openURL(attachmentUrl)\n navigation.goBack()\n }\n\n return (\n <FormSheet.Root contentStyle={styles.formSheetContent}>\n <FormSheet.Action\n iconName=\"general.newWindow\"\n title=\"Open in browser\"\n accessibilityRole=\"link\"\n accessibilityLabel={`Open ${attachmentName} in browser`}\n accessibilityHint={`${attachmentName} can be downloaded and shared through the browser.`}\n onPress={handleOpenInBrowser}\n />\n {canDelete && (\n <FormSheet.Action\n appearance=\"danger\"\n iconName=\"publishing.trash\"\n title={`Delete ${attachmentName}`}\n onPress={handleDeleteConfirm}\n />\n )}\n </FormSheet.Root>\n )\n}\n\nconst useStyles = () => {\n return StyleSheet.create({\n formSheetContent: {\n paddingTop: 16,\n },\n })\n}\n\nfunction getAttachmentLabelName(contentType: string) {\n if (contentType.startsWith('image/')) return 'image'\n if (contentType.startsWith('video/')) return 'video'\n if (contentType.startsWith('audio/')) return 'audio'\n if (contentType === 'application/pdf') return 'PDF'\n if (contentType.startsWith('application/')) return 'file'\n\n return ''\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeleteAttachment.d.ts","sourceRoot":"","sources":["../../../../src/screens/attachment_actions/hooks/useDeleteAttachment.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDeleteAttachment.d.ts","sourceRoot":"","sources":["../../../../src/screens/attachment_actions/hooks/useDeleteAttachment.tsx"],"names":[],"mappings":"AAOA,KAAK,wBAAwB,GAAG;IAC9B,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,wBAAgB,mBAAmB,CAAC,EAClC,eAAe,EACf,YAAY,EACZ,cAAc,GACf,EAAE,wBAAwB;;EA4B1B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Alert } from 'react-native';
|
|
2
|
-
import { useNavigation } from '@react-navigation/native';
|
|
3
2
|
import { useMutation } from '@tanstack/react-query';
|
|
4
3
|
import { useApiClient } from '../../../hooks/use_api_client';
|
|
5
4
|
import { useCallback } from 'react';
|
|
@@ -7,7 +6,6 @@ import { useConversationMessages } from '../../../hooks/use_conversation_message
|
|
|
7
6
|
import { Haptic } from '../../../utils/native_adapters';
|
|
8
7
|
export function useDeleteAttachment({ conversation_id, attachmentId, attachmentName, }) {
|
|
9
8
|
const apiClient = useApiClient();
|
|
10
|
-
const navigation = useNavigation();
|
|
11
9
|
const { refetch } = useConversationMessages({ conversation_id }, { refetchOnMount: false });
|
|
12
10
|
const deleteAttachment = useCallback(() => {
|
|
13
11
|
const url = `/me/conversations/${conversation_id}/message_attachments/${attachmentId}`;
|
|
@@ -15,10 +13,10 @@ export function useDeleteAttachment({ conversation_id, attachmentId, attachmentN
|
|
|
15
13
|
}, [apiClient, conversation_id, attachmentId]);
|
|
16
14
|
const { mutate: handleDeleteAttachment } = useMutation({
|
|
17
15
|
mutationFn: deleteAttachment,
|
|
16
|
+
mutationKey: ['deleteAttachment', attachmentId],
|
|
18
17
|
onSuccess: () => {
|
|
19
18
|
refetch();
|
|
20
19
|
Haptic.notificationSuccess();
|
|
21
|
-
navigation.goBack();
|
|
22
20
|
},
|
|
23
21
|
onError: () => {
|
|
24
22
|
Alert.alert('Oops', `We were unable to delete this ${attachmentName} attachment. Please try again.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeleteAttachment.js","sourceRoot":"","sources":["../../../../src/screens/attachment_actions/hooks/useDeleteAttachment.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useDeleteAttachment.js","sourceRoot":"","sources":["../../../../src/screens/attachment_actions/hooks/useDeleteAttachment.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAA;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAA;AAQvD,MAAM,UAAU,mBAAmB,CAAC,EAClC,eAAe,EACf,YAAY,EACZ,cAAc,GACW;IACzB,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,EAAE,OAAO,EAAE,GAAG,uBAAuB,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAA;IAE3F,MAAM,gBAAgB,GAAG,WAAW,CAAC,GAAG,EAAE;QACxC,MAAM,GAAG,GAAG,qBAAqB,eAAe,wBAAwB,YAAY,EAAE,CAAA;QAEtF,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAA;IACvC,CAAC,EAAE,CAAC,SAAS,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC,CAAA;IAE9C,MAAM,EAAE,MAAM,EAAE,sBAAsB,EAAE,GAAG,WAAW,CAAC;QACrD,UAAU,EAAE,gBAAgB;QAC5B,WAAW,EAAE,CAAC,kBAAkB,EAAE,YAAY,CAAC;QAC/C,SAAS,EAAE,GAAG,EAAE;YACd,OAAO,EAAE,CAAA;YACT,MAAM,CAAC,mBAAmB,EAAE,CAAA;QAC9B,CAAC;QACD,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,CAAC,KAAK,CACT,MAAM,EACN,iCAAiC,cAAc,gCAAgC,CAChF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;IAEF,OAAO;QACL,sBAAsB;KACvB,CAAA;AACH,CAAC","sourcesContent":["import { Alert } from 'react-native'\nimport { useMutation } from '@tanstack/react-query'\nimport { useApiClient } from '../../../hooks/use_api_client'\nimport { useCallback } from 'react'\nimport { useConversationMessages } from '../../../hooks/use_conversation_messages'\nimport { Haptic } from '../../../utils/native_adapters'\n\ntype UseDeleteAttachmentProps = {\n conversation_id: number\n attachmentId: string | undefined\n attachmentName: string\n}\n\nexport function useDeleteAttachment({\n conversation_id,\n attachmentId,\n attachmentName,\n}: UseDeleteAttachmentProps) {\n const apiClient = useApiClient()\n const { refetch } = useConversationMessages({ conversation_id }, { refetchOnMount: false })\n\n const deleteAttachment = useCallback(() => {\n const url = `/me/conversations/${conversation_id}/message_attachments/${attachmentId}`\n\n return apiClient.chat.delete({ url })\n }, [apiClient, conversation_id, attachmentId])\n\n const { mutate: handleDeleteAttachment } = useMutation({\n mutationFn: deleteAttachment,\n mutationKey: ['deleteAttachment', attachmentId],\n onSuccess: () => {\n refetch()\n Haptic.notificationSuccess()\n },\n onError: () => {\n Alert.alert(\n 'Oops',\n `We were unable to delete this ${attachmentName} attachment. Please try again.`\n )\n },\n })\n\n return {\n handleDeleteAttachment,\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.22.0-rc.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"react-native-url-polyfill": "^2.0.0",
|
|
59
59
|
"typescript": "<5.6.0"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "c2228e57eb9d8428f1f393cd375a548f6967e7c4"
|
|
62
62
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, StyleSheet } from 'react-native'
|
|
3
|
+
import { Spinner } from '../../display'
|
|
4
|
+
import { useTheme } from '../../../hooks'
|
|
5
|
+
|
|
6
|
+
export function AttachmentDeletingOverlay() {
|
|
7
|
+
const styles = useStyles()
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<View style={styles.container}>
|
|
11
|
+
<View style={styles.overlay} />
|
|
12
|
+
<Spinner size={24} />
|
|
13
|
+
</View>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const useStyles = () => {
|
|
18
|
+
const { colors } = useTheme()
|
|
19
|
+
|
|
20
|
+
return StyleSheet.create({
|
|
21
|
+
container: {
|
|
22
|
+
...StyleSheet.absoluteFillObject,
|
|
23
|
+
justifyContent: 'center',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
borderRadius: 8,
|
|
26
|
+
overflow: 'hidden',
|
|
27
|
+
},
|
|
28
|
+
overlay: {
|
|
29
|
+
...StyleSheet.absoluteFillObject,
|
|
30
|
+
backgroundColor: colors.fillColorNeutral070,
|
|
31
|
+
opacity: 0.5,
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
}
|
|
@@ -6,13 +6,16 @@ import { AttachmentCard, AttachmentCardTitle } from './attachment_card'
|
|
|
6
6
|
import { useTheme } from '../../../hooks'
|
|
7
7
|
import { Audio } from '../../../utils/native_adapters'
|
|
8
8
|
import { PlatformPressable } from '@react-navigation/elements'
|
|
9
|
+
import { AttachmentDeletingOverlay } from './attachment_deleting_overlay'
|
|
9
10
|
|
|
10
11
|
export function AudioAttachment({
|
|
11
12
|
attachment,
|
|
12
13
|
onMessageAttachmentLongPress,
|
|
14
|
+
isDeleting,
|
|
13
15
|
}: {
|
|
14
16
|
attachment: DenormalizedMessageAttachmentResource
|
|
15
17
|
onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void
|
|
18
|
+
isDeleting: boolean
|
|
16
19
|
}) {
|
|
17
20
|
const styles = useStyles()
|
|
18
21
|
const { colors } = useTheme()
|
|
@@ -34,9 +37,10 @@ export function AudioAttachment({
|
|
|
34
37
|
|
|
35
38
|
return (
|
|
36
39
|
<PlatformPressable
|
|
37
|
-
onLongPress={() => onMessageAttachmentLongPress(attachment)}
|
|
40
|
+
onLongPress={() => !isDeleting && onMessageAttachmentLongPress(attachment)}
|
|
38
41
|
android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}
|
|
39
42
|
accessibilityHint="Long press for more options"
|
|
43
|
+
disabled={isDeleting}
|
|
40
44
|
>
|
|
41
45
|
<AttachmentCard>
|
|
42
46
|
<View style={styles.container}>
|
|
@@ -46,7 +50,7 @@ export function AudioAttachment({
|
|
|
46
50
|
size="md"
|
|
47
51
|
accessibilityLabel={sound.isPlaying ? 'Pause' : 'Play'}
|
|
48
52
|
onPress={toggleAudio}
|
|
49
|
-
disabled={!sound}
|
|
53
|
+
disabled={!sound || isDeleting}
|
|
50
54
|
style={styles.button}
|
|
51
55
|
iconStyle={styles.buttonIcon}
|
|
52
56
|
/>
|
|
@@ -64,6 +68,7 @@ export function AudioAttachment({
|
|
|
64
68
|
)}
|
|
65
69
|
</View>
|
|
66
70
|
</View>
|
|
71
|
+
{isDeleting && <AttachmentDeletingOverlay />}
|
|
67
72
|
</AttachmentCard>
|
|
68
73
|
</PlatformPressable>
|
|
69
74
|
)
|
|
@@ -7,13 +7,16 @@ import { useTheme } from '../../../hooks'
|
|
|
7
7
|
import { PlatformPressable } from '@react-navigation/elements'
|
|
8
8
|
import { tokens } from '../../../vendor/tapestry/tokens'
|
|
9
9
|
import { Linking } from '../../../utils'
|
|
10
|
+
import { AttachmentDeletingOverlay } from './attachment_deleting_overlay'
|
|
10
11
|
|
|
11
12
|
export function GenericFileAttachment({
|
|
12
13
|
attachment,
|
|
13
14
|
onMessageAttachmentLongPress,
|
|
15
|
+
isDeleting,
|
|
14
16
|
}: {
|
|
15
17
|
attachment: DenormalizedMessageAttachmentResource
|
|
16
18
|
onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void
|
|
19
|
+
isDeleting: boolean
|
|
17
20
|
}) {
|
|
18
21
|
const styles = useStyles()
|
|
19
22
|
const { colors } = useTheme()
|
|
@@ -32,10 +35,11 @@ export function GenericFileAttachment({
|
|
|
32
35
|
return (
|
|
33
36
|
<PlatformPressable
|
|
34
37
|
onPress={handleDownload}
|
|
35
|
-
onLongPress={() => onMessageAttachmentLongPress(attachment)}
|
|
38
|
+
onLongPress={() => !isDeleting && onMessageAttachmentLongPress(attachment)}
|
|
36
39
|
android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}
|
|
37
40
|
accessibilityRole="link"
|
|
38
41
|
accessibilityHint={`Press to open ${fileTypeLabel} in a browser. Long press for more options`}
|
|
42
|
+
disabled={isDeleting}
|
|
39
43
|
>
|
|
40
44
|
<AttachmentCard>
|
|
41
45
|
<View style={styles.container}>
|
|
@@ -44,6 +48,7 @@ export function GenericFileAttachment({
|
|
|
44
48
|
<AttachmentCardTitle>{filename}</AttachmentCardTitle>
|
|
45
49
|
</View>
|
|
46
50
|
</View>
|
|
51
|
+
{isDeleting && <AttachmentDeletingOverlay />}
|
|
47
52
|
</AttachmentCard>
|
|
48
53
|
</PlatformPressable>
|
|
49
54
|
)
|
|
@@ -34,6 +34,7 @@ import { DenormalizedMessageAttachmentResource } from '../../../types/resources/
|
|
|
34
34
|
import { PlatformPressable } from '@react-navigation/elements'
|
|
35
35
|
import { useTheme } from '../../../hooks'
|
|
36
36
|
import { Haptic, platformFontWeightMedium } from '../../../utils'
|
|
37
|
+
import { AttachmentDeletingOverlay } from './attachment_deleting_overlay'
|
|
37
38
|
|
|
38
39
|
const { width: WINDOW_WIDTH, height: WINDOW_HEIGHT } = Dimensions.get('window')
|
|
39
40
|
const DISMISS_PAN_THRESHOLD = 175
|
|
@@ -64,12 +65,14 @@ export function ImageAttachment({
|
|
|
64
65
|
currentImageIndex,
|
|
65
66
|
metaProps,
|
|
66
67
|
onMessageAttachmentLongPress,
|
|
68
|
+
isDeleting,
|
|
67
69
|
}: {
|
|
68
70
|
attachment: DenormalizedMessageAttachmentResource
|
|
69
71
|
imageAttachments: DenormalizedMessageAttachmentResource[]
|
|
70
72
|
currentImageIndex: number
|
|
71
73
|
metaProps: MetaProps
|
|
72
74
|
onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void
|
|
75
|
+
isDeleting: boolean
|
|
73
76
|
}) {
|
|
74
77
|
const { attributes } = attachment
|
|
75
78
|
const { url, urlMedium, filename, metadata = {} } = attributes
|
|
@@ -87,12 +90,15 @@ export function ImageAttachment({
|
|
|
87
90
|
<PlatformPressable
|
|
88
91
|
style={styles.container}
|
|
89
92
|
onPress={() => {
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
if (!isDeleting) {
|
|
94
|
+
setModalKey(prev => prev + 1)
|
|
95
|
+
setVisible(true)
|
|
96
|
+
}
|
|
92
97
|
}}
|
|
93
|
-
onLongPress={() => onMessageAttachmentLongPress(attachment)}
|
|
98
|
+
onLongPress={() => !isDeleting && onMessageAttachmentLongPress(attachment)}
|
|
94
99
|
android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}
|
|
95
100
|
accessibilityHint="Long press for more options"
|
|
101
|
+
disabled={isDeleting}
|
|
96
102
|
>
|
|
97
103
|
<Image
|
|
98
104
|
source={{ uri: urlMedium || url }}
|
|
@@ -100,6 +106,7 @@ export function ImageAttachment({
|
|
|
100
106
|
wrapperStyle={styles.attachmentImageWrapper}
|
|
101
107
|
alt={filename}
|
|
102
108
|
/>
|
|
109
|
+
{isDeleting && <AttachmentDeletingOverlay />}
|
|
103
110
|
</PlatformPressable>
|
|
104
111
|
<LightboxModal
|
|
105
112
|
key={modalKey}
|
|
@@ -931,6 +938,7 @@ const useStyles = ({ imageWidth = 100, imageHeight = 100 }: UseStylesProps = {})
|
|
|
931
938
|
return StyleSheet.create({
|
|
932
939
|
container: {
|
|
933
940
|
maxWidth: '100%',
|
|
941
|
+
position: 'relative',
|
|
934
942
|
},
|
|
935
943
|
touchEventIsolator: {
|
|
936
944
|
flex: 1,
|
|
@@ -7,13 +7,16 @@ import { Video, VideoPlayerHandle } from '../../../utils/native_adapters'
|
|
|
7
7
|
import { PlatformPressable } from '@react-navigation/elements'
|
|
8
8
|
import { useTheme } from '../../../hooks'
|
|
9
9
|
import { tokens } from '../../../vendor/tapestry/tokens'
|
|
10
|
+
import { AttachmentDeletingOverlay } from './attachment_deleting_overlay'
|
|
10
11
|
|
|
11
12
|
export function VideoAttachment({
|
|
12
13
|
attachment,
|
|
13
14
|
onMessageAttachmentLongPress,
|
|
15
|
+
isDeleting,
|
|
14
16
|
}: {
|
|
15
17
|
attachment: DenormalizedMessageAttachmentResource
|
|
16
18
|
onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void
|
|
19
|
+
isDeleting: boolean
|
|
17
20
|
}) {
|
|
18
21
|
const { colors } = useTheme()
|
|
19
22
|
const styles = useStyles()
|
|
@@ -45,10 +48,11 @@ export function VideoAttachment({
|
|
|
45
48
|
<View style={styles.container} ref={viewRef}>
|
|
46
49
|
<PlatformPressable
|
|
47
50
|
onPress={openVideo}
|
|
48
|
-
onLongPress={() => onMessageAttachmentLongPress(attachment)}
|
|
51
|
+
onLongPress={() => !isDeleting && onMessageAttachmentLongPress(attachment)}
|
|
49
52
|
android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}
|
|
50
53
|
accessibilityLabel="Play Video"
|
|
51
54
|
accessibilityHint="Press to play video. Long press for more options"
|
|
55
|
+
disabled={isDeleting}
|
|
52
56
|
>
|
|
53
57
|
<View style={styles.thumbnailOverlay} />
|
|
54
58
|
<Video.Player
|
|
@@ -58,7 +62,7 @@ export function VideoAttachment({
|
|
|
58
62
|
style={styles.video}
|
|
59
63
|
onFullscreenPlayerWillDismiss={onFullscreenPlayerWillDismiss}
|
|
60
64
|
/>
|
|
61
|
-
{!isOpen && (
|
|
65
|
+
{!isOpen && !isDeleting && (
|
|
62
66
|
<View style={styles.playContainer}>
|
|
63
67
|
<View style={styles.playCircle}>
|
|
64
68
|
<Icon
|
|
@@ -69,6 +73,7 @@ export function VideoAttachment({
|
|
|
69
73
|
</View>
|
|
70
74
|
</View>
|
|
71
75
|
)}
|
|
76
|
+
{isDeleting && <AttachmentDeletingOverlay />}
|
|
72
77
|
</PlatformPressable>
|
|
73
78
|
</View>
|
|
74
79
|
)
|