diff --git a/src/client.js b/src/client.js index 1222fbe..43367da 100644 --- a/src/client.js +++ b/src/client.js @@ -19,6 +19,7 @@ import { receiveChatHistory, receivePixelReturn, setMobile, + tryPlacePixel, } from './actions'; import store from './ui/store'; @@ -116,3 +117,28 @@ document.addEventListener('DOMContentLoaded', () => { } setInterval(runGC, 300000); }); + + +// on captcha received +// TODO: this really isn't beautiful +window.onCaptcha = async function onCaptcha(token: string) { + const body = JSON.stringify({ + token, + }); + await fetch('/api/captcha', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body, + // https://github.com/github/fetch/issues/349 + credentials: 'include', + }); + + const { + i, j, offset, color, + } = window.pixel; + store.dispatch(tryPlacePixel(i, j, offset, color)); + + window.grecaptcha.reset(); +}; diff --git a/src/components/App.jsx b/src/components/App.jsx index 5e07c0a..e2a2819 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -18,7 +18,6 @@ import ChatButton from './ChatButton'; import ChatBox from './ChatBox'; import Menu from './Menu'; import UI from './UI'; -import ReCaptcha from './ReCaptcha'; import ExpandMenuButton from './ExpandMenuButton'; import MinecraftTPButton from './MinecraftTPButton'; import ModalRoot from './ModalRoot'; @@ -27,7 +26,6 @@ const App = () => (