sdy

rename variables

......@@ -14,7 +14,7 @@ export default withRouter(({ location }) => {
const { pathname } = location;
const roomName = pathname.slice(1, pathname.length);
let messageObj, outcomingMsg, outcomingTime, roomNum;
let messageObj, roomNum, sendingText, sendingTime, sendingMsgObj;
if (roomName !== undefined) {
const { data } = useQuery(GET_ROOM_BY_NAME, { variables: { roomName } });
......@@ -44,9 +44,14 @@ export default withRouter(({ location }) => {
if (!messageObj) {
toast.error("fail to create new message !, try again");
} else {
const { text, createdAt } = messageObj;
outcomingMsg = text;
outcomingTime = createdAt;
const {
data: {
wholeMessage: { text, createdAt },
},
} = messageObj;
sendingText = text;
sendingTime = createdAt;
sendingMsgObj = messageObj;
}
} catch {
toast.error("text must be not empty");
......@@ -58,8 +63,9 @@ export default withRouter(({ location }) => {
location={location}
message={message}
onSubmit={onSubmit}
outcomingMsg={outcomingMsg}
outcomingTime={outcomingTime}
sendingText={sendingText}
sendingTime={sendingTime}
sendingMsgObj={sendingMsgObj}
/>
);
});
......