{"version":3,"sources":["constants/ActionTypes.js","api/index.js","actions/Messages.js","components/Chatfield/Chatfield.jsx","components/Loginfield/Loginfield.jsx","actions/User.js","components/ChatViewField/Message/Message.jsx","components/ChatViewField/ChatViewField.jsx","App.jsx","reducers/messages.js","reducers/user.js","reducers/index.js","index.js"],"names":["MessageTypes","UserTypes","ApiTypes","WHEN","addMessage","messageData","a","client","send","JSON","stringify","Nuke","headers","TYPE","AddMessage","dispatch","api","payload","body","type","console","trace","withStyles","root","background","input","color","classes","user","useSelector","state","useDispatch","HandleSubmit","evt","bIsDesktop","preventDefault","sMsgContent","target","value","length","id","displayName","message","content","date","Date","style","height","onSubmit","TextField","className","inputProps","autoFocus","multiline","fullWidth","onKeyDown","keyCode","shiftKey","HandleEnter","placeholder","Loginfield","userData","log","err","Message","data","padding","display","paddingBottom","split","map","str","i","margin","ChatViewField","divRef","useRef","messages","useEffect","current","scrollIntoView","slice","reverse","index","ref","w3cwebsocket","App","onmessage","msg","RenderNewMessage","parse","Grid","container","item","xs","sm","lg","xl","onClick","Messages","action","temp","pop","User","combineReducers","composeEnhancers","window","__REDUX_DEVTOOLS_EXTENSION_COMPOSE__","compose","store","createStore","reducers","applyMiddleware","thunk","ReactDOM","render","document","getElementById"],"mappings":"wSAAaA,EACA,YADAA,EAEG,eAFHA,EAGE,cAGFC,EACJ,QADIA,EAEH,SAGGC,EAEL,OAFKA,EAGH,SAIGC,EACJ,QADIA,EAEH,SCMGC,EAAU,uCAAG,WAAOC,GAAP,SAAAC,EAAA,sDAExBC,EAAOC,KAAKC,KAAKC,UAAUL,IAFH,2CAAH,sDAQVM,EAAI,uCAAG,sBAAAL,EAAA,sDAElBC,EAAOC,KAAKC,KAAKC,UAAU,CACzBE,QAAS,CACPC,KAAMX,MAJQ,2CAAH,qDCjBXY,EAAa,SAACT,GAAD,8CAAiB,WAAOU,GAAP,SAAAT,EAAA,+EAI1BU,EAAeX,GAJW,OAMhCU,EAAS,CAAEE,QAASZ,EAAYa,KAAMC,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KC,YAAa2D,EAAOnF,SACzC,KAAKhB,EACH,MACF,QACE,OAAO2B,ICVE4E,cAAgB,CAAE3B,WAAUjD,SCOrC6E,G,MAAmBC,OAAOC,sCAAwCC,KAE3DC,EAAQC,YAAYC,EAAgCN,EAAiBO,YAAgBC,OAElGC,IAASC,OACP,cAAC,IAAD,CAAUN,MAAOA,EAAjB,SACE,cAAC,EAAD,MAEFO,SAASC,eAAe,W","file":"static/js/main.10743629.chunk.js","sourcesContent":["export const MessageTypes = {\r\n FETCH_ALL: \"FETCH_ALL\",\r\n POST_MESSAGE: \"POST_MESSAGE\",\r\n NEW_MESSAGE: \"NEW_MESSAGE\"\r\n}\r\n\r\nexport const UserTypes = {\r\n LOGIN: \"LOGIN\",\r\n LOGOUT: \"LOGOUT\"\r\n}\r\n\r\nexport const ApiTypes = {\r\n GET: \"GET\",\r\n POST: \"POST\",\r\n DELETE: \"DELETE\",\r\n PATCH: \"PATCH\"\r\n}\r\n\r\nexport const WHEN = {\r\n FIRST: \"FIRST\",\r\n NORMAL: \"NORMAL\"\r\n}","import { client } from \"../App\";\r\n\r\nimport { ApiTypes } from \"./../constants/ActionTypes.js\"\r\n//const url = \"https://scuffedwebsite.com/chat/api/messages/\";\r\n\r\n\r\n// Request recent messages from database using custom header\r\nexport const fetchMessages = async () =>\r\n{\r\n try\r\n {\r\n client.send(JSON.stringify({\r\n headers: {\r\n TYPE: ApiTypes.GET\r\n }\r\n }))\r\n }\r\n catch (err)\r\n {\r\n console.trace(err);\r\n }\r\n}\r\n\r\n\r\n// Add message to database and broadcast to other clients using custom header defined in \r\n// messageData\r\nexport const addMessage = async (messageData) =>\r\n{\r\n client.send(JSON.stringify(messageData));\r\n}\r\n\r\n\r\n// Delete messages in database using custom header\r\n// This should probably be removed but it's useful for testing purposes\r\nexport const Nuke = async () =>\r\n{\r\n client.send(JSON.stringify({\r\n headers: {\r\n TYPE: ApiTypes.DELETE\r\n }\r\n }));\r\n}","import { MessageTypes, WHEN } from \"../constants/ActionTypes\";\r\nimport * as api from \"./../api/index\";\r\n\r\nconst GetMessages = () => async (dispatch) =>\r\n{\r\n try\r\n {\r\n const data = await api.fetchMessages();\r\n console.log(data);\r\n dispatch({ payload: data, type: MessageTypes.FETCH_ALL });\r\n }\r\n catch (err)\r\n {\r\n console.trace(err);\r\n }\r\n}\r\n\r\nconst AddMessage = (messageData) => async (dispatch) =>\r\n{\r\n try\r\n {\r\n await api.addMessage(messageData);\r\n\r\n dispatch({ payload: messageData.body, type: MessageTypes.POST_MESSAGE });\r\n }\r\n catch (err)\r\n {\r\n console.trace(err);\r\n }\r\n}\r\n\r\nconst RenderNewMessage = (msg) => async (dispatch) =>\r\n{\r\n try\r\n {\r\n switch (msg.headers)\r\n {\r\n case WHEN.FIRST:\r\n dispatch({ payload: msg.body, type: MessageTypes.FETCH_ALL });\r\n break;\r\n case WHEN.NORMAL:\r\n dispatch({ payload: msg.body, type: MessageTypes.NEW_MESSAGE });\r\n break;\r\n default:\r\n console.log(\"(´。_。`) that wasn't supposed to happen\");\r\n break;\r\n }\r\n }\r\n catch (err)\r\n {\r\n console.trace(err);\r\n }\r\n}\r\n\r\n\r\n\r\nexport { GetMessages, AddMessage, RenderNewMessage };\r\n\r\n","import { useDispatch, useSelector } from \"react-redux\";\r\nimport { ApiTypes } from \"../../constants/ActionTypes\";\r\n\r\nimport { AddMessage } from \"./../../actions/Messages\"\r\n\r\nimport { TextField, withStyles } from \"@material-ui/core\"\r\nimport \"./chatfield.css\"\r\nconst styles = {\r\n root: {\r\n background: \"#222222\"\r\n },\r\n input: {\r\n color: \"#21D7EA\"\r\n }\r\n}\r\n\r\nconst Chatfield = ({ classes }) =>\r\n{\r\n\r\n const user = useSelector((state) => state.user);\r\n const dispatch = useDispatch();\r\n\r\n\r\n\r\n const HandleSubmit = (evt, bIsDesktop = false) =>\r\n {\r\n\r\n evt.preventDefault();\r\n\r\n const sMsgContent = bIsDesktop ? evt.target.value : evt.target[0].value;\r\n\r\n if (sMsgContent.length < 1) return;\r\n const messageData = {\r\n headers: {\r\n TYPE: ApiTypes.POST\r\n },\r\n body: {\r\n user: {\r\n id: user.id,\r\n displayName: user.displayName\r\n },\r\n message: {\r\n content: sMsgContent,\r\n date: new Date()\r\n }\r\n }\r\n }\r\n\r\n\r\n dispatch(AddMessage(messageData));\r\n\r\n if (bIsDesktop)\r\n {\r\n evt.target.value = \"\";\r\n evt.target.style.height = \"auto\";\r\n }\r\n else\r\n {\r\n evt.target[0].value = \"\";\r\n evt.target[0].style.height = \"auto\";\r\n }\r\n\r\n }\r\n\r\n const HandleEnter = (evt) =>\r\n {\r\n if (evt.keyCode === 13 && !evt.shiftKey)\r\n {\r\n HandleSubmit(evt, true);\r\n evt.target.value = \"\";\r\n };\r\n }\r\n\r\n return (\r\n
{str}
\r\n No messages(*^-^*)\r\n
\r\n\r\n Sidebar placeholder
\r\n \r\n