stream-chat-react-native-core 4.7.0-beta.1 → 4.7.0-beta.4
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/README.md +1 -0
- package/lib/commonjs/components/Attachment/Card.js +23 -14
- package/lib/commonjs/components/Attachment/Card.js.map +1 -1
- package/lib/commonjs/components/Chat/hooks/useIsOnline.js +6 -6
- package/lib/commonjs/components/Chat/hooks/useIsOnline.js.map +1 -1
- package/lib/commonjs/components/Message/Message.js +6 -6
- package/lib/commonjs/components/Message/Message.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/renderText.js +22 -15
- package/lib/commonjs/components/Message/MessageSimple/utils/renderText.js.map +1 -1
- package/lib/commonjs/components/Reply/Reply.js +5 -5
- package/lib/commonjs/components/Reply/Reply.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +15 -4
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Card.js +23 -14
- package/lib/module/components/Attachment/Card.js.map +1 -1
- package/lib/module/components/Chat/hooks/useIsOnline.js +6 -6
- package/lib/module/components/Chat/hooks/useIsOnline.js.map +1 -1
- package/lib/module/components/Message/Message.js +6 -6
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/utils/renderText.js +22 -15
- package/lib/module/components/Message/MessageSimple/utils/renderText.js.map +1 -1
- package/lib/module/components/Reply/Reply.js +5 -5
- package/lib/module/components/Reply/Reply.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +15 -4
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Chat/hooks/useIsOnline.d.ts +1 -1
- package/lib/typescript/components/Message/Message.d.ts +9 -3
- package/package.json +2 -2
- package/src/components/Attachment/Card.tsx +3 -0
- package/src/components/Chat/hooks/useIsOnline.ts +7 -7
- package/src/components/Message/Message.tsx +8 -4
- package/src/components/Message/MessageSimple/utils/renderText.tsx +6 -1
- package/src/components/Reply/Reply.tsx +3 -1
- package/src/contexts/messageInputContext/MessageInputContext.tsx +11 -0
- package/src/version.json +1 -1
|
@@ -13,7 +13,7 @@ import type { DefaultStreamChatGenerics } from '../../../types/types';
|
|
|
13
13
|
/**
|
|
14
14
|
* Disconnect the websocket connection when app goes to background,
|
|
15
15
|
* and reconnect when app comes to foreground.
|
|
16
|
-
* We do this to make sure
|
|
16
|
+
* We do this to make sure the user receives push notifications when app is in the background.
|
|
17
17
|
* You can't receive push notification until you have active websocket connection.
|
|
18
18
|
*/
|
|
19
19
|
export const useIsOnline = <
|
|
@@ -25,10 +25,10 @@ export const useIsOnline = <
|
|
|
25
25
|
const [isOnline, setIsOnline] = useState(true);
|
|
26
26
|
const [connectionRecovering, setConnectionRecovering] = useState(false);
|
|
27
27
|
const isMounted = useIsMountedRef();
|
|
28
|
-
const
|
|
28
|
+
const clientExists = !!client;
|
|
29
29
|
|
|
30
30
|
const onBackground = useCallback(() => {
|
|
31
|
-
if (!closeConnectionOnBackground) return;
|
|
31
|
+
if (!closeConnectionOnBackground || !clientExists) return;
|
|
32
32
|
|
|
33
33
|
for (const cid in client.activeChannels) {
|
|
34
34
|
const channel = client.activeChannels[cid];
|
|
@@ -37,13 +37,13 @@ export const useIsOnline = <
|
|
|
37
37
|
|
|
38
38
|
client.closeConnection();
|
|
39
39
|
setIsOnline(false);
|
|
40
|
-
}, [closeConnectionOnBackground, client]);
|
|
40
|
+
}, [closeConnectionOnBackground, client, clientExists]);
|
|
41
41
|
|
|
42
42
|
const onForeground = useCallback(() => {
|
|
43
|
-
if (!closeConnectionOnBackground) return;
|
|
43
|
+
if (!closeConnectionOnBackground || !clientExists) return;
|
|
44
44
|
|
|
45
45
|
client.openConnection();
|
|
46
|
-
}, [closeConnectionOnBackground, client]);
|
|
46
|
+
}, [closeConnectionOnBackground, client, clientExists]);
|
|
47
47
|
|
|
48
48
|
useAppStateListener(onForeground, onBackground);
|
|
49
49
|
|
|
@@ -101,7 +101,7 @@ export const useIsOnline = <
|
|
|
101
101
|
chatListeners.forEach((listener) => listener.unsubscribe?.());
|
|
102
102
|
unsubscribeNetInfo?.();
|
|
103
103
|
};
|
|
104
|
-
}, [
|
|
104
|
+
}, [clientExists]);
|
|
105
105
|
|
|
106
106
|
return { connectionRecovering, isOnline };
|
|
107
107
|
};
|
|
@@ -53,15 +53,13 @@ import {
|
|
|
53
53
|
import type { MessageActionListItemProps } from '../MessageOverlay/MessageActionListItem';
|
|
54
54
|
|
|
55
55
|
export type TouchableEmitter =
|
|
56
|
-
| 'card'
|
|
57
56
|
| 'fileAttachment'
|
|
58
57
|
| 'gallery'
|
|
59
58
|
| 'giphy'
|
|
60
59
|
| 'message'
|
|
61
60
|
| 'messageContent'
|
|
62
61
|
| 'messageReplies'
|
|
63
|
-
| 'reactionList'
|
|
64
|
-
| 'textLink';
|
|
62
|
+
| 'reactionList';
|
|
65
63
|
|
|
66
64
|
export type TextMentionTouchableHandlerPayload<
|
|
67
65
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -70,21 +68,27 @@ export type TextMentionTouchableHandlerPayload<
|
|
|
70
68
|
additionalInfo?: { user?: UserResponse<StreamChatGenerics> };
|
|
71
69
|
};
|
|
72
70
|
|
|
71
|
+
export type UrlTouchableHandlerPayload = {
|
|
72
|
+
emitter: 'textLink' | 'card';
|
|
73
|
+
additionalInfo?: { url?: string };
|
|
74
|
+
};
|
|
75
|
+
|
|
73
76
|
export type TouchableHandlerPayload = {
|
|
74
77
|
defaultHandler?: () => void;
|
|
75
78
|
event?: GestureResponderEvent;
|
|
76
79
|
} & (
|
|
77
80
|
| {
|
|
78
|
-
additionalInfo?: Record<string, unknown>;
|
|
79
81
|
emitter?: TouchableEmitter;
|
|
80
82
|
}
|
|
81
83
|
| TextMentionTouchableHandlerPayload
|
|
84
|
+
| UrlTouchableHandlerPayload
|
|
82
85
|
);
|
|
83
86
|
|
|
84
87
|
export type MessageTouchableHandlerPayload<
|
|
85
88
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
86
89
|
> = TouchableHandlerPayload & {
|
|
87
90
|
actionHandlers?: MessageActionHandlers;
|
|
91
|
+
additionalInfo?: Record<string, unknown>;
|
|
88
92
|
message?: MessageType<StreamChatGenerics>;
|
|
89
93
|
};
|
|
90
94
|
|
|
@@ -161,10 +161,14 @@ export const renderText = <
|
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
const link: ReactNodeOutput = (node, output, { ...state }) => {
|
|
164
|
+
const url = node.target;
|
|
164
165
|
const onPress = (event: GestureResponderEvent) => {
|
|
165
166
|
if (!preventPress && onPressParam) {
|
|
166
167
|
onPressParam({
|
|
167
|
-
|
|
168
|
+
additionalInfo: { url },
|
|
169
|
+
defaultHandler: () => {
|
|
170
|
+
onLink(url);
|
|
171
|
+
},
|
|
168
172
|
emitter: 'textLink',
|
|
169
173
|
event,
|
|
170
174
|
});
|
|
@@ -174,6 +178,7 @@ export const renderText = <
|
|
|
174
178
|
const onLongPress = (event: GestureResponderEvent) => {
|
|
175
179
|
if (!preventPress && onLongPressParam) {
|
|
176
180
|
onLongPressParam({
|
|
181
|
+
additionalInfo: { url },
|
|
177
182
|
emitter: 'textLink',
|
|
178
183
|
event,
|
|
179
184
|
});
|
|
@@ -203,7 +203,9 @@ const ReplyWithContext = <
|
|
|
203
203
|
/>
|
|
204
204
|
) : null
|
|
205
205
|
) : null}
|
|
206
|
-
{messageType === 'video'
|
|
206
|
+
{messageType === 'video' && !lastAttachment.og_scrape_url ? (
|
|
207
|
+
<VideoThumbnail style={[styles.videoAttachment]} />
|
|
208
|
+
) : null}
|
|
207
209
|
<MessageTextContainer<StreamChatGenerics>
|
|
208
210
|
markdownStyles={
|
|
209
211
|
quotedMessage.deleted_at
|
|
@@ -665,6 +665,8 @@ export const MessageInputProvider = <
|
|
|
665
665
|
attachments.push({
|
|
666
666
|
fallback: image.file.name,
|
|
667
667
|
image_url: image.url,
|
|
668
|
+
original_height: image.height,
|
|
669
|
+
original_width: image.width,
|
|
668
670
|
type: 'image',
|
|
669
671
|
} as Attachment<StreamChatGenerics>);
|
|
670
672
|
}
|
|
@@ -686,6 +688,15 @@ export const MessageInputProvider = <
|
|
|
686
688
|
image_url: file.url,
|
|
687
689
|
type: 'image',
|
|
688
690
|
} as Attachment<StreamChatGenerics>);
|
|
691
|
+
} else if (file.file.type?.startsWith('audio/')) {
|
|
692
|
+
attachments.push({
|
|
693
|
+
asset_url: file.url,
|
|
694
|
+
duration: file.file.duration,
|
|
695
|
+
file_size: file.file.size,
|
|
696
|
+
mime_type: file.file.type,
|
|
697
|
+
title: file.file.name,
|
|
698
|
+
type: 'audio',
|
|
699
|
+
} as Attachment<StreamChatGenerics>);
|
|
689
700
|
} else if (file.file.type?.startsWith('video/')) {
|
|
690
701
|
attachments.push({
|
|
691
702
|
asset_url: file.url,
|
package/src/version.json
CHANGED