X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fpages%2FTournament.js;h=1f2a354c4cfaf39b1b1e2d2729ce733f84f8455e;hb=c30ac282dde3d746d6a7762ee18c70b4416500b5;hp=cdafd69b12c2414140f3dce96d07c87cd2e68bf2;hpb=edd0e97bfdc544114f30bf4c13a929631c44a555;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 ; }