Skip to content

Commit

Permalink
Fix page range filter logics
Browse files Browse the repository at this point in the history
  • Loading branch information
chihchy committed Sep 8, 2023
1 parent 2d9588e commit ce9bdc9
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions EhPanda/App/Tools/Utilities/URLUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,29 @@ private extension URL {
queryItems1[.fSrdd] = String(filter.minRating)
}

if filter.pageRangeActivated, let minPages = Int(filter.pageLowerBound),
let maxPages = Int(filter.pageUpperBound),
minPages > 0 && maxPages > 0 && minPages <= maxPages
{
if filter.pageRangeActivated {
queryItems2[.fSp] = .filterOn
queryItems1[.fSpf] = String(minPages)
queryItems1[.fSpt] = String(maxPages)

switch (Int(filter.pageLowerBound), Int(filter.pageUpperBound)) {
case let (.some(minPages), .some(maxPages)):
if minPages > 0 && maxPages > 0 && minPages <= maxPages {
queryItems1[.fSpf] = String(minPages)
queryItems1[.fSpt] = String(maxPages)
}

case let (.some(minPages), _):
if minPages > 0 {
queryItems1[.fSpf] = String(minPages)
}

case let (_, .some(maxPages)):
if maxPages > 0 {
queryItems1[.fSpt] = String(maxPages)
}

case (.none, .none):
break
}
}

if filter.disableLanguage { queryItems2[.fSfl] = .filterOn }
Expand Down

0 comments on commit ce9bdc9

Please sign in to comment.