Skip to content

Commit

Permalink
Merge pull request #349 from mitaai/preview
Browse files Browse the repository at this point in the history
commenting out websocket code
  • Loading branch information
mbogo-mit authored Dec 7, 2023
2 parents eaf0c1b + 97859ce commit 2287d45
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/pages/api/user/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const handler = async (req, res) => {
updateMethods.$currentDate = { updatedAt: true };


console.log("ObjectId.isValid(req.query.id): ", ObjectId.isValid(req.query.id))
// console.log("ObjectId.isValid(req.query.id): ", ObjectId.isValid(req.query.id))

const doc = await db
.collection('users')
Expand Down
72 changes: 36 additions & 36 deletions src/pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,34 @@ export default function Home({
const newReg = query && query.alert && query.alert === 'completeRegistration';
const loading = status === 'loading';

const [socketUrl, setSocketUrl] = useState('wss://wq5pn518mf.execute-api.us-east-2.amazonaws.com/dev/');
const [messageHistory, setMessageHistory] = useState([]);
// const [socketUrl, setSocketUrl] = useState('wss://wq5pn518mf.execute-api.us-east-2.amazonaws.com/dev/');
// const [messageHistory, setMessageHistory] = useState([]);

const {
sendMessage,
sendJsonMessage,
lastMessage,
lastJsonMessage,
readyState,
getWebSocket,
} = useWebSocket(socketUrl, {
onOpen: () => console.log('opened'),
//Will attempt to reconnect on all close events, such as server shutting down
shouldReconnect: (closeEvent) => true,
});
// const {
// sendMessage,
// sendJsonMessage,
// lastMessage,
// lastJsonMessage,
// readyState,
// getWebSocket,
// } = useWebSocket(socketUrl, {
// onOpen: () => console.log('opened'),
// //Will attempt to reconnect on all close events, such as server shutting down
// shouldReconnect: (closeEvent) => true,
// });

const connectionStatus = {
[ReadyState.CONNECTING]: 'Connecting',
[ReadyState.OPEN]: 'Open',
[ReadyState.CLOSING]: 'Closing',
[ReadyState.CLOSED]: 'Closed',
[ReadyState.UNINSTANTIATED]: 'Uninstantiated',
}[readyState];
// const connectionStatus = {
// [ReadyState.CONNECTING]: 'Connecting',
// [ReadyState.OPEN]: 'Open',
// [ReadyState.CLOSING]: 'Closing',
// [ReadyState.CLOSED]: 'Closed',
// [ReadyState.UNINSTANTIATED]: 'Uninstantiated',
// }[readyState];

console.log('connectionStatus: ', connectionStatus);
// console.log('connectionStatus: ', connectionStatus);


const handleSendMessage = useCallback(() => sendJsonMessage({ "action": 'request', "rm": '1', "_set": { "name": 'bob' } }), []);
// const handleSendMessage = useCallback(() => sendJsonMessage({ "action": 'request', "rm": '1', "_set": { "name": 'bob' } }), []);


const channelsMinWidth = 1375;
Expand Down Expand Up @@ -266,19 +266,19 @@ export default function Home({
);
};

useEffect(() => {
if (lastMessage !== null) {
console.log('lastMessage: ', lastMessage)
setMessageHistory((prev) => prev.concat(lastMessage));
}
}, [lastMessage, setMessageHistory]);
// useEffect(() => {
// if (lastMessage !== null) {
// console.log('lastMessage: ', lastMessage)
// setMessageHistory((prev) => prev.concat(lastMessage));
// }
// }, [lastMessage, setMessageHistory]);

useEffect(() => {
if (lastJsonMessage !== null) {
console.log('lastJsonMessage: ', lastJsonMessage)
setMessageHistory((prev) => prev.concat(lastJsonMessage));
}
}, [lastJsonMessage, setMessageHistory]);
// useEffect(() => {
// if (lastJsonMessage !== null) {
// console.log('lastJsonMessage: ', lastJsonMessage)
// setMessageHistory((prev) => prev.concat(lastJsonMessage));
// }
// }, [lastJsonMessage, setMessageHistory]);


useEffect(() => {
Expand Down Expand Up @@ -359,7 +359,7 @@ export default function Home({
}
}}
>
<Button onClick={() => handleSendMessage({ "action": 'request', "rm": '1', "_set": { "name": 'bob' } })}>Hello</Button>
{/* <Button onClick={() => handleSendMessage({ "action": 'request', "rm": '1', "_set": { "name": 'bob' } })}>Hello</Button> */}
{loading && (
<Card>
<Card.Body>
Expand Down

0 comments on commit 2287d45

Please sign in to comment.