more code
This commit is contained in:
parent
057f46403c
commit
6d12abab13
12
src/App.js
12
src/App.js
@ -38,6 +38,14 @@ function App() {
|
||||
setAnon(undefined)
|
||||
navigate(`/poll/${data}`)
|
||||
}
|
||||
function onExist(data) {
|
||||
console.log(' 🪲 APP onExist data: ', data)
|
||||
setExist(Boolean(data))
|
||||
if (data) {
|
||||
console.log(' 🪲 APP onExist join: ', data)
|
||||
socket.emit('join', data);
|
||||
}
|
||||
}
|
||||
function onJoin(data) {
|
||||
console.log(' 🪲 APP onJoin data: ', data)
|
||||
setUser(data.user)
|
||||
@ -49,10 +57,6 @@ function App() {
|
||||
setPoll(data.poll)
|
||||
setUser(data.user)
|
||||
}
|
||||
function onExist(data) {
|
||||
console.log(' 🪲 APP onExist data: ', data)
|
||||
setExist(data)
|
||||
}
|
||||
function onInfo(data) {
|
||||
console.log(' 🪲 APP onInfo data: ', data)
|
||||
if (data.anonymous !== undefined) {
|
||||
|
||||
@ -34,11 +34,11 @@ const Home = (props) => {
|
||||
return (
|
||||
<li className="my-6" key={index}>
|
||||
<Link to={`/poll/${item.id}`}>
|
||||
<div className="bg-white text-black p-4 flex flex-row justify-between">
|
||||
<div>☆ {item.title}</div>
|
||||
<div>
|
||||
<span className="text-gray-500"> ({item.users})</span>
|
||||
{item.anonymous ? <span>anonymous</span> : <span>{item.user}</span>}
|
||||
<div className="flex flex-col shadow-lg">
|
||||
<div className="bg-white text-black px-4 py-2 rounded-tl rounded-tr"><h3>{item.title}</h3></div>
|
||||
<div className="bg-black text-white px-4 py-1 rounded-bl rounded-br text-xs flex flex-row justify-between">
|
||||
<span className="text-gray-500">{item.users} votes</span>
|
||||
<span>{item.anonymous ? <span>anonymous</span> : <span>{item.user}</span>}</span>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
@ -41,30 +41,39 @@ function Poll(props) {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
console.log('POLL props:', props)
|
||||
console.log('POLL 🎱 props:', props)
|
||||
console.log('POLL 🎱 id:', id)
|
||||
console.log('POLL 🎱 exist:', exist)
|
||||
console.log('POLL 🎱 anon:', anon)
|
||||
console.log('POLL 🎱 token:', Boolean(token))
|
||||
|
||||
if (exist === undefined) {
|
||||
console.log('POLL emit.exist.id:', id)
|
||||
socket.emit('exist', id)
|
||||
}
|
||||
if (anon === undefined) {
|
||||
if (exist && anon === undefined) {
|
||||
console.log('POLL emit.info.id:', id)
|
||||
socket.emit('info', id)
|
||||
}
|
||||
if (exist && !token && anon !== undefined && anon) {
|
||||
if (exist && anon !== undefined && anon && !token) {
|
||||
const data = {pid:id, user:randomUser(24)};
|
||||
socket.emit('join', data);
|
||||
console.log('POLL emit.join.data:', data)
|
||||
socket.emit('join', data);
|
||||
}
|
||||
if (exist && !token && anon !== undefined && !anon) {
|
||||
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: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);
|
||||
}
|
||||
},[user, exist, anon])
|
||||
},[id, exist, anon, token])
|
||||
|
||||
const onCopy = () => {
|
||||
console.log('onCopy')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user