Skip to content
Snippets Groups Projects
Commit b0c30663 authored by Bo-Chun Chen's avatar Bo-Chun Chen
Browse files

Add DEBUG flag for debug messages

parent e50e7d52
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ import Spinner from 'react-bootstrap/Spinner'; ...@@ -10,6 +10,7 @@ import Spinner from 'react-bootstrap/Spinner';
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons' import { faInfoCircle } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
const DEBUG = true;
// use REMOTE_USER for production // use REMOTE_USER for production
const username = 'louistw'; const username = 'louistw';
...@@ -39,7 +40,7 @@ function Main(props) { ...@@ -39,7 +40,7 @@ function Main(props) {
e.stopPropagation(); e.stopPropagation();
} else { } else {
showModal(); showModal();
console.log('Modal showed') if (DEBUG) console.log('Modal showed')
socket.emit('request', { socket.emit('request', {
'username': username, 'username': username,
'firstName': firstName.current.value, 'firstName': firstName.current.value,
...@@ -50,24 +51,23 @@ function Main(props) { ...@@ -50,24 +51,23 @@ function Main(props) {
} }
useEffect(() => { useEffect(() => {
console.log(socket.rooms) if (DEBUG) console.log(socket)
// Define socketio events // Define socketio events
if (!isConnected) { if (!isConnected) {
socket.emit('join_room', {username}, () => setIsConnected(true)); socket.emit('join_room', {username}, () => setIsConnected(true));
socket.on('message', data => { socket.on('message', data => {
console.log(data + ' ' + socket.id); if (DEBUG) console.log(data + ' ' + socket.id);
}); });
socket.on('connect', data => { socket.on('connect', data => {
console.log('on connect: ' + socket.id); if (DEBUG) console.log('on connect: ' + socket.id);
}); });
socket.on('requested', data => { socket.on('requested', data => {
console.log('Account requested'); if (DEBUG) console.log('Account requested');
showModal(); showModal();
}); });
socket.on('created', data => { socket.on('created', data => {
console.log('account has been created.') if (DEBUG) console.log('account has been created.')
let sec = 3; let sec = 3;
(function countdown () { (function countdown () {
setModalTitle("Your account is ready!"); setModalTitle("Your account is ready!");
...@@ -75,7 +75,7 @@ function Main(props) { ...@@ -75,7 +75,7 @@ function Main(props) {
setTimeout(countdown, 1000); setTimeout(countdown, 1000);
})() })()
setTimeout(() => { setTimeout(() => {
console.log('Redirecting to /test') if (DEBUG) console.log('Redirecting to /test')
window.location = '/test'; window.location = '/test';
}, sec * 1000); }, sec * 1000);
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment