1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Merge pull request #230 from bruce30262/fix_gallery_order_issue

Fix gallery order issue
This commit is contained in:
Patrik J. Braun 2021-03-07 09:20:25 +01:00 committed by GitHub
commit 0f40bb67e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 20 deletions

View File

@ -172,13 +172,17 @@ export class GalleryComponent implements OnInit, OnDestroy {
}
switch (this._galleryService.sorting.value) {
case SortingMethods.ascName:
case SortingMethods.ascDate:
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare()(a.name, b.name));
break;
case SortingMethods.ascDate:
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare()(a.lastModified, b.lastModified));
break;
case SortingMethods.descName:
case SortingMethods.descDate:
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare({ order: 'desc' })(a.name, b.name));
break;
case SortingMethods.descDate:
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare({ order: 'desc' })(a.lastModified, b.lastModified));
break;
case SortingMethods.random:
this.rndService.setSeed(this.directories.length);
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => {

View File

@ -28,6 +28,7 @@ import {SortingMethods} from '../../../../../common/entities/SortingMethods';
import {MediaDTO} from '../../../../../common/entities/MediaDTO';
import {QueryParams} from '../../../../../common/QueryParams';
import {SeededRandomService} from '../../../model/seededRandom.service';
import { compare } from 'natural-orderby';
@Component({
selector: 'app-gallery-grid',
@ -230,26 +231,10 @@ export class GalleryGridComponent implements OnChanges, OnInit, AfterViewInit, O
private sortPhotos() {
switch (this.galleryService.sorting.value) {
case SortingMethods.ascName:
this.media.sort((a: PhotoDTO, b: PhotoDTO) => {
if (a.name.toLowerCase() < b.name.toLowerCase()) {
return -1;
}
if (a.name.toLowerCase() > b.name.toLowerCase()) {
return 1;
}
return 0;
});
this.media.sort((a: PhotoDTO, b: PhotoDTO) => compare()(a.name, b.name));
break;
case SortingMethods.descName:
this.media.sort((a: PhotoDTO, b: PhotoDTO) => {
if (a.name.toLowerCase() < b.name.toLowerCase()) {
return 1;
}
if (a.name.toLowerCase() > b.name.toLowerCase()) {
return -1;
}
return 0;
});
this.media.sort((a: PhotoDTO, b: PhotoDTO) => compare({order: 'desc' })(a.name, b.name));
break;
case SortingMethods.ascDate:
this.media.sort((a: PhotoDTO, b: PhotoDTO) => {