Add file sorting capabilities and sorting GET api#27398
Closed
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
blizzz
reviewed
Jun 7, 2021
Member
blizzz
left a comment
There was a problem hiding this comment.
(constant) names over meaningless integers
Member
|
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)) { |
Member
There was a problem hiding this comment.
Suggested change
| 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]); |
Member
There was a problem hiding this comment.
💥 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]); |
blizzz
reviewed
Jun 7, 2021
Comment on lines
+39
to
+40
| public const SORTING_MODES = ['name', 'size', 'mtime']; | ||
| public const SORTING_DIRECTIONS = ['asc', 'desc']; |
Member
There was a problem hiding this comment.
please use associative indices (probably event constants) to avoid messing with strings or meaningless numerical indices in the code.
Merged
Merged
Merged
Merged
Merged
Merged
Member
|
moved to 27 |
Member
Author
|
Obsolete with new files to vue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Will avoid apps to implement their own
nextcloud/viewer#650