- * Change the stored sort type for the books view.
- * @param $id
- * @param Request $request
- * @return \Illuminate\Http\RedirectResponse
+ * Change the stored sort type for a particular view.
+ */
+ public function changeSort(Request $request, string $id, string $type)
+ {
+ $validSortTypes = ['books', 'bookshelves'];
+ if (!in_array($type, $validSortTypes)) {
+ return redirect()->back(500);
+ }
+ return $this->changeListSort($id, $request, $type);
+ }
+
+ /**
+ * Toggle dark mode for the current user.
+ */
+ public function toggleDarkMode()
+ {
+ $enabled = setting()->getForCurrentUser('dark-mode-enabled', false);
+ setting()->putUser(user(), 'dark-mode-enabled', $enabled ? 'false' : 'true');
+ return redirect()->back();
+ }
+
+ /**
+ * Update the stored section expansion preference for the given user.