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 <noreply@anthropic.com>
This commit is contained in:
myrmidex 2026-03-07 17:22:05 +01:00
parent b658f847fb
commit 276812811c
2 changed files with 2 additions and 7 deletions

View file

@ -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()

View file

@ -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"
>
<svg class="h-4 w-4 mr-2 {{ $isRefreshing ? 'animate-spin' : '' }}" wire:loading.class="animate-spin" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">