X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fpages%2FTournament.js;h=1f2a354c4cfaf39b1b1e2d2729ce733f84f8455e;hb=4388278823ac8a791641ac1d65fc675e9543b8e8;hp=cdafd69b12c2414140f3dce96d07c87cd2e68bf2;hpb=2efd7613561696a3abb19ee9f42b15cf9b4058ad;p=alttp.git diff --git a/resources/js/components/pages/Tournament.js b/resources/js/components/pages/Tournament.js index cdafd69..1f2a354 100644 --- a/resources/js/components/pages/Tournament.js +++ b/resources/js/components/pages/Tournament.js @@ -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 ; }