Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
Triz_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
sdy
2020-05-31 23:43:38 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7ec9e78f8414ec9d864425031fb7ebe2e5bdf2e9
7ec9e78f
1 parent
173af080
change variables name
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
15 deletions
front/src/Routes/Chat/ChatContainer.js
front/src/Routes/Chat/ChatContainer.js
View file @
7ec9e78
import
React
from
"react"
;
import
{
use
Subscription
,
use
Mutation
,
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
,
sending
MsgObj
;
let
messageObj
,
roomNum
,
messageText
,
messageTime
,
new
MsgObj
;
if
(
roomName
!==
undefined
)
{
const
{
data
}
=
useQuery
(
GET_ROOM_BY_NAME
,
{
variables
:
{
roomName
}
});
...
...
@@ -26,7 +22,7 @@ export default withRouter(({ location }) => {
}
}
const
[
createMsg
]
=
useMutation
(
WHOL
E_MESSAGE
);
const
[
createMsg
]
=
useMutation
(
CREAT
E_MESSAGE
);
//const { data } = useSubscription(SUBSCRIPTION_MSG);
const
message
=
useInput
(
""
);
...
...
@@ -46,12 +42,12 @@ export default withRouter(({ location }) => {
}
else
{
const
{
data
:
{
whol
eMessage
:
{
text
,
createdAt
},
creat
eMessage
:
{
text
,
createdAt
},
},
}
=
messageObj
;
sending
Text
=
text
;
sending
Time
=
createdAt
;
sending
MsgObj
=
messageObj
;
message
Text
=
text
;
message
Time
=
createdAt
;
new
MsgObj
=
messageObj
;
}
}
catch
{
toast
.
error
(
"text must be not empty"
);
...
...
@@ -63,9 +59,9 @@ export default withRouter(({ location }) => {
location
=
{
location
}
message
=
{
message
}
onSubmit
=
{
onSubmit
}
sendingText
=
{
sending
Text
}
sendingTime
=
{
sending
Time
}
sending
MsgObj
=
{
sendingMsgObj
}
messageText
=
{
message
Text
}
messageTime
=
{
message
Time
}
new
MsgObj
=
{
sendingMsgObj
}
/
>
);
});
...
...
Please
register
or
login
to post a comment