Prevented empty results from being sorted

This commit is contained in:
Geomitron
2021-04-10 20:45:58 -05:00
parent 2e33f12ba6
commit 3afbf1c49f

View File

@@ -19,7 +19,7 @@ export class ResultTableComponent implements OnInit {
@ViewChild(CheckboxDirective, { static: true }) checkboxColumn: CheckboxDirective
@ViewChildren('tableRow') tableRows: QueryList<ResultTableRowComponent>
results: SongResult[]
results: SongResult[] = []
activeRowID: number = null
sortDirection: 'ascending' | 'descending' = 'descending'
sortColumn: 'name' | 'artist' | 'album' | 'genre' | null = null
@@ -52,6 +52,7 @@ export class ResultTableComponent implements OnInit {
}
onColClicked(column: 'name' | 'artist' | 'album' | 'genre') {
if (this.results.length == 0) { return }
if (this.sortColumn != column) {
this.sortColumn = column
this.sortDirection = 'descending'