From 276812811ccd28147117e7800d9abbf73f268a90 Mon Sep 17 00:00:00 2001 From: myrmidex Date: Sat, 7 Mar 2026 17:22:05 +0100 Subject: [PATCH] 64 - Reload page after article refresh Dispatch a Livewire event on refresh that triggers a 10-second setTimeout via Alpine.js, then reloads the page to show newly fetched articles. Co-Authored-By: Claude Opus 4.6 --- app/Livewire/Articles.php | 8 +------- resources/views/livewire/articles.blade.php | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/Livewire/Articles.php b/app/Livewire/Articles.php index 4cce6b3..6e603be 100644 --- a/app/Livewire/Articles.php +++ b/app/Livewire/Articles.php @@ -36,13 +36,7 @@ public function refresh(): void ArticleDiscoveryJob::dispatch(); - // Reset after 10 seconds - $this->dispatch('refresh-complete')->self(); - } - - public function refreshComplete(): void - { - $this->isRefreshing = false; + $this->dispatch('refresh-started'); } public function render() diff --git a/resources/views/livewire/articles.blade.php b/resources/views/livewire/articles.blade.php index b972dd5..3acec05 100644 --- a/resources/views/livewire/articles.blade.php +++ b/resources/views/livewire/articles.blade.php @@ -19,6 +19,7 @@ wire:click="refresh" wire:loading.attr="disabled" @disabled($isRefreshing) + x-on:refresh-started.window="setTimeout(() => window.location.reload(), 10000)" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed" >