mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Fix #109
This commit is contained in:
parent
15e62468bb
commit
4f1b52826d
@ -92,17 +92,20 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configureTransformer(pathPattern("search"), requestMethods: [.get]) { (content: Entity<JSON>) -> SearchPage in
|
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
|
let type = json.dictionaryValue["type"]?.stringValue
|
||||||
|
|
||||||
if type == "channel" {
|
if type == "channel" {
|
||||||
return ContentItem(channel: self.extractChannel(from: json))
|
return ContentItem(channel: self.extractChannel(from: json))
|
||||||
} else if type == "playlist" {
|
} else if type == "playlist" {
|
||||||
return ContentItem(playlist: self.extractChannelPlaylist(from: json))
|
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)
|
return SearchPage(results: results, last: results.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ final class SearchModel: ObservableObject {
|
|||||||
|
|
||||||
resource?.removeObservers(ownedBy: store)
|
resource?.removeObservers(ownedBy: store)
|
||||||
|
|
||||||
resource = accounts.api.search(query, page: page?.nextPage)
|
resource = accounts.api.search(query, page: pageToLoad.nextPage)
|
||||||
resource.addObserver(store)
|
resource.addObserver(store)
|
||||||
|
|
||||||
resource
|
resource
|
||||||
|
Loading…
Reference in New Issue
Block a user