Skip to content

Commit de80422

Browse files
committed
refactor: Chat to use Typescript
1 parent f63e4cf commit de80422

File tree

2 files changed

+7
-4
lines changed
  • packages

2 files changed

+7
-4
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/Chat/index.js renamed to packages/app/src/app/pages/Sandbox/Editor/Workspace/Chat/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const Messages = styled.div`
2222
flex: 1;
2323
`;
2424

25-
export const Chat = () => {
25+
export const Chat: React.FC = () => {
2626
const [value, setValue] = useState('');
2727
const [height, setHeight] = useState('');
2828
const { state, actions } = useOvermind();
@@ -34,7 +34,7 @@ export const Chat = () => {
3434
}
3535
useEffect(scrollDown);
3636

37-
const handleKeyDown = e => {
37+
const handleKeyDown = (e: KeyboardEvent) => {
3838
if (e.keyCode === ENTER && !e.shiftKey) {
3939
e.preventDefault();
4040
e.stopPropagation();
@@ -47,7 +47,7 @@ export const Chat = () => {
4747
}
4848
};
4949

50-
const handleChange = e => {
50+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
5151
setValue(e.target.value);
5252
};
5353

packages/common/src/types/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ export type LiveUser = {
193193
avatarUrl: string;
194194
};
195195

196+
export type ChatUserGetter = (id: string) => string;
197+
196198
export type RoomInfo = {
197199
startTime: number;
198200
ownerIds: string[];
@@ -211,7 +213,8 @@ export type RoomInfo = {
211213
// We keep a separate map of user_id -> username for the case when
212214
// a user disconnects. We still need to keep track of the name.
213215
users: {
214-
[id: string]: string;
216+
[id: string]: string | ChatUserGetter;
217+
get: ChatUserGetter;
215218
};
216219
};
217220
};

0 commit comments

Comments
 (0)