]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/pages/Tournament.js
lock tournaments
[alttp.git] / resources / js / components / pages / Tournament.js
index 5a9c8b05c207ce74db4c159559bdef5b5511b106..11dc388c67d60c3832a977a7265a93033b7010ee 100644 (file)
@@ -34,9 +34,8 @@ const Tournament = () => {
        }, [id]);
 
        useEffect(() => {
-               window.Echo.private(`Tournament.${id}`)
+               window.Echo.channel(`Tournament.${id}`)
                        .listen('ResultReported', e => {
-                               console.log(e);
                                if (e.result) {
                                        setTournament(tournament => patchResult(tournament, e.result));
                                }
@@ -45,7 +44,7 @@ const Tournament = () => {
                                if (e.round) {
                                        setTournament(tournament => ({
                                                ...tournament,
-                                               rounds: [...tournament.rounds, e.round],
+                                               rounds: [e.round, ...tournament.rounds],
                                        }));
                                }
                        })
@@ -53,6 +52,11 @@ const Tournament = () => {
                                if (e.round) {
                                        setTournament(tournament => patchRound(tournament, e.round));
                                }
+                       })
+                       .listen('TournamentChanged', e => {
+                               if (e.tournament) {
+                                       setTournament(tournament => ({ ...tournament, ...e.tournament }));
+                               }
                        });
                return () => {
                        window.Echo.leave(`Tournament.${id}`);