stream-chat-expo 9.7.3-beta.3 → 9.7.3
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-chat-expo",
|
|
3
3
|
"description": "The official Expo SDK for Stream Chat, a service for building chat applications",
|
|
4
|
-
"version": "9.7.3
|
|
4
|
+
"version": "9.7.3",
|
|
5
5
|
"author": {
|
|
6
6
|
"company": "Stream.io Inc",
|
|
7
7
|
"name": "Stream.io Inc"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"types": "types/index.d.ts",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"mime": "^4.0.7",
|
|
30
|
-
"stream-chat-react-native-core": "9.7.3
|
|
30
|
+
"stream-chat-react-native-core": "9.7.3"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"expo": ">=52.0.0",
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
type SetClipboardStringOptions = {
|
|
2
|
+
onFailure?: (error: unknown) => void;
|
|
3
|
+
onSuccess?: () => void;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
let Clipboard:
|
|
7
|
+
| {
|
|
8
|
+
setString?: (text: string) => void;
|
|
9
|
+
setStringAsync?: (text: string) => Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
| undefined;
|
|
2
12
|
|
|
3
13
|
try {
|
|
4
14
|
Clipboard = require('expo-clipboard');
|
|
@@ -12,6 +22,35 @@ if (!Clipboard) {
|
|
|
12
22
|
);
|
|
13
23
|
}
|
|
14
24
|
|
|
15
|
-
export const setClipboardString =
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
export const setClipboardString =
|
|
26
|
+
Clipboard && (Clipboard.setStringAsync || Clipboard.setString)
|
|
27
|
+
? (text: string, options?: SetClipboardStringOptions) => {
|
|
28
|
+
try {
|
|
29
|
+
// `expo-clipboard` removed the synchronous `setString` in favour of
|
|
30
|
+
// the async API. Keep this handler synchronous (void return,
|
|
31
|
+
// like the legacy `setString`) and fire the async write without
|
|
32
|
+
// awaiting, reporting the outcome through the callbacks. Fall back to
|
|
33
|
+
// `setString` for older versions.
|
|
34
|
+
if (Clipboard?.setStringAsync) {
|
|
35
|
+
Clipboard.setStringAsync(text)
|
|
36
|
+
.then((success) => {
|
|
37
|
+
if (success) {
|
|
38
|
+
options?.onSuccess?.();
|
|
39
|
+
} else {
|
|
40
|
+
options?.onFailure?.(new Error('Copying to clipboard failed'));
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
.catch((error: unknown) => {
|
|
44
|
+
console.log('Copying to clipboard failed...', error);
|
|
45
|
+
options?.onFailure?.(error);
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
Clipboard?.setString?.(text);
|
|
49
|
+
options?.onSuccess?.();
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.log('Copying to clipboard failed...', error);
|
|
53
|
+
options?.onFailure?.(error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
: null;
|