From 2efd7613561696a3abb19ee9f42b15cf9b4058ad Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Fri, 11 Mar 2022 09:53:15 +0100 Subject: [PATCH] add command to reload clients --- app/Console/Commands/PleaseRefresh.php | 33 +++++++++++++++++++++++ app/Events/PleaseRefresh.php | 37 ++++++++++++++++++++++++++ resources/js/components/App.js | 10 +++++++ resources/js/i18n/de.js | 1 + routes/channels.php | 6 ++++- 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 app/Console/Commands/PleaseRefresh.php create mode 100644 app/Events/PleaseRefresh.php diff --git a/app/Console/Commands/PleaseRefresh.php b/app/Console/Commands/PleaseRefresh.php new file mode 100644 index 0000000..7ebea1c --- /dev/null +++ b/app/Console/Commands/PleaseRefresh.php @@ -0,0 +1,33 @@ + { }; }, []); + useEffect(() => { + window.Echo.channel('App.Control') + .listen('PleaseRefresh', () => { + location.reload(); + }); + return () => { + window.Echo.leave('App.Control'); + }; + }, []); + return
diff --git a/resources/js/i18n/de.js b/resources/js/i18n/de.js index e31b96c..033059b 100644 --- a/resources/js/i18n/de.js +++ b/resources/js/i18n/de.js @@ -21,6 +21,7 @@ export default { }, rounds: { date: '{{ date, L }}', + empty: 'Noch keine Runde gestartet', heading: 'Runden', new: 'Neue Runde', }, diff --git a/routes/channels.php b/routes/channels.php index 5d451e1..4302bb7 100644 --- a/routes/channels.php +++ b/routes/channels.php @@ -14,5 +14,9 @@ use Illuminate\Support\Facades\Broadcast; */ Broadcast::channel('App.Models.User.{id}', function ($user, $id) { - return (int) $user->id === (int) $id; + return (int) $user->id === (int) $id; +}); + +Broadcast::channel('App.Control', function ($user) { + return true; }); -- 2.39.2