Skip to content

Commit 3f42af8

Browse files
authored
Merge pull request #9 from commt/feature/project-fields
Update Request Fields & Config
2 parents 3bdb961 + 4931952 commit 3f42af8

File tree

15 files changed

+73
-101
lines changed

15 files changed

+73
-101
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules/
1+
node_modules/
2+
dist/

Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ import { useInitiate } from "@commt/rn-sdk/hooks";
5151
5252
const ClientConfig = {
5353
apiKey: "123456789?",
54-
subscriptionKey: "0987654321?",
55-
secret: "123456789018A_7JzPo?23F+4y#erPL" // This is just and example you don't have to add secret here for initialization
54+
projectId: "0987654321?",
55+
secret: "123456789018A_7JzPo?23F+4y#erPL"
5656
};
5757
5858
function App(): JSX.Element {

package.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{
22
"name": "@commt/rn-sdk",
3-
"version": "0.0.2",
3+
"version": "0.1.0",
44
"description": "Ultimate chat plugin for react native applications",
5-
"main": "src/index.tsx",
5+
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
67
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
8+
"test": "echo \"Error: no test specified\" && exit 1",
9+
"build": "rm -rf dist/* && npx tsc"
810
},
911
"repository": {
1012
"type": "git",
11-
"url": "git+https://github.com/commt/rn-sdk.git"
13+
"url": "git+https://github.com/commt/commt-react-native.git"
1214
},
15+
"files": ["dist"],
1316
"dependencies": {
1417
"dayjs": "^1.11.9",
1518
"axios": "^1.4.0",
1619
"node-forge": "^1.3.1",
17-
"react": "18.2.0",
18-
"react-native": "0.71.8",
1920
"styled-components": "^6.0.0-rc.3",
2021
"rn-emoji-keyboard": "^1.5.0",
2122
"socket.io-client": "^4.6.2",
@@ -28,6 +29,10 @@
2829
"@types/react": "^18.0.24",
2930
"@tsconfig/react-native": "^2.0.2"
3031
},
32+
"peerDependencies": {
33+
"react": "18.2.0",
34+
"react-native": "0.71.8"
35+
},
3136
"keywords": [
3237
"commt",
3338
"commt-chat-sdk",
@@ -50,7 +55,7 @@
5055
}
5156
],
5257
"bugs": {
53-
"url": "https://github.com/commt/rn-sdk.git/issues"
58+
"url": "https://github.com/commt/commt-react-native.git/issues"
5459
},
5560
"homepage": "https://commt.co/doc",
5661
"license": "MIT",

src/components/Chat/index.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const Chat = ({
4747
rooms,
4848
messages,
4949
app: {
50-
configs: { indicators, tenantId, apiKey, subscriptionKey, projectName },
50+
configs: { indicators, tenantId, apiKey, projectId },
5151
},
5252
},
5353
dispatch,
@@ -94,8 +94,7 @@ const Chat = ({
9494
//handle Log params
9595
{
9696
apiKey,
97-
subscriptionKey,
98-
projectName,
97+
projectId,
9998
chatAuthId: selfUser!.chatAuthId,
10099
},
101100
);
@@ -114,8 +113,7 @@ const Chat = ({
114113
//handle Log params
115114
{
116115
apiKey,
117-
subscriptionKey,
118-
projectName,
116+
projectId,
119117
chatAuthId: selfUser!.chatAuthId,
120118
},
121119
);
@@ -208,8 +206,7 @@ const Chat = ({
208206
//handle Log params
209207
{
210208
apiKey,
211-
subscriptionKey,
212-
projectName,
209+
projectId,
213210
chatAuthId: selfUser!.chatAuthId,
214211
},
215212
);
@@ -245,9 +242,11 @@ const Chat = ({
245242
renderCustomView={(props: BubbleProps<ICustomMessage>) => (
246243
<CustomUsernameView {...props} activeRoom={activeRoom} />
247244
)}
248-
renderAvatar={(props) => (
249-
<CustomAvatar {...props} activeRoom={activeRoom} />
250-
)}
245+
renderAvatar={(props) =>
246+
activeRoom?.groupAvatar && (
247+
<CustomAvatar {...props} activeRoom={activeRoom} />
248+
)
249+
}
251250
renderAvatarOnTop={true}
252251
renderChatFooter={renderChatFooter}
253252
renderSystemMessage={CustomSystemMessage}

src/components/CustomAvatar/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ interface CustomAvatarProps extends AvatarProps<IMessage> {
1111
const CustomAvatar = (props: CustomAvatarProps) => {
1212
const theme = useTheme();
1313
// render user avatar just for community chat
14-
if (props.activeRoom?.groupAvatar) {
15-
return <Avatar {...props} imageStyle={styles(theme).avatarImageStle} />;
16-
}
14+
return <Avatar {...props} imageStyle={styles(theme).avatarImageStle} />;
1715
};
1816

1917
export default CustomAvatar;

src/components/CustomBubble/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const ReadInfo = ({ currentMessage, activeRoom }: ReadInfoProps) => {
4646
);
4747
}
4848
}
49+
50+
return <></>;
4951
};
5052

5153
const CustomBubble = (props: CustomBubbleProps) => {

src/components/TextInput/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { StyleProp, TextInputProps, TextStyle } from "react-native";
33
import { useTheme } from "styled-components/native";
44
import { StyledTextInput } from "./styles";
55

6-
interface InputProps extends TextInputProps {
6+
export interface InputProps extends TextInputProps {
77
style?: StyleProp<TextStyle>;
88
}
99

src/context/reducers/appReducer.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ export type ConfigsProps = {
1414
indicators: IndicatorProps[];
1515
tenantId: string;
1616
apiKey: string;
17-
subscriptionKey: string;
1817
secretKey: string;
19-
projectName: string;
18+
projectId: string;
2019
};
2120

2221
export type AppState = {
@@ -34,9 +33,8 @@ export const AppValues: AppState = {
3433
indicators: [],
3534
tenantId: "",
3635
apiKey: "",
37-
subscriptionKey: "",
3836
secretKey: "",
39-
projectName: "",
37+
projectId: "",
4038
},
4139
};
4240

src/hooks/useSendMessage.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const useSendMessage = () => {
1818
users: { selfUser, users },
1919
rooms,
2020
app: {
21-
configs: { secretKey, apiKey, subscriptionKey, projectName, e2e },
21+
configs: { secretKey, apiKey, projectId, e2e },
2222
},
2323
},
2424
dispatch,
@@ -89,8 +89,7 @@ const useSendMessage = () => {
8989
//handle Log params
9090
{
9191
apiKey,
92-
subscriptionKey,
93-
projectName,
92+
projectId,
9493
chatAuthId: selfUser!.chatAuthId,
9594
chatRoomAuthId,
9695
},

src/hooks/useSetRooms.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const useSetRooms = () => {
1010
state: {
1111
users: { selfUser },
1212
app: {
13-
configs: { apiKey, subscriptionKey, indicators, projectName },
13+
configs: { apiKey, indicators, projectId },
1414
},
1515
},
1616
dispatch,
@@ -21,8 +21,7 @@ const useSetRooms = () => {
2121
const activeRooms = await getRoomsReadToken({
2222
roomIds: rooms.map((room) => room.chatRoomAuthId).join(","),
2323
apiKey,
24-
subscriptionKey,
25-
projectName,
24+
projectId,
2625
chatAuthId: selfUser!.chatAuthId,
2726
});
2827

0 commit comments

Comments
 (0)