@planningcenter/chat-react-native 1.3.0-rc.1 → 1.3.0-rc.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/.eslintrc.yml +2 -0
- package/CHANGELOG.md +11 -0
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +19 -9
- package/build/index.js.map +1 -1
- package/package.json +7 -3
- package/src/index.tsx +32 -13
package/.eslintrc.yml
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.3.0-rc.2](https://github.com/planningcenter/chat-js/compare/v1.2.0...v1.3.0-rc.2) (2025-02-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add auth to the example app ([#50](https://github.com/planningcenter/chat-js/issues/50)) ([5e0ae00](https://github.com/planningcenter/chat-js/commit/5e0ae008345743f6bba388e982a3ad768265971a))
|
|
12
|
+
* drop stream and set global dependencies ([#49](https://github.com/planningcenter/chat-js/issues/49)) ([1214b9f](https://github.com/planningcenter/chat-js/commit/1214b9fbc17f4ab67a1de1d39954604a28268f35))
|
|
13
|
+
* **StreamChat:** export core package ([#41](https://github.com/planningcenter/chat-js/issues/41)) ([e9afde0](https://github.com/planningcenter/chat-js/commit/e9afde0e2a11d9c7e13b84f8eee8a6cfa7aff795)), closes [#45](https://github.com/planningcenter/chat-js/issues/45)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.3.0-rc.1](https://github.com/planningcenter/chat-js/compare/v1.2.0...v1.3.0-rc.1) (2025-02-06)
|
|
7
18
|
|
|
8
19
|
|
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAGlD,wBAAgB,OAAO,CAAC,EACtB,KAAK,EACL,cAAc,GACf,EAAE;IACD,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,cAAc,EAAE,MAAM,IAAI,CAAA;CAC3B,qBAiCA"}
|
package/build/index.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { FlatList, Text } from 'react-native';
|
|
3
|
-
export function PCOChat({ token, onTokenExpired }) {
|
|
2
|
+
import { FlatList, StyleSheet, Text } from 'react-native';
|
|
3
|
+
export function PCOChat({ token, onTokenExpired, }) {
|
|
4
4
|
const [conversations, setConversations] = useState(null);
|
|
5
|
+
const styles = useStyles();
|
|
5
6
|
useEffect(() => {
|
|
6
|
-
if (!token)
|
|
7
|
+
if (!token) {
|
|
7
8
|
return;
|
|
9
|
+
}
|
|
8
10
|
fetch('https://api.planningcenteronline.com/chat/v2/me/conversations', {
|
|
9
11
|
headers: {
|
|
10
|
-
Authorization: `Bearer ${token
|
|
11
|
-
}
|
|
12
|
-
})
|
|
12
|
+
Authorization: `Bearer ${token.access_token}`,
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
.then(validateResponse)
|
|
13
16
|
.then(response => response.json())
|
|
14
17
|
.then(setConversations)
|
|
15
18
|
.catch(error => {
|
|
@@ -17,13 +20,20 @@ export function PCOChat({ token, onTokenExpired }) {
|
|
|
17
20
|
onTokenExpired();
|
|
18
21
|
}
|
|
19
22
|
});
|
|
20
|
-
}, [token]);
|
|
21
|
-
return (<FlatList data={conversations?.data} ListEmptyComponent={<Text>No conversations</Text>} contentContainerStyle={
|
|
23
|
+
}, [onTokenExpired, token]);
|
|
24
|
+
return (<FlatList data={conversations?.data} ListEmptyComponent={<Text>No conversations</Text>} contentContainerStyle={styles.container} ListHeaderComponent={<Text style={styles.foo}>Conversations</Text>} renderItem={({ item }) => <Text>{item.attributes.title}</Text>}/>);
|
|
22
25
|
}
|
|
26
|
+
const useStyles = () => {
|
|
27
|
+
return StyleSheet.create({
|
|
28
|
+
container: { columnGap: 16 },
|
|
29
|
+
foo: { fontSize: 24 },
|
|
30
|
+
});
|
|
31
|
+
};
|
|
23
32
|
const validateResponse = (response) => {
|
|
24
33
|
const isExpired = response.status === 401;
|
|
25
|
-
if (isExpired)
|
|
34
|
+
if (isExpired) {
|
|
26
35
|
throw new Error('Token expired');
|
|
36
|
+
}
|
|
27
37
|
return response;
|
|
28
38
|
};
|
|
29
39
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEzD,MAAM,UAAU,OAAO,CAAC,EACtB,KAAK,EACL,cAAc,GAIf;IACC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAM,IAAI,CAAC,CAAA;IAC7D,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAE1B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAM;QACR,CAAC;QAED,KAAK,CAAC,+DAA+D,EAAE;YACrE,OAAO,EAAE;g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,CAAA;IACzC,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA","sourcesContent":["import React, { useEffect, useState } from 'react'\nimport { FlatList, StyleSheet, Text } from 'react-native'\n\nexport function PCOChat({\n token,\n onTokenExpired,\n}: {\n token?: OathToken\n onTokenExpired: () => void\n}) {\n const [conversations, setConversations] = useState<any>(null)\n const styles = useStyles()\n\n useEffect(() => {\n if (!token) {\n return\n }\n\n fetch('https://api.planningcenteronline.com/chat/v2/me/conversations', {\n headers: {\n Authorization: `Bearer ${token.access_token}`,\n },\n })\n .then(validateResponse)\n .then(response => response.json())\n .then(setConversations)\n .catch(error => {\n if (error.message === 'Token expired') {\n onTokenExpired()\n }\n })\n }, [onTokenExpired, token])\n\n return (\n <FlatList\n data={conversations?.data}\n ListEmptyComponent={<Text>No conversations</Text>}\n contentContainerStyle={styles.container}\n ListHeaderComponent={<Text style={styles.foo}>Conversations</Text>}\n renderItem={({ item }) => <Text>{item.attributes.title}</Text>}\n />\n )\n}\n\nconst useStyles = () => {\n return StyleSheet.create({\n container: { columnGap: 16 },\n foo: { fontSize: 24 },\n })\n}\n\nconst validateResponse = (response: Response) => {\n const isExpired = response.status === 401\n if (isExpired) {\n throw new Error('Token expired')\n }\n\n return response\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "1.3.0-rc.
|
|
3
|
+
"version": "1.3.0-rc.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
"react-native": "*"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"
|
|
20
|
+
"@react-native/eslint-config": "^0.77.0",
|
|
21
|
+
"@typescript-eslint/parser": "^8.23.0",
|
|
22
|
+
"expo-module-scripts": "^3.4.0",
|
|
23
|
+
"prettier": "^3.4.2",
|
|
24
|
+
"react-native": "0.74.5"
|
|
21
25
|
},
|
|
22
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "01657a32952a72a2a82786e1de30edfc0f52b4f3"
|
|
23
27
|
}
|
package/src/index.tsx
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import { FlatList, Text } from 'react-native'
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { FlatList, StyleSheet, Text } from 'react-native'
|
|
3
3
|
|
|
4
|
-
export function PCOChat({
|
|
4
|
+
export function PCOChat({
|
|
5
|
+
token,
|
|
6
|
+
onTokenExpired,
|
|
7
|
+
}: {
|
|
8
|
+
token?: OathToken
|
|
9
|
+
onTokenExpired: () => void
|
|
10
|
+
}) {
|
|
5
11
|
const [conversations, setConversations] = useState<any>(null)
|
|
12
|
+
const styles = useStyles()
|
|
6
13
|
|
|
7
14
|
useEffect(() => {
|
|
8
|
-
if (!token)
|
|
15
|
+
if (!token) {
|
|
16
|
+
return
|
|
17
|
+
}
|
|
9
18
|
|
|
10
19
|
fetch('https://api.planningcenteronline.com/chat/v2/me/conversations', {
|
|
11
20
|
headers: {
|
|
12
|
-
Authorization: `Bearer ${token
|
|
13
|
-
}
|
|
14
|
-
})
|
|
21
|
+
Authorization: `Bearer ${token.access_token}`,
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
.then(validateResponse)
|
|
15
25
|
.then(response => response.json())
|
|
16
26
|
.then(setConversations)
|
|
17
27
|
.catch(error => {
|
|
@@ -19,22 +29,31 @@ export function PCOChat({ token, onTokenExpired }: { token?: OathToken, onTokenE
|
|
|
19
29
|
onTokenExpired()
|
|
20
30
|
}
|
|
21
31
|
})
|
|
22
|
-
}, [token])
|
|
32
|
+
}, [onTokenExpired, token])
|
|
23
33
|
|
|
24
34
|
return (
|
|
25
|
-
<FlatList
|
|
35
|
+
<FlatList
|
|
26
36
|
data={conversations?.data}
|
|
27
37
|
ListEmptyComponent={<Text>No conversations</Text>}
|
|
28
|
-
contentContainerStyle={
|
|
29
|
-
ListHeaderComponent={<Text style={
|
|
38
|
+
contentContainerStyle={styles.container}
|
|
39
|
+
ListHeaderComponent={<Text style={styles.foo}>Conversations</Text>}
|
|
30
40
|
renderItem={({ item }) => <Text>{item.attributes.title}</Text>}
|
|
31
41
|
/>
|
|
32
42
|
)
|
|
33
43
|
}
|
|
34
44
|
|
|
45
|
+
const useStyles = () => {
|
|
46
|
+
return StyleSheet.create({
|
|
47
|
+
container: { columnGap: 16 },
|
|
48
|
+
foo: { fontSize: 24 },
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
35
52
|
const validateResponse = (response: Response) => {
|
|
36
53
|
const isExpired = response.status === 401
|
|
37
|
-
if (isExpired)
|
|
54
|
+
if (isExpired) {
|
|
55
|
+
throw new Error('Token expired')
|
|
56
|
+
}
|
|
38
57
|
|
|
39
58
|
return response
|
|
40
|
-
}
|
|
59
|
+
}
|