]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/pages/Tournament.js
allow users to set their stream link
[alttp.git] / resources / js / components / pages / Tournament.js
index 11dc388c67d60c3832a977a7265a93033b7010ee..6e32227ab2d04d330b8025dc16744fdbbee5d606 100644 (file)
@@ -7,7 +7,7 @@ import ErrorMessage from '../common/ErrorMessage';
 import Loading from '../common/Loading';
 import NotFound from '../pages/NotFound';
 import Detail from '../tournament/Detail';
-import { patchResult, patchRound, sortParticipants } from '../../helpers/Tournament';
+import { patchResult, patchRound, patchUser, sortParticipants } from '../../helpers/Tournament';
 
 const Tournament = () => {
        const params = useParams();
@@ -63,6 +63,20 @@ const Tournament = () => {
                };
        }, [id]);
 
+       useEffect(() => {
+               const cb = (e) => {
+                       if (e.user) {
+                               setTournament(tournament => patchUser(tournament, e.user));
+                       }
+               };
+               window.Echo.channel('App.Control')
+                       .listen('UserChanged', cb);
+               return () => {
+                       window.Echo.channel('App.Control')
+                               .stopListening('UserChanged', cb);
+               };
+       }, []);
+
        if (loading) {
                return <Loading />;
        }