Skip to content

Commit 88b57c9

Browse files
author
Jaap
committed
update app.js
1 parent cf8b507 commit 88b57c9

File tree

1 file changed

+22
-53
lines changed

1 file changed

+22
-53
lines changed

examples/messaging/src/App.js

Lines changed: 22 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,102 +6,71 @@ import {
66
Channel,
77
MessageList,
88
MessageInput,
9+
MessageInputFlat,
910
MessageSimple,
11+
ChannelHeader,
1012
ChannelPreviewMessenger,
1113
InfiniteScrollPaginator,
14+
ChannelListMessenger,
1215
ChannelList,
1316
Window,
1417
Thread,
1518
} from 'stream-chat-react';
16-
import {
17-
MessagingInput,
18-
MessagingChannelHeader,
19-
MessagingChannelList,
20-
MessagingCreateChannel,
21-
} from './components';
2219
import 'stream-chat-react/dist/css/index.css';
2320
import './App.css';
2421

2522
const urlParams = new URLSearchParams(window.location.search);
26-
const apiKey = urlParams.get('apikey') || 'qk4nn7rpcn75';
27-
urlParams.get('user') || 'example-user';
28-
const user = urlParams.get('user') || 'example-user';
29-
const theme = urlParams.get('theme') || 'dark';
30-
const userToken =
31-
urlParams.get('user_token') ||
32-
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiZXhhbXBsZS11c2VyIn0.HlC0dMKL43y3K_XbfvQS_Yc3V314HU4Z7LrBLil777g';
33-
34-
const filters = { type: 'messaging', members: { $in: [user] } };
23+
// const user =
24+
// urlParams.get('user') || process.env.REACT_APP_CHAT_API_DEFAULT_USER;
25+
const theme = urlParams.get('theme') || 'light';
26+
// const channelName = urlParams.get('channel') || 'demo';
27+
// const userToken =
28+
// urlParams.get('user_token') ||
29+
// process.env.REACT_APP_CHAT_API_DEFAULT_USER_TOKEN;
30+
const filters = { type: 'messaging', example: 1 };
3531
const sort = {
3632
last_message_at: -1,
3733
updated_at: -1,
3834
cid: 1,
3935
};
40-
41-
const options = { state: true, watch: true, presence: true, limit: 10 };
36+
const options = { state: true, watch: true, presence: true };
4237
const Paginator = (props) => (
4338
<InfiniteScrollPaginator threshold={300} {...props} />
4439
);
4540

4641
class App extends Component {
4742
constructor(props) {
4843
super(props);
49-
this.chatClient = new StreamChat(apiKey);
44+
this.chatClient = new StreamChat('qk4nn7rpcn75');
5045
// if (process.env.REACT_APP_CHAT_SERVER_ENDPOINT) {
5146
// this.chatClient.setBaseURL(process.env.REACT_APP_CHAT_SERVER_ENDPOINT);
5247
// }
5348
this.chatClient.setUser(
5449
{
55-
id: user,
50+
id: 'example-user',
5651
},
57-
userToken,
52+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiZXhhbXBsZS11c2VyIn0.HlC0dMKL43y3K_XbfvQS_Yc3V314HU4Z7LrBLil777g',
5853
);
59-
this.state = {
60-
createChannel: false,
61-
};
6254
}
6355

64-
onClose = () => {
65-
this.setState({
66-
createChannel: false,
67-
});
68-
};
69-
70-
onOpen = () => {
71-
this.setState({
72-
createChannel: true,
73-
});
74-
};
75-
7656
render() {
7757
return (
7858
<Chat client={this.chatClient} theme={`messaging ${theme}`}>
7959
<ChannelList
80-
List={(props) => (
81-
<MessagingChannelList {...props} onCreateChannel={this.onOpen} />
82-
)}
60+
List={ChannelListMessenger}
8361
Preview={ChannelPreviewMessenger}
8462
filters={filters}
8563
sort={sort}
8664
options={options}
87-
// Paginator={Paginator}
65+
Paginator={Paginator}
8866
/>
89-
<Channel maxNumberOfFiles={10} multipleUploads={true}>
90-
<MessagingCreateChannel
91-
onClose={this.onClose}
92-
visible={this.state.createChannel}
93-
/>
67+
<Channel>
9468
<Window>
95-
<MessagingChannelHeader />
96-
<MessageList TypingIndicator={() => null} />
97-
<MessageInput focus />
69+
<ChannelHeader />
70+
<MessageList />
71+
<MessageInput Input={MessageInputFlat} focus />
9872
</Window>
99-
<Thread
100-
Message={MessageSimple}
101-
additionalMessageInputProps={{
102-
Input: MessagingInput,
103-
}}
104-
/>
73+
<Thread Message={MessageSimple} />
10574
</Channel>
10675
</Chat>
10776
);

0 commit comments

Comments
 (0)