@planningcenter/chat-react-native 1.3.0-rc.0 → 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 +22 -0
- package/build/index.d.ts +5 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +37 -8
- package/build/index.js.map +1 -1
- package/package.json +7 -18
- package/src/index.tsx +55 -9
- package/tsconfig.json +2 -3
package/.eslintrc.yml
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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
|
+
|
|
17
|
+
## [1.3.0-rc.1](https://github.com/planningcenter/chat-js/compare/v1.2.0...v1.3.0-rc.1) (2025-02-06)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add auth to the example app ([#50](https://github.com/planningcenter/chat-js/issues/50)) ([5e0ae00](https://github.com/planningcenter/chat-js/commit/5e0ae008345743f6bba388e982a3ad768265971a))
|
|
23
|
+
* drop stream and set global dependencies ([#49](https://github.com/planningcenter/chat-js/issues/49)) ([1214b9f](https://github.com/planningcenter/chat-js/commit/1214b9fbc17f4ab67a1de1d39954604a28268f35))
|
|
24
|
+
* **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)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [1.3.0-rc.0](https://github.com/planningcenter/chat-js/compare/v1.2.0...v1.3.0-rc.0) (2025-01-24)
|
|
7
29
|
|
|
8
30
|
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
3
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function PCOChat({ token, onTokenExpired, }: {
|
|
3
|
+
token?: OathToken;
|
|
4
|
+
onTokenExpired: () => void;
|
|
5
|
+
}): React.JSX.Element;
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
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,
|
|
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,10 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Text } from 'react-native';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { FlatList, StyleSheet, Text } from 'react-native';
|
|
3
|
+
export function PCOChat({ token, onTokenExpired, }) {
|
|
4
|
+
const [conversations, setConversations] = useState(null);
|
|
5
|
+
const styles = useStyles();
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (!token) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
fetch('https://api.planningcenteronline.com/chat/v2/me/conversations', {
|
|
11
|
+
headers: {
|
|
12
|
+
Authorization: `Bearer ${token.access_token}`,
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
.then(validateResponse)
|
|
16
|
+
.then(response => response.json())
|
|
17
|
+
.then(setConversations)
|
|
18
|
+
.catch(error => {
|
|
19
|
+
if (error.message === 'Token expired') {
|
|
20
|
+
onTokenExpired();
|
|
21
|
+
}
|
|
22
|
+
});
|
|
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>}/>);
|
|
9
25
|
}
|
|
26
|
+
const useStyles = () => {
|
|
27
|
+
return StyleSheet.create({
|
|
28
|
+
container: { columnGap: 16 },
|
|
29
|
+
foo: { fontSize: 24 },
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
const validateResponse = (response) => {
|
|
33
|
+
const isExpired = response.status === 401;
|
|
34
|
+
if (isExpired) {
|
|
35
|
+
throw new Error('Token expired');
|
|
36
|
+
}
|
|
37
|
+
return response;
|
|
38
|
+
};
|
|
10
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,
|
|
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;gBACP,aAAa,EAAE,UAAU,KAAK,CAAC,YAAY,EAAE;aAC9C;SACF,CAAC;aACC,IAAI,CAAC,gBAAgB,CAAC;aACtB,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;aACjC,IAAI,CAAC,gBAAgB,CAAC;aACtB,KAAK,CAAC,KAAK,CAAC,EAAE;YACb,IAAI,KAAK,CAAC,OAAO,KAAK,eAAe,EAAE,CAAC;gBACtC,cAAc,EAAE,CAAA;YAClB,CAAC;QACH,CAAC,CAAC,CAAA;IACN,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,CAAA;IAE3B,OAAO,CACL,CAAC,QAAQ,CACP,IAAI,CAAC,CAAC,aAAa,EAAE,IAAI,CAAC,CAC1B,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAClD,qBAAqB,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CACxC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,CACnE,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,EAC/D,CACH,CAAA;AACH,CAAC;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,SAAS,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;QAC5B,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;KACtB,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG,CAAC,QAAkB,EAAE,EAAE;IAC9C,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,KAAK,GAAG,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,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"
|
|
4
|
-
"version": "1.3.0-rc.0",
|
|
3
|
+
"version": "1.3.0-rc.2",
|
|
5
4
|
"description": "",
|
|
6
5
|
"main": "build/index.js",
|
|
7
6
|
"types": "build/index.d.ts",
|
|
@@ -11,28 +10,18 @@
|
|
|
11
10
|
"clean": "expo-module clean",
|
|
12
11
|
"lint": "expo-module lint",
|
|
13
12
|
"test": "expo-module test",
|
|
14
|
-
"prepublishOnly": "expo-module prepublishOnly"
|
|
15
|
-
"postinstall": "patch-package",
|
|
16
|
-
"expo-module": "expo-module"
|
|
17
|
-
},
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"patch-package": "^8.0.0",
|
|
20
|
-
"stream-chat-expo": "5.44.2",
|
|
21
|
-
"stream-chat-react-native": "5.44.2"
|
|
13
|
+
"prepublishOnly": "expo-module prepublishOnly"
|
|
22
14
|
},
|
|
23
15
|
"peerDependencies": {
|
|
24
|
-
"expo": "*",
|
|
25
16
|
"react": "*",
|
|
26
|
-
"react-dom": "*",
|
|
27
17
|
"react-native": "*"
|
|
28
18
|
},
|
|
29
19
|
"devDependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
20
|
+
"@react-native/eslint-config": "^0.77.0",
|
|
21
|
+
"@typescript-eslint/parser": "^8.23.0",
|
|
32
22
|
"expo-module-scripts": "^3.4.0",
|
|
33
|
-
"
|
|
34
|
-
"react-
|
|
35
|
-
"react-native": "0.76.6"
|
|
23
|
+
"prettier": "^3.4.2",
|
|
24
|
+
"react-native": "0.74.5"
|
|
36
25
|
},
|
|
37
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "01657a32952a72a2a82786e1de30edfc0f52b4f3"
|
|
38
27
|
}
|
package/src/index.tsx
CHANGED
|
@@ -1,13 +1,59 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Text } from 'react-native'
|
|
3
|
-
import { OverlayProvider } from 'stream-chat-expo';
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { FlatList, StyleSheet, Text } from 'react-native'
|
|
4
3
|
|
|
5
|
-
export
|
|
4
|
+
export function PCOChat({
|
|
5
|
+
token,
|
|
6
|
+
onTokenExpired,
|
|
7
|
+
}: {
|
|
8
|
+
token?: OathToken
|
|
9
|
+
onTokenExpired: () => void
|
|
10
|
+
}) {
|
|
11
|
+
const [conversations, setConversations] = useState<any>(null)
|
|
12
|
+
const styles = useStyles()
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!token) {
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
fetch('https://api.planningcenteronline.com/chat/v2/me/conversations', {
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${token.access_token}`,
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
.then(validateResponse)
|
|
25
|
+
.then(response => response.json())
|
|
26
|
+
.then(setConversations)
|
|
27
|
+
.catch(error => {
|
|
28
|
+
if (error.message === 'Token expired') {
|
|
29
|
+
onTokenExpired()
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
}, [onTokenExpired, token])
|
|
6
33
|
|
|
7
|
-
export function MyView() {
|
|
8
34
|
return (
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
35
|
+
<FlatList
|
|
36
|
+
data={conversations?.data}
|
|
37
|
+
ListEmptyComponent={<Text>No conversations</Text>}
|
|
38
|
+
contentContainerStyle={styles.container}
|
|
39
|
+
ListHeaderComponent={<Text style={styles.foo}>Conversations</Text>}
|
|
40
|
+
renderItem={({ item }) => <Text>{item.attributes.title}</Text>}
|
|
41
|
+
/>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const useStyles = () => {
|
|
46
|
+
return StyleSheet.create({
|
|
47
|
+
container: { columnGap: 16 },
|
|
48
|
+
foo: { fontSize: 24 },
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const validateResponse = (response: Response) => {
|
|
53
|
+
const isExpired = response.status === 401
|
|
54
|
+
if (isExpired) {
|
|
55
|
+
throw new Error('Token expired')
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return response
|
|
13
59
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
// @generated by expo-module-scripts
|
|
2
1
|
{
|
|
3
2
|
"extends": "expo-module-scripts/tsconfig.base",
|
|
4
3
|
"compilerOptions": {
|
|
5
4
|
"outDir": "./build"
|
|
6
5
|
},
|
|
7
|
-
"include": ["./src"],
|
|
8
|
-
"exclude": ["**/__mocks__/*", "**/__tests__/*"]
|
|
6
|
+
"include": ["./src", "../chat-core/types.d.ts"],
|
|
7
|
+
"exclude": ["**/__mocks__/*", "**/__tests__/*"],
|
|
9
8
|
}
|