Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

skjnldsv
Copy link
Member

@skjnldsv skjnldsv commented Jun 5, 2021

Will avoid apps to implement their own
nextcloud/viewer#650

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Copy link
Member

@blizzz blizzz left a 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

@blizzz
Copy link
Member

blizzz commented Jun 7, 2021

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)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]);
Copy link
Member

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]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment on lines +39 to +40
public const SORTING_MODES = ['name', 'size', 'mtime'];
public const SORTING_DIRECTIONS = ['asc', 'desc'];
Copy link
Member

@blizzz blizzz Jun 7, 2021

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.

@skjnldsv skjnldsv modified the milestones: Nextcloud 22, Nextcloud 23 Jun 7, 2021
@skjnldsv skjnldsv added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Jun 7, 2021
@MorrisJobke MorrisJobke removed their request for review July 4, 2021 11:33
@skjnldsv skjnldsv mentioned this pull request Oct 13, 2021
@skjnldsv skjnldsv modified the milestones: Nextcloud 23, Nextcloud 24 Oct 21, 2021
@skjnldsv skjnldsv mentioned this pull request Mar 24, 2022
@blizzz blizzz mentioned this pull request Mar 31, 2022
This was referenced Apr 7, 2022
@blizzz blizzz modified the milestones: Nextcloud 24, Nextcloud 25 Apr 21, 2022
This was referenced Aug 12, 2022
@skjnldsv skjnldsv modified the milestones: Nextcloud 25, Nextcloud 26 Aug 18, 2022
@blizzz blizzz mentioned this pull request Feb 1, 2023
@skjnldsv skjnldsv mentioned this pull request Feb 23, 2023
@blizzz blizzz mentioned this pull request Mar 7, 2023
@blizzz blizzz modified the milestones: Nextcloud 26, Nextcloud 27 Mar 7, 2023
@blizzz
Copy link
Member

blizzz commented Mar 7, 2023

moved to 27

@skjnldsv
Copy link
Member Author

Obsolete with new files to vue

@skjnldsv skjnldsv closed this Apr 19, 2023
@ChristophWurst ChristophWurst deleted the feat/files-sorting branch April 19, 2023 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants