Skip to content

Commit a5816ba

Browse files
committed
Merge branch 'typescript-conversion' into CRS-441_message-mentions
2 parents 5ac18be + 1e2b96f commit a5816ba

File tree

17 files changed

+265
-129
lines changed

17 files changed

+265
-129
lines changed

examples/messaging/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"react-app-polyfill": "^1.0.2",
88
"react-dom": "link:../../node_modules/react-dom",
99
"react-scripts": "2.1.4",
10-
"stream-chat": "3.5.1",
10+
"stream-chat": "3.7.0",
1111
"stream-chat-react": "link:../../"
1212
},
1313
"scripts": {

examples/messaging/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10242,10 +10242,10 @@ stream-browserify@^2.0.1:
1024210242
version "0.0.0"
1024310243
uid ""
1024410244

10245-
stream-chat@3.5.1:
10246-
version "3.5.1"
10247-
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-3.5.1.tgz#553df1b2458b1208ae798c18e14571ea8daa5065"
10248-
integrity sha512-mLUu2zoiI+Ebj7YAAJnBagyFW4YDrdx/f3bvkZkmCWMidNN26xNitvq7Jelwz6LXjlVm+fPrWdwAyPJlymtLkQ==
10245+
stream-chat@3.7.0:
10246+
version "3.7.0"
10247+
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-3.7.0.tgz#1e2e122feeb594509fdb4e36855cddb1dc5476c3"
10248+
integrity sha512-a4mg0kmdU6c1Foz8p1a370jAac8wkDNugE+GQrTeOqZqWh/yIrsE31WsJb901hhrl5nFwWPiTpFO0HuFXr8EmA==
1024910249
dependencies:
1025010250
"@babel/runtime" "^7.13.10"
1025110251
"@types/jsonwebtoken" "^8.5.0"

examples/typescript-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"react": "link:../../node_modules/react",
77
"react-dom": "link:../../node_modules/react-dom",
88
"react-scripts": "3.4.1",
9-
"stream-chat": "3.1.2",
9+
"stream-chat": "3.7.0",
1010
"stream-chat-react": "link:../../",
11-
"typescript": "4.1.4"
11+
"typescript": "4.2.3"
1212
},
1313
"devDependencies": {
1414
"@testing-library/jest-dom": "^4.2.4",
Lines changed: 38 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,61 @@
1-
import React, { Component } from 'react';
1+
import React from 'react';
22
import { ChannelSort, StreamChat } from 'stream-chat';
33
import {
44
Chat,
55
Channel,
6+
ChannelHeader,
7+
ChannelList,
8+
ChannelListMessenger,
9+
ChannelPreviewMessenger,
610
MessageList,
711
MessageInput,
812
MessageInputFlat,
9-
MessageSimple,
10-
ChannelHeader,
11-
ChannelPreviewMessenger,
12-
ChannelListMessenger,
13-
ChannelList,
14-
Window,
1513
Thread,
14+
Window,
1615
} from 'stream-chat-react';
1716
import 'stream-chat-react/dist/css/index.css';
1817
import './App.css';
1918

20-
const urlParams = new URLSearchParams(window.location.search);
21-
const apiKey = urlParams.get('apiKey') || 'qk4nn7rpcn75';
22-
const userId = urlParams.get('user') || 'example-user';
23-
const theme = urlParams.get('theme') || 'light';
24-
const userToken =
25-
urlParams.get('user_token') ||
26-
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiZXhhbXBsZS11c2VyIn0.HlC0dMKL43y3K_XbfvQS_Yc3V314HU4Z7LrBLil777g';
19+
const apiKey = process.env.REACT_APP_STREAM_KEY as string;
20+
const userId = process.env.REACT_APP_USER_ID as string;
21+
const userToken = process.env.REACT_APP_USER_TOKEN as string;
22+
const theme = 'light';
2723

28-
const filters = { type: 'messaging', example: 1 };
29-
const options = { state: true, watch: true, presence: true };
24+
const filters = { type: 'messaging' };
25+
const options = { state: true, presence: true, limit: 10 };
3026
const sort: ChannelSort = {
27+
cid: 1,
3128
last_message_at: -1,
3229
updated_at: -1,
33-
cid: 1,
3430
};
3531

36-
class App extends Component {
37-
chatClient = new StreamChat('');
38-
constructor(props: Readonly<{}>) {
39-
super(props);
40-
this.chatClient = StreamChat.getInstance(apiKey);
32+
const chatClient = StreamChat.getInstance(apiKey);
4133

42-
if (process.env.REACT_APP_CHAT_SERVER_ENDPOINT) {
43-
this.chatClient.setBaseURL(process.env.REACT_APP_CHAT_SERVER_ENDPOINT);
44-
}
34+
if (process.env.REACT_APP_CHAT_SERVER_ENDPOINT) {
35+
chatClient.setBaseURL(process.env.REACT_APP_CHAT_SERVER_ENDPOINT);
36+
}
4537

46-
this.chatClient.connectUser({ id: userId }, userToken);
47-
}
38+
chatClient.connectUser({ id: userId }, userToken);
4839

49-
render() {
50-
return (
51-
<Chat client={this.chatClient} theme={`messaging ${theme}`}>
52-
<ChannelList
53-
List={ChannelListMessenger}
54-
Preview={ChannelPreviewMessenger}
55-
filters={filters}
56-
sort={sort}
57-
options={options}
58-
/>
59-
<Channel>
60-
<Window>
61-
<ChannelHeader />
62-
<MessageList />
63-
<MessageInput Input={MessageInputFlat} focus />
64-
</Window>
65-
<Thread Message={MessageSimple} />
66-
</Channel>
67-
</Chat>
68-
);
69-
}
70-
}
40+
const App = () => (
41+
// @ts-expect-error TODO: find out why v3.1.3 of stream-chat inits this error
42+
<Chat client={chatClient} theme={`messaging ${theme}`}>
43+
<ChannelList
44+
List={ChannelListMessenger}
45+
Preview={ChannelPreviewMessenger}
46+
filters={filters}
47+
sort={sort}
48+
options={options}
49+
/>
50+
<Channel>
51+
<Window>
52+
<ChannelHeader />
53+
<MessageList />
54+
<MessageInput Input={MessageInputFlat} focus />
55+
</Window>
56+
<Thread />
57+
</Channel>
58+
</Chat>
59+
);
7160

7261
export default App;

examples/typescript-app/yarn.lock

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,13 @@
10691069
dependencies:
10701070
regenerator-runtime "^0.13.4"
10711071

1072+
"@babel/runtime@^7.13.10":
1073+
version "7.13.10"
1074+
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.10.tgz#47d42a57b6095f4468da440388fdbad8bebf0d7d"
1075+
integrity sha512-4QPkjJq6Ns3V/RgpEahRk+AGfL0eO6RHHtTWoNNr5mO49G6B5+X6d6THgWEAvTrznU5xYpbAlVKRYcsCgh/Akw==
1076+
dependencies:
1077+
regenerator-runtime "^0.13.4"
1078+
10721079
"@babel/template@^7.12.13", "@babel/template@^7.4.0", "@babel/template@^7.8.6":
10731080
version "7.12.13"
10741081
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.12.13.tgz#530265be8a2589dbb37523844c5bcb55947fb327"
@@ -5063,10 +5070,10 @@ [email protected]:
50635070
tapable "^1.0.0"
50645071
worker-rpc "^0.1.0"
50655072

5066-
form-data@^3.0.0:
5067-
version "3.0.0"
5068-
resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.0.tgz#31b7e39c85f1355b7139ee0c647cf0de7f83c682"
5069-
integrity sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==
5073+
form-data@^4.0.0:
5074+
version "4.0.0"
5075+
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
5076+
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
50705077
dependencies:
50715078
asynckit "^0.4.0"
50725079
combined-stream "^1.0.8"
@@ -10742,20 +10749,20 @@ stream-browserify@^2.0.1:
1074210749
version "0.0.0"
1074310750
uid ""
1074410751

10745-
stream-chat@3.1.2:
10746-
version "3.1.2"
10747-
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-3.1.2.tgz#271ff85f5533ae432bc94168bfeffca8efc6b55a"
10748-
integrity sha512-hIVkycehlJrkG2D+RV77qhZeOjZyas398DNdD8GeQlVB7Li60p+XPAsaeNob7kEptFow2LC2TTUiR4hQDCbufg==
10752+
stream-chat@3.7.0:
10753+
version "3.7.0"
10754+
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-3.7.0.tgz#1e2e122feeb594509fdb4e36855cddb1dc5476c3"
10755+
integrity sha512-a4mg0kmdU6c1Foz8p1a370jAac8wkDNugE+GQrTeOqZqWh/yIrsE31WsJb901hhrl5nFwWPiTpFO0HuFXr8EmA==
1074910756
dependencies:
10750-
"@babel/runtime" "^7.12.13"
10757+
"@babel/runtime" "^7.13.10"
1075110758
"@types/jsonwebtoken" "^8.5.0"
1075210759
"@types/ws" "^7.4.0"
1075310760
axios "^0.21.1"
1075410761
base64-js "^1.5.1"
10755-
form-data "^3.0.0"
10762+
form-data "^4.0.0"
1075610763
isomorphic-ws "^4.0.1"
1075710764
jsonwebtoken "^8.5.1"
10758-
ws "^7.4.3"
10765+
ws "^7.4.4"
1075910766

1076010767
stream-each@^1.1.0:
1076110768
version "1.2.3"
@@ -11313,10 +11320,10 @@ typedarray@^0.0.6:
1131311320
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
1131411321
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
1131511322

11316-
typescript@4.1.4:
11317-
version "4.1.4"
11318-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.4.tgz#f058636e2f4f83f94ddaae07b20fd5e14598432f"
11319-
integrity sha512-+Uru0t8qIRgjuCpiSPpfGuhHecMllk5Zsazj5LZvVsEStEjmIRRBZe+jHjGQvsgS7M1wONy2PQXd67EMyV6acg==
11323+
typescript@4.2.3:
11324+
version "4.2.3"
11325+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
11326+
integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
1132011327

1132111328
ua-parser-js@^0.7.18:
1132211329
version "0.7.23"
@@ -12088,10 +12095,10 @@ ws@^6.1.2, ws@^6.2.1:
1208812095
dependencies:
1208912096
async-limiter "~1.0.0"
1209012097

12091-
ws@^7.4.3:
12092-
version "7.4.3"
12093-
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.3.tgz#1f9643de34a543b8edb124bdcbc457ae55a6e5cd"
12094-
integrity sha512-hr6vCR76GsossIRsr8OLR9acVVm1jyfEWvhbNjtgPOrfvAlKzvyeg/P6r8RuDjRyrcQoPQT7K0DGEPc7Ae6jzA==
12098+
ws@^7.4.4:
12099+
version "7.4.4"
12100+
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.4.tgz#383bc9742cb202292c9077ceab6f6047b17f2d59"
12101+
integrity sha512-Qm8k8ojNQIMx7S+Zp8u/uHOx7Qazv3Yv4q68MiWWWOJhiwG5W3x7iqmRtJo8xxrciZUY4vRxUTJCKuRnF28ZZw==
1209512102

1209612103
xml-name-validator@^3.0.0:
1209712104
version "3.0.0"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
},
165165
"scripts": {
166166
"analyze": "yarn build -- --stats && webpack-bundle-analyzer build/bundle-stats.json",
167-
"build": "mkdir -p dist/assets assets && yarn build-translations && yarn bundle",
167+
"build": "mkdir -p dist/assets assets && yarn build-translations && yarn types && yarn bundle",
168168
"build-styles": "sass src/styles/index.scss dist/css/index.css --style compressed",
169169
"bundle": "rollup -c",
170170
"bundle-size": "BUNDLE_SIZE=true yarn bundle",

src/components/Attachment/utils.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ export const renderAttachmentActions = <
9595
return (
9696
<AttachmentActions
9797
{...attachment}
98-
actionHandler={() => actionHandler}
98+
actionHandler={(event, name, value) =>
99+
actionHandler?.(name, value, event)
100+
}
99101
actions={attachment.actions || []}
100102
id={attachment.id || ''}
101103
key={`key-actions-${attachment.id}`}

0 commit comments

Comments
 (0)