From 4f1b52826d79a95cfd0efcfd54ce0d859a72f7d3 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Mon, 28 Mar 2022 21:26:38 +0200 Subject: [PATCH] Fix #109 --- Model/Applications/InvidiousAPI.swift | 7 +++++-- Model/Search/SearchModel.swift | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Model/Applications/InvidiousAPI.swift b/Model/Applications/InvidiousAPI.swift index 101157a1..e224bd66 100644 --- a/Model/Applications/InvidiousAPI.swift +++ b/Model/Applications/InvidiousAPI.swift @@ -92,15 +92,18 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI { } configureTransformer(pathPattern("search"), requestMethods: [.get]) { (content: Entity) -> 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) diff --git a/Model/Search/SearchModel.swift b/Model/Search/SearchModel.swift index 3758a0c9..a426f017 100644 --- a/Model/Search/SearchModel.swift +++ b/Model/Search/SearchModel.swift @@ -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