]> BookStack Code Mirror - bookstack/blobdiff - app/Util/SimpleListOptions.php
Revised revision list to responsive layout
[bookstack] / app / Util / SimpleListOptions.php
index f6daa6954adfcf4f7f5ab20641b0fa77c2d216c1..cb7e75a2d5609f48560d3aa6ac3e35078889e780 100644 (file)
@@ -28,11 +28,11 @@ class SimpleListOptions
      * Create a new instance from the given request.
      * Takes the item type (plural) that's used as a key for storing sort preferences.
      */
-    public static function fromRequest(Request $request, string $typeKey): self
+    public static function fromRequest(Request $request, string $typeKey, bool $sortDescDefault = false): self
     {
         $search = $request->get('search', '');
         $sort = setting()->getForCurrentUser($typeKey . '_sort', '');
-        $order = setting()->getForCurrentUser($typeKey . '_sort_order', 'asc');
+        $order = setting()->getForCurrentUser($typeKey . '_sort_order', $sortDescDefault ? 'desc' : 'asc');
 
         return new static($typeKey, $sort, $order, $search);
     }