]> BookStack Code Mirror - bookstack/blobdiff - app/Users/Controllers/UserPreferencesController.php
fix Sidebar scrolling at mid-range sceen
[bookstack] / app / Users / Controllers / UserPreferencesController.php
index d9ee50ca71396d11b18328e80c17b2ea23bffc18..08d65743b8c766b1e76e7da08b55b07d5de59c18 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace BookStack\Users\Controllers;
 
-use BookStack\Activity\Models\Watch;
 use BookStack\Http\Controller;
 use BookStack\Permissions\PermissionApplicator;
 use BookStack\Settings\UserNotificationPreferences;
@@ -33,6 +32,8 @@ class UserPreferencesController extends Controller
         $shortcuts = UserShortcutMap::fromUserPreferences();
         $enabled = setting()->getForCurrentUser('ui-shortcuts-enabled', false);
 
+        $this->setPageTitle(trans('preferences.shortcuts_interface'));
+
         return view('users.preferences.shortcuts', [
             'shortcuts' => $shortcuts,
             'enabled' => $enabled,
@@ -62,13 +63,16 @@ class UserPreferencesController extends Controller
     public function showNotifications(PermissionApplicator $permissions)
     {
         $this->checkPermission('receive-notifications');
+        $this->preventGuestAccess();
 
         $preferences = (new UserNotificationPreferences(user()));
 
-        $query = Watch::query()->where('user_id', '=', user()->id);
+        $query = user()->watches()->getQuery();
         $query = $permissions->restrictEntityRelationQuery($query, 'watches', 'watchable_id', 'watchable_type');
+        $query = $permissions->filterDeletedFromEntityRelationQuery($query, 'watches', 'watchable_id', 'watchable_type');
         $watches = $query->with('watchable')->paginate(20);
 
+        $this->setPageTitle(trans('preferences.notifications'));
         return view('users.preferences.notifications', [
             'preferences' => $preferences,
             'watches' => $watches,
@@ -81,6 +85,7 @@ class UserPreferencesController extends Controller
     public function updateNotifications(Request $request)
     {
         $this->checkPermission('receive-notifications');
+        $this->preventGuestAccess();
         $data = $this->validate($request, [
            'preferences' => ['required', 'array'],
            'preferences.*' => ['required', 'string'],
@@ -140,7 +145,7 @@ class UserPreferencesController extends Controller
      */
     public function toggleDarkMode()
     {
-        $enabled = setting()->getForCurrentUser('dark-mode-enabled', false);
+        $enabled = setting()->getForCurrentUser('dark-mode-enabled');
         setting()->putForCurrentUser('dark-mode-enabled', $enabled ? 'false' : 'true');
 
         return redirect()->back();