feat: allow sorting by date added (#1631)

This commit is contained in:
Phan An 2022-12-15 22:59:19 +07:00 committed by GitHub
parent cb84f14f34
commit e8e2c2db75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View file

@ -22,12 +22,21 @@ class SongRepository extends Repository
'title' => 'songs.title',
'track' => 'songs.track',
'length' => 'songs.length',
'created_at' => 'songs.created_at',
'disc' => 'songs.disc',
'artist_name' => 'artists.name',
'album_name' => 'albums.name',
];
private const VALID_SORT_COLUMNS = ['songs.title', 'songs.track', 'songs.length', 'artists.name', 'albums.name'];
private const VALID_SORT_COLUMNS = [
'songs.title',
'songs.track',
'songs.length',
'songs.created_at',
'artists.name',
'albums.name',
];
private const DEFAULT_QUEUE_LIMIT = 500;
public function getOneByPath(string $path): ?Song

View file

@ -53,6 +53,10 @@ const menuItems: { label: string, field: SongListSortField }[] = [
{
label: 'Time',
field: 'length'
},
{
label: 'Date Added',
field: 'created_at'
}
]

View file

@ -21,9 +21,13 @@ interface Plyr {
media: HTMLMediaElement
restart (): void
play (): void
pause (): void
seek (position: number): void
setVolume (volume: number): void
}
@ -351,7 +355,7 @@ interface SongListConfig {
reorderable: boolean
}
type SongListSortField = keyof Pick<Song, 'track' | 'disc' | 'title' | 'album_name' | 'length' | 'artist_name'>
type SongListSortField = keyof Pick<Song, 'track' | 'disc' | 'title' | 'album_name' | 'length' | 'artist_name' | 'created_at'>
type SortOrder = 'asc' | 'desc'