Clarified result count

This commit is contained in:
Geomitron
2020-03-12 10:54:33 -04:00
parent a64ec34589
commit f1d58aafa8
3 changed files with 15 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
<div class="ui bottom borderless menu"> <div class="ui bottom borderless menu">
<div *ngIf="resultCount > 0" class="item">{{resultCount}} Result{{resultCount == 1 ? '' : 's'}}</div> <div *ngIf="resultCount > 0" class="item">{{resultCount}}{{allResultsVisible ? '' : '+'}} Result{{resultCount == 1 ? '' : 's'}}</div>
<div class="item"> <div class="item">
<button *ngIf="selectedResults.length > 0" (click)="downloadSelected()" class="ui positive button">Download Selected</button> <button *ngIf="selectedResults.length > 0" (click)="downloadSelected()" class="ui positive button">Download Selected</button>
</div> </div>

View File

@@ -25,7 +25,7 @@ export class StatusBarComponent {
constructor( constructor(
private electronService: ElectronService, private electronService: ElectronService,
private downloadService: DownloadService, private downloadService: DownloadService,
searchService: SearchService, private searchService: SearchService,
ref: ChangeDetectorRef ref: ChangeDetectorRef
) { ) {
downloadService.onDownloadUpdated(() => { downloadService.onDownloadUpdated(() => {
@@ -43,6 +43,10 @@ export class StatusBarComponent {
}) })
} }
get allResultsVisible() {
return this.searchService.allResultsVisible
}
showDownloads() { showDownloads() {
$('#downloadsModal').modal('show') $('#downloadsModal').modal('show')
} }

View File

@@ -10,9 +10,9 @@ export class SearchService {
private resultsChangedEmitter = new EventEmitter<SongResult[]>() // For when any results change private resultsChangedEmitter = new EventEmitter<SongResult[]>() // For when any results change
private newResultsEmitter = new EventEmitter<SongResult[]>() // For when a new search happens private newResultsEmitter = new EventEmitter<SongResult[]>() // For when a new search happens
private results: SongResult[] = [] private results: SongResult[] = []
private awaitingResults = false private awaitingResults = false // TODO: add loading icon below table when this is true
private currentQuery: SongSearch private currentQuery: SongSearch
private allResultsVisible = true private _allResultsVisible = true
constructor(private electronService: ElectronService) { } constructor(private electronService: ElectronService) { }
@@ -39,7 +39,7 @@ export class SearchService {
} }
async updateScroll() { async updateScroll() {
if (!this.awaitingResults && !this.allResultsVisible) { if (!this.awaitingResults && !this._allResultsVisible) {
this.awaitingResults = true this.awaitingResults = true
this.currentQuery.offset += 20 this.currentQuery.offset += 20
this.results.push(...this.trimLastChart(await this.electronService.invoke('song-search', this.currentQuery))) this.results.push(...this.trimLastChart(await this.electronService.invoke('song-search', this.currentQuery)))
@@ -52,11 +52,15 @@ export class SearchService {
trimLastChart(results: SongResult[]) { trimLastChart(results: SongResult[]) {
if (results.length > 20) { if (results.length > 20) {
results.splice(20, 1) results.splice(20, 1)
this.allResultsVisible = false this._allResultsVisible = false
} else { } else {
this.allResultsVisible = true this._allResultsVisible = true
} }
return results return results
} }
get allResultsVisible() {
return this._allResultsVisible
}
} }