Skip to content

Commit f63e4cf

Browse files
committed
refactor: Chat to use overmind
1 parent f6689e6 commit f63e4cf

File tree

1 file changed

+7
-8
lines changed
  • packages/app/src/app/pages/Sandbox/Editor/Workspace/Chat

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React, { useState, useEffect, useRef } from 'react';
22
import styled from 'styled-components';
33
import { sortBy, takeRight } from 'lodash-es';
4-
import { inject, observer } from 'app/componentConnectors';
54

65
import AutosizeTextArea from '@codesandbox/common/lib/components/AutosizeTextArea';
76
import { ENTER } from '@codesandbox/common/lib/utils/keycodes';
7+
import { useOvermind } from 'app/overmind';
88

99
const Container = styled.div`
1010
min-height: 200px;
@@ -22,9 +22,10 @@ const Messages = styled.div`
2222
flex: 1;
2323
`;
2424

25-
const ChatComponent = ({ signals, store }) => {
25+
export const Chat = () => {
2626
const [value, setValue] = useState('');
2727
const [height, setHeight] = useState('');
28+
const { state, actions } = useOvermind();
2829
const messagesRef = useRef(null);
2930
function scrollDown() {
3031
if (messagesRef.current) {
@@ -38,7 +39,7 @@ const ChatComponent = ({ signals, store }) => {
3839
e.preventDefault();
3940
e.stopPropagation();
4041
// Enter
41-
signals.live.onSendChat({
42+
actions.live.onSendChat({
4243
message: value,
4344
});
4445
setValue('');
@@ -50,9 +51,9 @@ const ChatComponent = ({ signals, store }) => {
5051
setValue(e.target.value);
5152
};
5253

53-
const { messages, users } = store.live.roomInfo.chat;
54-
const currentUserId = store.live.liveUserId;
55-
const roomInfoUsers = store.live.roomInfo.users;
54+
const { messages, users } = state.live.roomInfo.chat;
55+
const currentUserId = state.live.liveUserId;
56+
const roomInfoUsers = state.live.roomInfo.users;
5657

5758
return (
5859
<Container
@@ -132,5 +133,3 @@ const ChatComponent = ({ signals, store }) => {
132133
</Container>
133134
);
134135
};
135-
136-
export const Chat = inject('signals', 'store')(observer(ChatComponent));

0 commit comments

Comments
 (0)