Skip to content

Commit

Permalink
feat: allow sorting by date added (#1631)
Browse files Browse the repository at this point in the history
  • Loading branch information
phanan committed Dec 15, 2022
1 parent cb84f14 commit e8e2c2d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
11 changes: 10 additions & 1 deletion app/Repositories/SongRepository.php
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions resources/assets/js/components/song/SongListSorter.vue
Expand Up @@ -53,6 +53,10 @@ const menuItems: { label: string, field: SongListSortField }[] = [
{
label: 'Time',
field: 'length'
},
{
label: 'Date Added',
field: 'created_at'
}
]
Expand Down
6 changes: 5 additions & 1 deletion resources/assets/js/types.d.ts
Expand Up @@ -21,9 +21,13 @@ interface Plyr {
media: HTMLMediaElement

restart (): void

play (): void

pause (): void

seek (position: number): void

setVolume (volume: number): void
}

Expand Down Expand Up @@ -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'

Expand Down

0 comments on commit e8e2c2d

Please sign in to comment.