stream-chat-react-native-core 5.4.2-beta.1 → 5.4.2-beta.2
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 +122 -433
- package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js +358 -0
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -0
- package/lib/commonjs/components/MessageList/NetworkDownIndicator.js +14 -6
- package/lib/commonjs/components/MessageList/NetworkDownIndicator.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +134 -85
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js +39 -17
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/commonjs/hooks/useAppStateListener.js +9 -15
- package/lib/commonjs/hooks/useAppStateListener.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js +122 -433
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js +358 -0
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -0
- package/lib/module/components/MessageList/NetworkDownIndicator.js +14 -6
- package/lib/module/components/MessageList/NetworkDownIndicator.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +134 -85
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayProvider.js +39 -17
- package/lib/module/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/module/hooks/useAppStateListener.js +9 -15
- package/lib/module/hooks/useAppStateListener.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/AttachmentPicker/AttachmentPicker.d.ts +0 -11
- package/lib/typescript/components/AttachmentPicker/components/AttachmentPickerItem.d.ts +16 -0
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +1 -1
- package/lib/typescript/hooks/__tests__/useAppStateListener.test.d.ts +1 -0
- package/package.json +2 -2
- package/src/components/AttachmentPicker/AttachmentPicker.tsx +79 -322
- package/src/components/AttachmentPicker/components/AttachmentPickerItem.tsx +245 -0
- package/src/components/MessageList/NetworkDownIndicator.tsx +13 -10
- package/src/contexts/messageInputContext/MessageInputContext.tsx +27 -25
- package/src/contexts/overlayContext/OverlayProvider.tsx +28 -4
- package/src/hooks/__tests__/useAppStateListener.test.tsx +41 -0
- package/src/hooks/useAppStateListener.ts +9 -12
- package/src/version.json +1 -1
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
1
|
Object.defineProperty(exports, "__esModule", {
|
|
4
2
|
value: true
|
|
5
3
|
});
|
|
6
4
|
exports.useAppStateListener = void 0;
|
|
7
5
|
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
-
|
|
10
6
|
var _react = require("react");
|
|
11
7
|
|
|
12
8
|
var _reactNative = require("react-native");
|
|
13
9
|
|
|
14
10
|
var useAppStateListener = function useAppStateListener(onForeground, onBackground) {
|
|
15
|
-
var
|
|
16
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
17
|
-
appState = _useState2[0],
|
|
18
|
-
setAppState = _useState2[1];
|
|
19
|
-
|
|
11
|
+
var appStateRef = (0, _react.useRef)(_reactNative.AppState.currentState);
|
|
20
12
|
var handleAppStateChange = (0, _react.useCallback)(function (nextAppState) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
var prevAppState = appStateRef.current;
|
|
14
|
+
|
|
15
|
+
if (prevAppState.match(/inactive|background/) && nextAppState === 'active') {
|
|
16
|
+
onForeground == null ? void 0 : onForeground();
|
|
17
|
+
} else if (prevAppState === 'active' && nextAppState.match(/inactive|background/)) {
|
|
18
|
+
onBackground == null ? void 0 : onBackground();
|
|
25
19
|
}
|
|
26
20
|
|
|
27
|
-
|
|
28
|
-
}, [onBackground, onForeground
|
|
21
|
+
appStateRef.current = nextAppState;
|
|
22
|
+
}, [onBackground, onForeground]);
|
|
29
23
|
(0, _react.useEffect)(function () {
|
|
30
24
|
var subscription = _reactNative.AppState.addEventListener('change', handleAppStateChange);
|
|
31
25
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useAppStateListener.ts"],"names":["useAppStateListener","onForeground","onBackground","AppState","currentState","
|
|
1
|
+
{"version":3,"sources":["useAppStateListener.ts"],"names":["useAppStateListener","onForeground","onBackground","appStateRef","AppState","currentState","handleAppStateChange","nextAppState","prevAppState","current","match","subscription","addEventListener","remove","removeEventListener"],"mappings":";;;;;AAAA;;AACA;;AAEO,IAAMA,mBAAmB,GAAG,SAAtBA,mBAAsB,CAACC,YAAD,EAA4BC,YAA5B,EAA0D;AAC3F,MAAMC,WAAW,GAAG,mBAAOC,sBAASC,YAAhB,CAApB;AACA,MAAMC,oBAAoB,GAAG,wBAC3B,UAACC,YAAD,EAAkC;AAChC,QAAMC,YAAY,GAAGL,WAAW,CAACM,OAAjC;;AACA,QAAID,YAAY,CAACE,KAAb,CAAmB,qBAAnB,KAA6CH,YAAY,KAAK,QAAlE,EAA4E;AAC1EN,MAAAA,YAAY,QAAZ,YAAAA,YAAY;AACb,KAFD,MAEO,IAAIO,YAAY,KAAK,QAAjB,IAA6BD,YAAY,CAACG,KAAb,CAAmB,qBAAnB,CAAjC,EAA4E;AACjFR,MAAAA,YAAY,QAAZ,YAAAA,YAAY;AACb;;AACDC,IAAAA,WAAW,CAACM,OAAZ,GAAsBF,YAAtB;AACD,GAT0B,EAU3B,CAACL,YAAD,EAAeD,YAAf,CAV2B,CAA7B;AAaA,wBAAU,YAAM;AACd,QAAMU,YAAY,GAAGP,sBAASQ,gBAAT,CAA0B,QAA1B,EAAoCN,oBAApC,CAArB;;AAEA,WAAO,YAAM;AAGX,UAAIK,YAAJ,YAAIA,YAAY,CAAEE,MAAlB,EAA0B;AACxBF,QAAAA,YAAY,CAACE,MAAb;AACD,OAFD,MAEO;AACLT,8BAASU,mBAAT,CAA6B,QAA7B,EAAuCR,oBAAvC;AACD;AACF,KARD;AASD,GAZD,EAYG,CAACA,oBAAD,CAZH;AAaD,CA5BM","sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport { AppState, AppStateStatus } from 'react-native';\n\nexport const useAppStateListener = (onForeground?: () => void, onBackground?: () => void) => {\n const appStateRef = useRef(AppState.currentState);\n const handleAppStateChange = useCallback(\n (nextAppState: AppStateStatus) => {\n const prevAppState = appStateRef.current;\n if (prevAppState.match(/inactive|background/) && nextAppState === 'active') {\n onForeground?.();\n } else if (prevAppState === 'active' && nextAppState.match(/inactive|background/)) {\n onBackground?.();\n }\n appStateRef.current = nextAppState;\n },\n [onBackground, onForeground],\n );\n\n useEffect(() => {\n const subscription = AppState.addEventListener('change', handleAppStateChange);\n\n return () => {\n // Following if-else logic is to support RN >= 0.65 and RN < 0.65 versions.\n // https://github.com/react-native-community/releases/blob/master/CHANGELOG.md#:~:text=EventEmitter%23removeSubscription%20is%20now%20deprecated.%20(cb6cbd12f8%20by%20%40yungsters)\n if (subscription?.remove) {\n subscription.remove();\n } else {\n AppState.removeEventListener('change', handleAppStateChange);\n }\n };\n }, [handleAppStateChange]);\n};\n"]}
|