File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed
Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,16 @@ protected function setUp(): void
2525 return ;
2626 }
2727
28- $ this ->success ($ subscribed ? 'Subscribed to notifications ' : 'Unsubscribed from notifications ' );
28+ $ this ->successNotificationTitle (
29+ $ subscribed ? 'Subscribed to notifications ' : 'Unsubscribed from notifications '
30+ );
31+
32+ $ this ->success ();
33+
34+ // Ask any listening components (like the sidebar) to refresh
35+ /** @var \Livewire\Component|null $livewire */
36+ $ livewire = $ this ->getLivewire ();
37+ $ livewire ?->dispatch('commentions:subscription:toggled ' )->to ('commentions::subscription-sidebar ' );
2938 })
3039 ->requiresConfirmation (false );
3140 }
Original file line number Diff line number Diff line change @@ -25,7 +25,16 @@ protected function setUp(): void
2525 return ;
2626 }
2727
28- $ this ->success ($ subscribed ? 'Subscribed to notifications ' : 'Unsubscribed from notifications ' );
28+ $ this ->successNotificationTitle (
29+ $ subscribed ? 'Subscribed to notifications ' : 'Unsubscribed from notifications '
30+ );
31+
32+ $ this ->success ();
33+
34+ // Ask any listening components (like the sidebar) to refresh
35+ /** @var \Livewire\Component|null $livewire */
36+ $ livewire = $ this ->getLivewire ();
37+ $ livewire ?->dispatch('commentions:subscription:toggled ' )->to ('commentions::subscription-sidebar ' );
2938 })
3039 ->requiresConfirmation (false );
3140 }
Original file line number Diff line number Diff line change 88use Kirschbaum \Commentions \Contracts \Commenter ;
99use Livewire \Attributes \Computed ;
1010use Livewire \Attributes \Renderless ;
11+ use Livewire \Attributes \On ;
1112
1213trait HasSidebar
1314{
@@ -89,6 +90,13 @@ public function toggleSubscription(): void
8990 unset($ this ->subscribers );
9091 }
9192
93+ #[On('commentions:subscription:toggled ' )]
94+ public function handleExternalSubscriptionToggle (): void
95+ {
96+ unset($ this ->isSubscribed );
97+ unset($ this ->subscribers );
98+ }
99+
92100 protected function getCurrentUser (): ?Commenter
93101 {
94102 return Config::resolveAuthenticatedUser ();
You can’t perform that action at this time.
0 commit comments