more code

This commit is contained in:
2023-09-16 15:15:48 +03:00
parent 2560086787
commit dac51ed4a4
3 changed files with 34 additions and 48 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ const Create = (props) => {
const [formData, setFormData] = useState({
title: "",
answers: ["", ""],
anonymous: false
anonymous: true
});
useEffect(() => {
+20 -42
View File
@@ -40,6 +40,23 @@ function Poll(props) {
return result;
}
useEffect(() => {
if (!token) {
console.log('POLL 🎱 id:', id)
console.log('POLL 🎱 token:', Boolean(token))
const data = {pid:id};
console.log(' 💾 POLL emit.join.data:', data)
socket.emit('join', data);
}
if (token) {
console.log('POLL 🎱 id:', id)
console.log('POLL 🎱 token:', Boolean(token))
const data = {pid:id, token: token};
console.log(' 💾 POLL emit.join.data:', data)
socket.emit('join', data);
}
},[id, token])
useEffect(() => {
console.log('POLL 🎱 id:', id)
console.log('POLL 🎱 exist:', exist)
@@ -48,52 +65,13 @@ function Poll(props) {
console.log('POLL 🎱 token:', Boolean(token))
console.log('POLL 🎱 poll:', poll)
if (!token) {
const data = {pid:id};
console.log(' 💾 POLL emit.join.data:', data)
socket.emit('join', data);
}
if (token) {
const data = {pid:id, token: token};
console.log(' 💾 POLL emit.join.data:', data)
socket.emit('join', data);
}
if (token && user) {
console.log('POLL 🎱 id:', id)
console.log('POLL 🎱 token:', Boolean(token))
console.log('POLL emit.poll.token:', token)
socket.emit('poll', token);
}
// if (exist === undefined) {
// console.log('POLL emit.exist.id:', id)
// socket.emit('exist', id)
// }
// if (exist && anon === undefined) {
// console.log('POLL emit.info.id:', id)
// socket.emit('info', id)
// }
// if (exist && anon !== undefined && anon && !token) {
// const data = {pid:id, user:randomUser(24)};
// console.log(' 💾 POLL emit.join.data:', data)
// socket.emit('join', data);
// }
// if (exist && anon !== undefined && !anon && !token) {
// console.log('POLL redirect anon:', JSON.stringify(anon))
// return navigate(`/poll/${id}/join`)
// }
// if (exist && anon !== undefined && anon && !token) {
// const data = {pid:id, user:randomUser(24)};
// console.log(' 💾 POLL emit.join.data:', data)
// socket.emit('join', data);
// }
// if (exist && anon !== undefined && anon && token) {
// const data = {pid:id, user:user};
// console.log(' 💾 💾 💾 POLL emit.join.data:', data)
// socket.emit('join', data);
// }
// if (exist && token) {
// console.log('POLL emit.poll.token:', token)
// socket.emit('poll', token);
// }
},[id, exist, anon, token])
},[token])
const onCopy = () => {
console.log('onCopy')