This commit is contained in:
Arkadiusz Fal 2022-03-28 21:26:38 +02:00
parent 15e62468bb
commit 4f1b52826d
2 changed files with 6 additions and 3 deletions

View File

@ -92,15 +92,18 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
}
configureTransformer(pathPattern("search"), requestMethods: [.get]) { (content: Entity<JSON>) -> SearchPage in
let results = content.json.arrayValue.compactMap { json -> ContentItem in
let results = content.json.arrayValue.compactMap { json -> ContentItem? in
let type = json.dictionaryValue["type"]?.stringValue
if type == "channel" {
return ContentItem(channel: self.extractChannel(from: json))
} else if type == "playlist" {
return ContentItem(playlist: self.extractChannelPlaylist(from: json))
} else if type == "video" {
return ContentItem(video: self.extractVideo(from: json))
}
return ContentItem(video: self.extractVideo(from: json))
return nil
}
return SearchPage(results: results, last: results.isEmpty)

View File

@ -115,7 +115,7 @@ final class SearchModel: ObservableObject {
resource?.removeObservers(ownedBy: store)
resource = accounts.api.search(query, page: page?.nextPage)
resource = accounts.api.search(query, page: pageToLoad.nextPage)
resource.addObserver(store)
resource