diff --git a/src/Platform/Http/Screens/NotificationScreen.php b/src/Platform/Http/Screens/NotificationScreen.php index c6b7af776..078d20388 100644 --- a/src/Platform/Http/Screens/NotificationScreen.php +++ b/src/Platform/Http/Screens/NotificationScreen.php @@ -41,6 +41,11 @@ class NotificationScreen extends Screen */ private $isNotEmpty = false; + /** + * @var bool + */ + private $hasUnread = false; + /** * Query data. * @@ -56,6 +61,9 @@ public function query(Request $request): iterable ->paginate(10); $this->isNotEmpty = $notifications->isNotEmpty(); + + $unreadNotifications = $request->user()->unreadNotifications; + $this->hasUnread = boolval(count($unreadNotifications)); return [ 'notifications' => $notifications, @@ -79,6 +87,7 @@ public function commandBar(): iterable Button::make(__('Mark all as read')) ->icon('eye') ->method('markAllAsRead') + ->disabled(!$this->hasUnread) ->canSee($this->isNotEmpty), ]; }