stream-chat-react-native-core 9.0.0-beta.24 → 9.0.0-beta.26
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/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js +19 -0
- package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/commonjs/components/Message/MessageItemView/utils/generateMarkdownText.js +3 -2
- package/lib/commonjs/components/Message/MessageItemView/utils/generateMarkdownText.js.map +1 -1
- package/lib/commonjs/components/Message/MessageItemView/utils/generateMarkdownText.test.js +1 -1
- package/lib/commonjs/components/Message/MessageItemView/utils/generateMarkdownText.test.js.map +1 -1
- package/lib/commonjs/components/Message/hooks/useMessageActionHandlers.js +2 -2
- package/lib/commonjs/components/Message/hooks/useMessageActionHandlers.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +3 -12
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/hooks/useAfterKeyboardOpenCallback.js +1 -3
- package/lib/commonjs/hooks/useAfterKeyboardOpenCallback.js.map +1 -1
- package/lib/commonjs/hooks/useAttachmentPickerBottomSheet.js +0 -23
- package/lib/commonjs/hooks/useAttachmentPickerBottomSheet.js.map +1 -1
- package/lib/commonjs/hooks/useKeyboardVisibility.js +2 -2
- package/lib/commonjs/hooks/useKeyboardVisibility.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js +19 -0
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/module/components/Message/MessageItemView/utils/generateMarkdownText.js +3 -2
- package/lib/module/components/Message/MessageItemView/utils/generateMarkdownText.js.map +1 -1
- package/lib/module/components/Message/MessageItemView/utils/generateMarkdownText.test.js +1 -1
- package/lib/module/components/Message/MessageItemView/utils/generateMarkdownText.test.js.map +1 -1
- package/lib/module/components/Message/hooks/useMessageActionHandlers.js +2 -2
- package/lib/module/components/Message/hooks/useMessageActionHandlers.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +3 -12
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/hooks/useAfterKeyboardOpenCallback.js +1 -3
- package/lib/module/hooks/useAfterKeyboardOpenCallback.js.map +1 -1
- package/lib/module/hooks/useAttachmentPickerBottomSheet.js +0 -23
- package/lib/module/hooks/useAttachmentPickerBottomSheet.js.map +1 -1
- package/lib/module/hooks/useKeyboardVisibility.js +2 -2
- package/lib/module/hooks/useKeyboardVisibility.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/AttachmentPicker/AttachmentPicker.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageItemView/utils/generateMarkdownText.d.ts.map +1 -1
- package/lib/typescript/components/Message/hooks/useMessageActionHandlers.d.ts +1 -0
- package/lib/typescript/components/Message/hooks/useMessageActionHandlers.d.ts.map +1 -1
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts.map +1 -1
- package/lib/typescript/hooks/useAfterKeyboardOpenCallback.d.ts.map +1 -1
- package/lib/typescript/hooks/useAttachmentPickerBottomSheet.d.ts +0 -3
- package/lib/typescript/hooks/useAttachmentPickerBottomSheet.d.ts.map +1 -1
- package/lib/typescript/hooks/useKeyboardVisibility.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/AttachmentPicker/AttachmentPicker.tsx +31 -0
- package/src/components/Message/MessageItemView/utils/generateMarkdownText.test.ts +3 -0
- package/src/components/Message/MessageItemView/utils/generateMarkdownText.ts +4 -2
- package/src/components/Message/hooks/useMessageActionHandlers.ts +3 -1
- package/src/contexts/messageInputContext/MessageInputContext.tsx +4 -14
- package/src/hooks/useAfterKeyboardOpenCallback.ts +1 -4
- package/src/hooks/useAttachmentPickerBottomSheet.ts +1 -34
- package/src/hooks/useKeyboardVisibility.ts +11 -3
- package/src/version.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback,
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import BottomSheet from '@gorhom/bottom-sheet';
|
|
4
4
|
import { BottomSheetMethods } from '@gorhom/bottom-sheet/lib/typescript/types';
|
|
@@ -6,31 +6,14 @@ import { BottomSheetMethods } from '@gorhom/bottom-sheet/lib/typescript/types';
|
|
|
6
6
|
/**
|
|
7
7
|
* This hook is used to manage the state of the attachment picker bottom sheet.
|
|
8
8
|
* It provides functions to open and close the bottom sheet, as well as a reference to the bottom sheet itself.
|
|
9
|
-
* It also handles the cleanup of the timeout used to close the bottom sheet.
|
|
10
9
|
* The bottom sheet is used to display the attachment picker UI.
|
|
11
10
|
* The `openPicker` function opens the bottom sheet, and the `closePicker` function closes it.
|
|
12
11
|
* The `bottomSheetRef` is a reference to the bottom sheet component, which allows for programmatic control of the bottom sheet.
|
|
13
|
-
* The `bottomSheetCloseTimeoutRef` is used to store the timeout ID for the close operation, allowing for cleanup if necessary.
|
|
14
12
|
*/
|
|
15
13
|
export const useAttachmentPickerBottomSheet = () => {
|
|
16
|
-
const bottomSheetCloseTimeoutRef = useRef<ReturnType<typeof setTimeout>>(undefined);
|
|
17
14
|
const bottomSheetRef = useRef<BottomSheet>(null);
|
|
18
15
|
|
|
19
|
-
useEffect(
|
|
20
|
-
() =>
|
|
21
|
-
// cleanup the timeout if the component unmounts
|
|
22
|
-
() => {
|
|
23
|
-
if (bottomSheetCloseTimeoutRef.current) {
|
|
24
|
-
clearTimeout(bottomSheetCloseTimeoutRef.current);
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
[],
|
|
28
|
-
);
|
|
29
|
-
|
|
30
16
|
const openPicker = useCallback((ref: React.RefObject<BottomSheetMethods | null>) => {
|
|
31
|
-
if (bottomSheetCloseTimeoutRef.current) {
|
|
32
|
-
clearTimeout(bottomSheetCloseTimeoutRef.current);
|
|
33
|
-
}
|
|
34
17
|
if (ref.current?.snapToIndex) {
|
|
35
18
|
ref.current.snapToIndex(0);
|
|
36
19
|
} else {
|
|
@@ -40,27 +23,11 @@ export const useAttachmentPickerBottomSheet = () => {
|
|
|
40
23
|
|
|
41
24
|
const closePicker = useCallback((ref: React.RefObject<BottomSheetMethods | null>) => {
|
|
42
25
|
if (ref.current?.close) {
|
|
43
|
-
if (bottomSheetCloseTimeoutRef.current) {
|
|
44
|
-
clearTimeout(bottomSheetCloseTimeoutRef.current);
|
|
45
|
-
}
|
|
46
26
|
ref.current.close();
|
|
47
|
-
// Attempt to close the bottomsheet again to circumvent accidental opening on Android.
|
|
48
|
-
// Details: This to prevent a race condition where the close function is called during the point when a internal container layout happens within the bottomsheet due to keyboard affecting the layout
|
|
49
|
-
// If the container layout measures a shorter height than previous but if the close snapped to the previous height's position, the bottom sheet will show up
|
|
50
|
-
// this short delay ensures that close function is always called after a container layout due to keyboard change
|
|
51
|
-
// NOTE: this timeout has to be above 500 as the keyboardAnimationDuration is 500 in the bottomsheet library - see src/hooks/useKeyboard.ts there for more details
|
|
52
|
-
bottomSheetCloseTimeoutRef.current = setTimeout(() => {
|
|
53
|
-
ref.current?.close();
|
|
54
|
-
}, 600);
|
|
55
27
|
}
|
|
56
28
|
}, []);
|
|
57
29
|
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
closePicker(bottomSheetRef);
|
|
60
|
-
}, [closePicker]);
|
|
61
|
-
|
|
62
30
|
return {
|
|
63
|
-
bottomSheetCloseTimeoutRef,
|
|
64
31
|
bottomSheetRef,
|
|
65
32
|
closePicker,
|
|
66
33
|
openPicker,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import { EventSubscription, Keyboard } from 'react-native';
|
|
2
|
+
import { EventSubscription, Keyboard, Platform } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { KeyboardControllerPackage } from '../components/KeyboardCompatibleView/KeyboardControllerAvoidingView';
|
|
5
5
|
|
|
@@ -24,8 +24,16 @@ export const useKeyboardVisibility = () => {
|
|
|
24
24
|
),
|
|
25
25
|
);
|
|
26
26
|
} else {
|
|
27
|
-
listeners.push(
|
|
28
|
-
|
|
27
|
+
listeners.push(
|
|
28
|
+
Keyboard.addListener(Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow', () =>
|
|
29
|
+
setIsKeyboardVisible(true),
|
|
30
|
+
),
|
|
31
|
+
);
|
|
32
|
+
listeners.push(
|
|
33
|
+
Keyboard.addListener(Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide', () =>
|
|
34
|
+
setIsKeyboardVisible(false),
|
|
35
|
+
),
|
|
36
|
+
);
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
return () => listeners.forEach((listener) => listener.remove());
|
package/src/version.json
CHANGED