SkyNovels[ES] feat: add filters, pagination and resolve fix search#2136
Conversation
| ): Promise<Plugin.NovelItem[]> { | ||
| searchTerm = searchTerm.toLowerCase(); | ||
| const url = this.apiSite + 'novels?&q'; | ||
| const url = `${this.apiSite}novels?page=${pageNo}&q=${searchTerm}`; |
There was a problem hiding this comment.
encodeURIcomponent for searchTerm
There was a problem hiding this comment.
God, I never learn. Okay.
| const url = this.apiSite + 'novels?&q'; | ||
|
|
||
| const result = await fetchApi(url); | ||
| filters: Filters | undefined = { |
There was a problem hiding this comment.
can remove typing here, since you already wrote satisfies Filters at the end
There was a problem hiding this comment.
I understand, thanks for the advice
| pageNo: number, | ||
| { filters }: Plugin.PopularNovelsOptions<typeof this.filters>, | ||
| ): Promise<Plugin.NovelItem[]> { | ||
| const genres = (filters?.genres?.value as string[]) || []; |
There was a problem hiding this comment.
the only thing probably undefined here is filters.genres.value, but this is also fine
| ): Promise<Plugin.NovelItem[]> { | ||
| const genres = (filters?.genres?.value as string[]) || []; | ||
| const order = genres.length > 0 ? 'updated' : 'rating'; | ||
| const url = `${this.apiSite}novels?page=${pageNo}&order=${order}&genres=${genres.join(',')}`; |
There was a problem hiding this comment.
will &genres= be added even if it's empty?
There was a problem hiding this comment.
Yes, because having it doesn't cause problems even if it's empty. Do you think I should avoid adding it if it's not necessary?
There was a problem hiding this comment.
should try to replicate website, if website is like this, it ok
There was a problem hiding this comment.
Understood, it's not like that on the website, I'll adjust it.
* SkyNovels[ES] feat: add filters, pagination and resolve fix search * SkyNovels[ES] Fix: minors correction * SkyNovels[ES] Fix: minors correction --------- Co-authored-by: JhoendryB <jhoendryblanco@htmail.com>
Feat:
Checklist