sdy

change variables name

import React from "react";
import { useSubscription, useMutation, useQuery } from "@apollo/react-hooks";
import { useMutation, useQuery } from "@apollo/react-hooks";
import ChatPresenter from "./ChatPresenter";
import { withRouter } from "react-router-dom";
import {
SUBSCRIPTION_MSG,
WHOLE_MESSAGE,
GET_ROOM_BY_NAME,
} from "./ChatQueries";
import { CREATE_MESSAGE, GET_ROOM_BY_NAME } from "./ChatQueries";
import useInput from "../../Hooks/useInput";
import { toast } from "react-toastify";
......@@ -14,7 +10,7 @@ export default withRouter(({ location }) => {
const { pathname } = location;
const roomName = pathname.slice(1, pathname.length);
let messageObj, roomNum, sendingText, sendingTime, sendingMsgObj;
let messageObj, roomNum, messageText, messageTime, newMsgObj;
if (roomName !== undefined) {
const { data } = useQuery(GET_ROOM_BY_NAME, { variables: { roomName } });
......@@ -26,7 +22,7 @@ export default withRouter(({ location }) => {
}
}
const [createMsg] = useMutation(WHOLE_MESSAGE);
const [createMsg] = useMutation(CREATE_MESSAGE);
//const { data } = useSubscription(SUBSCRIPTION_MSG);
const message = useInput("");
......@@ -46,12 +42,12 @@ export default withRouter(({ location }) => {
} else {
const {
data: {
wholeMessage: { text, createdAt },
createMessage: { text, createdAt },
},
} = messageObj;
sendingText = text;
sendingTime = createdAt;
sendingMsgObj = messageObj;
messageText = text;
messageTime = createdAt;
newMsgObj = messageObj;
}
} catch {
toast.error("text must be not empty");
......@@ -63,9 +59,9 @@ export default withRouter(({ location }) => {
location={location}
message={message}
onSubmit={onSubmit}
sendingText={sendingText}
sendingTime={sendingTime}
sendingMsgObj={sendingMsgObj}
messageText={messageText}
messageTime={messageTime}
newMsgObj={sendingMsgObj}
/>
);
});
......