Added scroll to show more results

This commit is contained in:
Geomitron
2020-03-11 23:20:41 -04:00
parent 18afa01e5c
commit 0a2acf9b31
4 changed files with 42 additions and 13 deletions

View File

@@ -23,7 +23,7 @@ class SearchHandler implements IPCInvokeHandler<'song-search'> {
*/
private getSearchQuery(search: SongSearch) {
switch (search.type) {
case SearchType.Any: return this.getGeneralSearchQuery(search.query)
case SearchType.Any: return this.getGeneralSearchQuery(search)
default: return '<<<ERROR>>>' // TODO: add more search types
}
}
@@ -31,12 +31,12 @@ class SearchHandler implements IPCInvokeHandler<'song-search'> {
/**
* @returns a database query that returns the top 20 songs that match `search`.
*/
private getGeneralSearchQuery(searchString: string) {
private getGeneralSearchQuery(search: SongSearch) {
return `
SELECT id, name, artist, album, genre, year
FROM Song
WHERE MATCH (name,artist,album,genre) AGAINST (${escape(searchString)}) > 0
LIMIT ${20} OFFSET ${0};
WHERE MATCH (name,artist,album,genre) AGAINST (${escape(search.query)}) > 0
LIMIT ${search.length} OFFSET ${search.offset};
` // TODO: add parameters for the limit and offset
}
}

View File

@@ -4,6 +4,8 @@
export interface SongSearch {
query: string
type: SearchType
offset: number
length: number
}
/**