-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add file sorting capabilities and sorting GET api #27398
Conversation
a697671
to
3528a67
Compare
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
2a21921
to
ad0ef00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(constant) names over meaningless integers
gna, github lost my comment |
$allowedDirection = ['asc', 'desc']; | ||
if (!in_array($mode, $allowedMode) || !in_array($direction, $allowedDirection)) { | ||
public function updateFileSorting($mode, $direction): Response { | ||
if (!in_array($mode, Capabilities::SORTING_MODES) || !in_array($direction, Capabilities::SORTING_DIRECTIONS)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!in_array($mode, Capabilities::SORTING_MODES) || !in_array($direction, Capabilities::SORTING_DIRECTIONS)) { | |
if (!in_array($mode, Capabilities::SORTING_MODES, true) || !in_array($direction, Capabilities::SORTING_DIRECTIONS, true)) { |
for strict comparison
* @return JSONResponse | ||
*/ | ||
public function getFileSorting(): JSONResponse { | ||
$file_sorting = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'file_sorting', Capabilities::SORTING_MODES[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💥 if the user is not logged in. please do a null check on the result of $this->userSession->getUser()
*/ | ||
public function getFileSorting(): JSONResponse { | ||
$file_sorting = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'file_sorting', Capabilities::SORTING_MODES[0]); | ||
$file_sorting_direction = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'file_sorting_direction', Capabilities::SORTING_DIRECTIONS[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
public const SORTING_MODES = ['name', 'size', 'mtime']; | ||
public const SORTING_DIRECTIONS = ['asc', 'desc']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use associative indices (probably event constants) to avoid messing with strings or meaningless numerical indices in the code.
moved to 27 |
Obsolete with new files to vue |
Will avoid apps to implement their own
nextcloud/viewer#650