-
-
Notifications
You must be signed in to change notification settings - Fork 287
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
Ensure consistent sorting of albums in list of shares #1429
Conversation
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.
I agree that the list should be explicitly ordered by something but why is hardcoding the title the right thing to do? Shouldn't the list be ordered by what the user specified in the settings?
I had the exact same thought, but then I looked at the remaining code of this method and all other sorting is hard-coded, too. For example, the list of existing shares is also sorted according to the album title (and then by user name) in a hard-coded manner. I wanted to keep this code consistent. Of course we could sort the list of albums without shares according to the user-defined sorting order, but then we should do this for the list of existing shares as well. This means more changes to the code than this PR. I assume the choice was made, because the list of shares does not show any previews in form of thumbnails. if the user had selected an ordering with respect to |
The code becomes: $albums_query = DB::table('base_albums')
->leftJoin('albums', 'albums.id', '=', 'base_albums.id')
->select(['base_albums.id', 'title', 'parent_id'])
->orderBy('title', 'ASC'); // added by this PR.
[...]
$albums = $albums_query->get();
$this->linkAlbums($albums);
$albums->each(function ($album) {
$album->title = $this->breadcrumbPath($album);
});
$albums->each(function ($album) {
unset($album->parent_id);
unset($album->parent);
}); However I would believe this is not the behavior we want.
If I read the code properly, the resulting list will be
While I would expect the following:
I am not saying it is better than current behavior, but I don't think this is the direction we completely want to go in. |
No, that is incorrect.
That is exactly what happens. The code still builds a proper tree. It has done that before (even with indeterministic ordering) and it will still do so afterwards. The only question is if we are fine with a hard-coded ordering wrt. the |
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.
LGTM.
And another pick of cherries from #1414. This PR ensures that the list of available albums (i.e. those albums which aren't shared yet) in the list of shares is consistent and deterministic.