sdy

change variables name

1 import React from "react"; 1 import React from "react";
2 -import { useSubscription, useMutation, useQuery } from "@apollo/react-hooks"; 2 +import { useMutation, useQuery } from "@apollo/react-hooks";
3 import ChatPresenter from "./ChatPresenter"; 3 import ChatPresenter from "./ChatPresenter";
4 import { withRouter } from "react-router-dom"; 4 import { withRouter } from "react-router-dom";
5 -import { 5 +import { CREATE_MESSAGE, GET_ROOM_BY_NAME } from "./ChatQueries";
6 - SUBSCRIPTION_MSG,
7 - WHOLE_MESSAGE,
8 - GET_ROOM_BY_NAME,
9 -} from "./ChatQueries";
10 import useInput from "../../Hooks/useInput"; 6 import useInput from "../../Hooks/useInput";
11 import { toast } from "react-toastify"; 7 import { toast } from "react-toastify";
12 8
...@@ -14,7 +10,7 @@ export default withRouter(({ location }) => { ...@@ -14,7 +10,7 @@ export default withRouter(({ location }) => {
14 const { pathname } = location; 10 const { pathname } = location;
15 const roomName = pathname.slice(1, pathname.length); 11 const roomName = pathname.slice(1, pathname.length);
16 12
17 - let messageObj, roomNum, sendingText, sendingTime, sendingMsgObj; 13 + let messageObj, roomNum, messageText, messageTime, newMsgObj;
18 14
19 if (roomName !== undefined) { 15 if (roomName !== undefined) {
20 const { data } = useQuery(GET_ROOM_BY_NAME, { variables: { roomName } }); 16 const { data } = useQuery(GET_ROOM_BY_NAME, { variables: { roomName } });
...@@ -26,7 +22,7 @@ export default withRouter(({ location }) => { ...@@ -26,7 +22,7 @@ export default withRouter(({ location }) => {
26 } 22 }
27 } 23 }
28 24
29 - const [createMsg] = useMutation(WHOLE_MESSAGE); 25 + const [createMsg] = useMutation(CREATE_MESSAGE);
30 //const { data } = useSubscription(SUBSCRIPTION_MSG); 26 //const { data } = useSubscription(SUBSCRIPTION_MSG);
31 27
32 const message = useInput(""); 28 const message = useInput("");
...@@ -46,12 +42,12 @@ export default withRouter(({ location }) => { ...@@ -46,12 +42,12 @@ export default withRouter(({ location }) => {
46 } else { 42 } else {
47 const { 43 const {
48 data: { 44 data: {
49 - wholeMessage: { text, createdAt }, 45 + createMessage: { text, createdAt },
50 }, 46 },
51 } = messageObj; 47 } = messageObj;
52 - sendingText = text; 48 + messageText = text;
53 - sendingTime = createdAt; 49 + messageTime = createdAt;
54 - sendingMsgObj = messageObj; 50 + newMsgObj = messageObj;
55 } 51 }
56 } catch { 52 } catch {
57 toast.error("text must be not empty"); 53 toast.error("text must be not empty");
...@@ -63,9 +59,9 @@ export default withRouter(({ location }) => { ...@@ -63,9 +59,9 @@ export default withRouter(({ location }) => {
63 location={location} 59 location={location}
64 message={message} 60 message={message}
65 onSubmit={onSubmit} 61 onSubmit={onSubmit}
66 - sendingText={sendingText} 62 + messageText={messageText}
67 - sendingTime={sendingTime} 63 + messageTime={messageTime}
68 - sendingMsgObj={sendingMsgObj} 64 + newMsgObj={sendingMsgObj}
69 /> 65 />
70 ); 66 );
71 }); 67 });
......