Advanced Search TS

This commit is contained in:
Geomitron
2021-04-02 22:24:06 -05:00
parent 265ae29f4b
commit e7a265529e
6 changed files with 146 additions and 67 deletions

View File

@@ -1,6 +1,6 @@
import { Injectable, EventEmitter } from '@angular/core'
import { ElectronService } from './electron.service'
import { SearchType, SongResult, SongSearch } from 'src/electron/shared/interfaces/search.interface'
import { SongResult, SongSearch } from 'src/electron/shared/interfaces/search.interface'
import { VersionResult } from 'src/electron/shared/interfaces/songDetails.interface'
@Injectable({
@@ -18,10 +18,10 @@ export class SearchService {
constructor(private electronService: ElectronService) { }
async newSearch(query: string) {
async newSearch(query: SongSearch) {
if (this.awaitingResults) { return }
this.awaitingResults = true
this.currentQuery = { query, type: SearchType.Any, offset: 0, length: 50 + 1 } // TODO: make length a setting
this.currentQuery = query
try {
this.results = this.trimLastChart(await this.electronService.invoke('song-search', this.currentQuery))
this.errorStateEmitter.emit(false)