Skip to content

Commit f4cab86

Browse files
authored
Merge pull request #3 from commt/feature/system-user
Feature System User
2 parents 7d68759 + 3bb2757 commit f4cab86

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

components/ChatHeader/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ const ChatHeader = ({
3232
const oppositeUserId = room
3333
? room.groupName
3434
? null
35-
: room.participants.find((id) => id !== selfUser?._id)
36-
: participants?.find((id) => id !== selfUser?._id);
35+
: room.participants.find(
36+
(id) => id !== selfUser?._id && !id.startsWith("system"),
37+
)
38+
: participants?.find(
39+
(id) => id !== selfUser?._id && !id.startsWith("system"),
40+
);
3741
const oppositeUser = users.find(({ _id }) => _id === oppositeUserId);
3842

3943
const renderMembersOrOnline = () => {

components/MessageList/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const MessageList = ({ onPress }: MessageListProps) => {
7979
return room.groupName.toLowerCase();
8080
} else {
8181
const oppositeUserId = room.participants.find(
82-
(id) => id !== selfUser?._id,
82+
(id) => id !== selfUser?._id && !id.startsWith("system"),
8383
);
8484
return (
8585
users

components/RoomCard/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ const RoomCard = ({ room, onClickAction }: RoomCardProps) => {
120120

121121
const oppositeUserId = room.groupName
122122
? null
123-
: room.participants.find((id) => id !== selfUser?._id);
123+
: room.participants.find(
124+
(id) => id !== selfUser?._id && !id.startsWith("system"),
125+
);
124126
const oppositeUser = oppositeUserId
125127
? users.find((user: UserProps) => user._id === oppositeUserId)
126128
: null;

context/reducers/usersReducer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ export type UserProps = {
44
_id: string;
55
chatAuthId: string;
66
username: string;
7-
avatar: string;
7+
avatar?: string;
88
online: boolean;
99
socketId?: string | undefined;
10-
privateKey: string;
11-
publicKey: string;
10+
privateKey?: string;
11+
publicKey?: string;
1212
};
1313

1414
export type UserState = {

service/index.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import { ConfigsProps } from "../context/reducers/appReducer";
44
import { RoomProps } from "../context/reducers/roomsReducer";
55
import PackageJson from "../package.json";
66

7-
interface AuthKeysProps {
7+
export interface InitiateProps {
88
apiKey: string;
99
subscriptionKey: string;
1010
}
1111

12-
export interface InitiateProps extends AuthKeysProps {
13-
tenantId: string;
14-
}
15-
16-
interface OnlineInfoProps extends AuthKeysProps {
12+
interface OnlineInfoProps extends InitiateProps {
1713
userIds: string;
1814
}
1915

@@ -22,7 +18,7 @@ type OnlineInfoReturnProps = Pick<
2218
"chatAuthId" | "socketId" | "online"
2319
>;
2420

25-
interface ReadTokenProps extends AuthKeysProps {
21+
interface ReadTokenProps extends InitiateProps {
2622
roomIds: string;
2723
}
2824

@@ -103,7 +99,6 @@ export const getRoomsReadToken = async (props: ReadTokenProps) => {
10399
},
104100
},
105101
);
106-
107102
return response.data;
108103
} catch {
109104
// TODO: Log error

0 commit comments

Comments
 (0)