File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed
Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change 77use Kirschbaum \Commentions \Config ;
88use Kirschbaum \Commentions \Contracts \Commenter ;
99use Livewire \Attributes \Computed ;
10- use Livewire \Attributes \On ;
1110use Livewire \Attributes \Renderless ;
1211
1312trait HasSidebar
@@ -61,6 +60,13 @@ public function subscribers(): Collection
6160 return $ this ->record ->getSubscribers ();
6261 }
6362
63+ #[Renderless]
64+ public function refreshSubscribers (): void
65+ {
66+ unset($ this ->isSubscribed );
67+ unset($ this ->subscribers );
68+ }
69+
6470 #[Renderless]
6571 public function toggleSubscription (): void
6672 {
@@ -86,15 +92,9 @@ public function toggleSubscription(): void
8692 ->send ();
8793 }
8894
89- unset($ this ->isSubscribed );
90- unset($ this ->subscribers );
91- }
95+ $ this ->refreshSubscribers ();
9296
93- #[On('commentions:subscription:toggled ' )]
94- public function handleExternalSubscriptionToggle (): void
95- {
96- unset($ this ->isSubscribed );
97- unset($ this ->subscribers );
97+ $ this ->dispatch ('commentions:subscription:toggled ' )->to ('commentions::subscription-sidebar ' );
9898 }
9999
100100 protected function getCurrentUser (): ?Commenter
Original file line number Diff line number Diff line change 44
55use Illuminate \Database \Eloquent \Model ;
66use Kirschbaum \Commentions \Livewire \Concerns \HasSidebar ;
7+ use Livewire \Attributes \On ;
78use Livewire \Component ;
89
910class SubscriptionSidebar extends Component
@@ -18,6 +19,12 @@ public function mount(Model $record, ?bool $showSubscribers = null): void
1819 $ this ->mountHasSidebar (true , $ showSubscribers );
1920 }
2021
22+ #[On('commentions:subscription:toggled ' )]
23+ public function handleExternalSubscriptionToggle (): void
24+ {
25+ $ this ->refreshSubscribers ();
26+ }
27+
2128 public function render ()
2229 {
2330 return view ('commentions::subscription-sidebar ' );
You can’t perform that action at this time.
0 commit comments