Remove feeds in folder
This commit is contained in:
parent
e6659eea10
commit
ec855364bc
|
@ -11,7 +11,7 @@ import Foundation
|
|||
enum NewsBlurFolderChange {
|
||||
case add(String)
|
||||
case rename(String, String)
|
||||
case delete(String)
|
||||
case delete(String, [String])
|
||||
}
|
||||
|
||||
extension NewsBlurFolderChange: NewsBlurDataConvertible {
|
||||
|
@ -27,11 +27,15 @@ extension NewsBlurFolderChange: NewsBlurDataConvertible {
|
|||
URLQueryItem(name: "new_folder_name", value: to),
|
||||
URLQueryItem(name: "in_folder", value: ""), // root folder
|
||||
]
|
||||
case .delete(let name):
|
||||
return [
|
||||
case .delete(let name, let feedIDs):
|
||||
var queryItems = [
|
||||
URLQueryItem(name: "folder_to_delete", value: name),
|
||||
URLQueryItem(name: "in_folder", value: ""), // root folder
|
||||
]
|
||||
queryItems.append(contentsOf: feedIDs.map { id in
|
||||
URLQueryItem(name: "feed_id", value: id)
|
||||
})
|
||||
return queryItems
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
@ -205,8 +205,8 @@ final class NewsBlurAPICaller: NSObject {
|
|||
sendUpdates(endpoint: "reader/rename_folder", payload: NewsBlurFolderChange.rename(folder, name), completion: completion)
|
||||
}
|
||||
|
||||
func removeFolder(named name: String, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
sendUpdates(endpoint: "reader/delete_folder", payload: NewsBlurFolderChange.delete(name), completion: completion)
|
||||
func removeFolder(named name: String, feedIDs: [String], completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
sendUpdates(endpoint: "reader/delete_folder", payload: NewsBlurFolderChange.delete(name, feedIDs), completion: completion)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -358,9 +358,18 @@ final class NewsBlurAccountDelegate: AccountDelegate {
|
|||
return
|
||||
}
|
||||
|
||||
var feedIDs: [String] = []
|
||||
for feed in folder.topLevelWebFeeds {
|
||||
if feed.folderRelationship?.count ?? 0 > 1 {
|
||||
clearFolderRelationship(for: feed, withFolderName: folderToRemove)
|
||||
} else if let subscriptionID = feed.subscriptionID {
|
||||
feedIDs.append(subscriptionID)
|
||||
}
|
||||
}
|
||||
|
||||
refreshProgress.addToNumberOfTasksAndRemaining(1)
|
||||
|
||||
caller.removeFolder(named: folderToRemove) { result in
|
||||
caller.removeFolder(named: folderToRemove, feedIDs: feedIDs) { result in
|
||||
self.refreshProgress.completeTask()
|
||||
|
||||
switch result {
|
||||
|
|
Loading…
Reference in New Issue