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:
commit
0f40bb67e5
@ -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) => {
|
||||
|
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user