]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/pages/Tournament.js
listen to round updates
[alttp.git] / resources / js / components / pages / Tournament.js
index cdafd69b12c2414140f3dce96d07c87cd2e68bf2..1f2a354c4cfaf39b1b1e2d2729ce733f84f8455e 100644 (file)
@@ -32,6 +32,22 @@ const Tournament = () => {
                        });
        }, [id]);
 
+       useEffect(() => {
+               window.Echo.private(`Tournament.${id}`)
+                       .listen('RoundAdded', e => {
+                               console.log(e);
+                               if (e.round) {
+                                       setTournament(tournament => ({
+                                               ...tournament,
+                                               rounds: [...tournament.rounds, e.round],
+                                       }));
+                               }
+                       });
+               return () => {
+                       window.Echo.leave(`Tournament.${id}`);
+               };
+       }, [id]);
+
        if (loading) {
                return <Loading />;
        }