From c9490fbe2305cbe6e6c7ebe125461d95f008c7fe Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 16 Mar 2022 16:57:17 +0100 Subject: [PATCH] public tournament page --- app/Events/ResultReported.php | 2 +- app/Events/RoundAdded.php | 2 +- app/Events/RoundChanged.php | 2 +- app/Policies/TournamentPolicy.php | 4 ++-- resources/js/components/App.js | 11 ++++------- resources/js/components/pages/Tournament.js | 2 +- resources/js/components/protocol/Protocol.js | 1 - 7 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/Events/ResultReported.php b/app/Events/ResultReported.php index 2a3eeb0..61ec98b 100644 --- a/app/Events/ResultReported.php +++ b/app/Events/ResultReported.php @@ -32,7 +32,7 @@ class ResultReported implements ShouldBroadcast */ public function broadcastOn() { - return new PrivateChannel('Tournament.'.$this->result->round->tournament_id); + return new Channel('Tournament.'.$this->result->round->tournament_id); } public $result; diff --git a/app/Events/RoundAdded.php b/app/Events/RoundAdded.php index a1b8787..0ea5661 100644 --- a/app/Events/RoundAdded.php +++ b/app/Events/RoundAdded.php @@ -32,7 +32,7 @@ class RoundAdded implements ShouldBroadcast */ public function broadcastOn() { - return new PrivateChannel('Tournament.'.$this->round->tournament_id); + return new Channel('Tournament.'.$this->round->tournament_id); } public $round; diff --git a/app/Events/RoundChanged.php b/app/Events/RoundChanged.php index 91d641b..a4df199 100644 --- a/app/Events/RoundChanged.php +++ b/app/Events/RoundChanged.php @@ -32,7 +32,7 @@ class RoundChanged implements ShouldBroadcast */ public function broadcastOn() { - return new PrivateChannel('Tournament.'.$this->round->tournament_id); + return new Channel('Tournament.'.$this->round->tournament_id); } public $round; diff --git a/app/Policies/TournamentPolicy.php b/app/Policies/TournamentPolicy.php index fd2a781..534813c 100644 --- a/app/Policies/TournamentPolicy.php +++ b/app/Policies/TournamentPolicy.php @@ -16,7 +16,7 @@ class TournamentPolicy * @param \App\Models\User $user * @return \Illuminate\Auth\Access\Response|bool */ - public function viewAny(User $user) + public function viewAny(?User $user) { return true; } @@ -28,7 +28,7 @@ class TournamentPolicy * @param \App\Models\Tournament $tournament * @return \Illuminate\Auth\Access\Response|bool */ - public function view(User $user, Tournament $tournament) + public function view(?User $user, Tournament $tournament) { return true; } diff --git a/resources/js/components/App.js b/resources/js/components/App.js index f632989..0199b93 100644 --- a/resources/js/components/App.js +++ b/resources/js/components/App.js @@ -3,7 +3,6 @@ import React, { useEffect, useState } from 'react'; import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom'; import Header from './common/Header'; -import Front from './pages/Front'; import Tournament from './pages/Tournament'; import UserContext from '../helpers/UserContext'; @@ -50,12 +49,10 @@ const App = () => { return
- {user ? - - } /> - } /> - - : } + + } /> + } /> + ; }; diff --git a/resources/js/components/pages/Tournament.js b/resources/js/components/pages/Tournament.js index a5c43ca..d5df3a1 100644 --- a/resources/js/components/pages/Tournament.js +++ b/resources/js/components/pages/Tournament.js @@ -34,7 +34,7 @@ const Tournament = () => { }, [id]); useEffect(() => { - window.Echo.private(`Tournament.${id}`) + window.Echo.channel(`Tournament.${id}`) .listen('ResultReported', e => { if (e.result) { setTournament(tournament => patchResult(tournament, e.result)); diff --git a/resources/js/components/protocol/Protocol.js b/resources/js/components/protocol/Protocol.js index e94cad7..7cd0b75 100644 --- a/resources/js/components/protocol/Protocol.js +++ b/resources/js/components/protocol/Protocol.js @@ -23,7 +23,6 @@ const Protocol = ({ id }) => { useEffect(() => { window.Echo.private(`Protocol.${id}`) .listen('ProtocolAdded', e => { - console.log(e); if (e.protocol) { setProtocol(protocol => [e.protocol, ...protocol]); } -- 2.39.2