mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-27 09:21:21 +01:00
Move feed
This commit is contained in:
parent
fe7cbe3bd3
commit
1e66860f34
@ -12,6 +12,7 @@ enum NewsBlurFeedChange {
|
|||||||
case add(String, String?)
|
case add(String, String?)
|
||||||
case rename(String, String)
|
case rename(String, String)
|
||||||
case delete(String, String?)
|
case delete(String, String?)
|
||||||
|
case move(String, String?, String?)
|
||||||
}
|
}
|
||||||
|
|
||||||
extension NewsBlurFeedChange: NewsBlurDataConvertible {
|
extension NewsBlurFeedChange: NewsBlurDataConvertible {
|
||||||
@ -34,6 +35,12 @@ extension NewsBlurFeedChange: NewsBlurDataConvertible {
|
|||||||
URLQueryItem(name: "feed_id", value: feedID),
|
URLQueryItem(name: "feed_id", value: feedID),
|
||||||
folder != nil ? URLQueryItem(name: "in_folder", value: folder) : nil,
|
folder != nil ? URLQueryItem(name: "in_folder", value: folder) : nil,
|
||||||
].compactMap { $0 }
|
].compactMap { $0 }
|
||||||
|
case .move(let feedID, let from, let to):
|
||||||
|
return [
|
||||||
|
URLQueryItem(name: "feed_id", value: feedID),
|
||||||
|
URLQueryItem(name: "in_folder", value: from ?? ""),
|
||||||
|
URLQueryItem(name: "to_folder", value: to ?? ""),
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -262,4 +262,18 @@ final class NewsBlurAPICaller: NSObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moveFeed(feedID: String, from: String?, to: String?, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||||
|
sendUpdates(
|
||||||
|
endpoint: "reader/move_feed_to_folder",
|
||||||
|
payload: NewsBlurFeedChange.move(feedID, from, to)
|
||||||
|
) { result in
|
||||||
|
switch result {
|
||||||
|
case .success:
|
||||||
|
completion(.success(()))
|
||||||
|
case .failure(let error):
|
||||||
|
completion(.failure(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,6 @@ final class NewsBlurAccountDelegate: AccountDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func renameWebFeed(for account: Account, with feed: WebFeed, to name: String, completion: @escaping (Result<Void, Error>) -> ()) {
|
func renameWebFeed(for account: Account, with feed: WebFeed, to name: String, completion: @escaping (Result<Void, Error>) -> ()) {
|
||||||
// This error should never happen
|
|
||||||
guard let feedID = feed.externalID else {
|
guard let feedID = feed.externalID else {
|
||||||
completion(.failure(NewsBlurError.invalidParameter))
|
completion(.failure(NewsBlurError.invalidParameter))
|
||||||
return
|
return
|
||||||
@ -480,7 +479,30 @@ final class NewsBlurAccountDelegate: AccountDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func moveWebFeed(for account: Account, with feed: WebFeed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> ()) {
|
func moveWebFeed(for account: Account, with feed: WebFeed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> ()) {
|
||||||
completion(.success(()))
|
guard let feedID = feed.externalID else {
|
||||||
|
completion(.failure(NewsBlurError.invalidParameter))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshProgress.addToNumberOfTasksAndRemaining(1)
|
||||||
|
|
||||||
|
caller.moveFeed(
|
||||||
|
feedID: feedID,
|
||||||
|
from: (from as? Folder)?.name,
|
||||||
|
to: (to as? Folder)?.name
|
||||||
|
) { result in
|
||||||
|
self.refreshProgress.completeTask()
|
||||||
|
|
||||||
|
switch result {
|
||||||
|
case .success:
|
||||||
|
from.removeWebFeed(feed)
|
||||||
|
to.addWebFeed(feed)
|
||||||
|
|
||||||
|
completion(.success(()))
|
||||||
|
case .failure(let error):
|
||||||
|
completion(.failure(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func restoreWebFeed(for account: Account, feed: WebFeed, container: Container, completion: @escaping (Result<Void, Error>) -> ()) {
|
func restoreWebFeed(for account: Account, feed: WebFeed, container: Container, completion: @escaping (Result<Void, Error>) -> ()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user