3838namespace OCA \Files \Controller ;
3939
4040use OC \Files \Node \Node ;
41+ use OCA \Files \Capabilities ;
4142use OCA \Files \Service \TagService ;
4243use OCP \AppFramework \Controller ;
4344use OCP \AppFramework \Http ;
5455use OCP \IUserSession ;
5556use OCP \Share \IManager ;
5657use OCP \Share \IShare ;
57-
5858/**
5959 * Class ApiController
6060 *
@@ -267,12 +267,9 @@ public function getRecentFiles() {
267267 * @param string $mode
268268 * @param string $direction
269269 * @return Response
270- * @throws \OCP\PreConditionNotMetException
271270 */
272- public function updateFileSorting ($ mode , $ direction ) {
273- $ allowedMode = ['name ' , 'size ' , 'mtime ' ];
274- $ allowedDirection = ['asc ' , 'desc ' ];
275- if (!in_array ($ mode , $ allowedMode ) || !in_array ($ direction , $ allowedDirection )) {
271+ public function updateFileSorting ($ mode , $ direction ): Response {
272+ if (!in_array ($ mode , Capabilities::SORTING_MODES ) || !in_array ($ direction , Capabilities::SORTING_DIRECTIONS )) {
276273 $ response = new Response ();
277274 $ response ->setStatus (Http::STATUS_UNPROCESSABLE_ENTITY );
278275 return $ response ;
@@ -282,6 +279,23 @@ public function updateFileSorting($mode, $direction) {
282279 return new Response ();
283280 }
284281
282+
283+ /**
284+ * Get the default sort mode
285+ *
286+ * @NoAdminRequired
287+ *
288+ * @return Response
289+ */
290+ public function getFileSorting (): JSONResponse {
291+ $ file_sorting = $ this ->config ->getUserValue ($ this ->userSession ->getUser ()->getUID (), 'files ' , 'file_sorting ' , Capabilities::SORTING_MODES [0 ]);
292+ $ file_sorting_direction = $ this ->config ->getUserValue ($ this ->userSession ->getUser ()->getUID (), 'files ' , 'file_sorting_direction ' , Capabilities::SORTING_DIRECTIONS [0 ]);
293+ return new JSONResponse ([
294+ 'file_sorting ' => $ file_sorting ,
295+ 'file_sorting_direction ' => $ file_sorting_direction
296+ ]);
297+ }
298+
285299 /**
286300 * Toggle default for showing/hiding hidden files
287301 *
0 commit comments