mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 23:58:36 +01:00
Convert moveFeed to async await.
This commit is contained in:
parent
3e37388604
commit
323d0404f2
@ -629,8 +629,9 @@ public enum FetchType {
|
||||
try await delegate.removeFeed(for: self, with: feed, from: container)
|
||||
}
|
||||
|
||||
public func moveFeed(_ feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
delegate.moveFeed(for: self, with: feed, from: from, to: to, completion: completion)
|
||||
public func moveFeed(_ feed: Feed, from: Container, to: Container) async throws {
|
||||
|
||||
try await delegate.moveFeed(for: self, with: feed, from: from, to: to)
|
||||
}
|
||||
|
||||
public func renameFeed(_ feed: Feed, to name: String) async throws {
|
||||
|
@ -40,7 +40,7 @@ import Secrets
|
||||
func renameFeed(for account: Account, with feed: Feed, to name: String) async throws
|
||||
func addFeed(for account: Account, with: Feed, to container: Container) async throws
|
||||
func removeFeed(for account: Account, with feed: Feed, from container: Container) async throws
|
||||
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void)
|
||||
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws
|
||||
|
||||
func restoreFeed(for account: Account, feed: Feed, container: Container) async throws
|
||||
func restoreFolder(for account: Account, folder: Folder) async throws
|
||||
|
@ -320,7 +320,21 @@ enum CloudKitAccountDelegateError: LocalizedError {
|
||||
}
|
||||
}
|
||||
|
||||
func moveFeed(for account: Account, with feed: Feed, from fromContainer: Container, to toContainer: Container, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws {
|
||||
|
||||
try await withCheckedThrowingContinuation { continuation in
|
||||
self.moveFeed(for: account, with: feed, from: from, to: to) { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume()
|
||||
case .failure(let error):
|
||||
continuation.resume(throwing: error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func moveFeed(for account: Account, with feed: Feed, from fromContainer: Container, to toContainer: Container, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
refreshProgress.addToNumberOfTasksAndRemaining(1)
|
||||
accountZone.moveFeed(feed, from: fromContainer, to: toContainer) { result in
|
||||
self.refreshProgress.completeTask()
|
||||
|
@ -564,7 +564,21 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws {
|
||||
|
||||
try await withCheckedThrowingContinuation { continuation in
|
||||
self.moveFeed(for: account, with: feed, from: from, to: to) { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume()
|
||||
case .failure(let error):
|
||||
continuation.resume(throwing: error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
if from is Account {
|
||||
addFeed(for: account, with: feed, to: to, completion: completion)
|
||||
} else {
|
||||
|
@ -575,6 +575,20 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
folder.removeFeed(feed)
|
||||
}
|
||||
|
||||
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws {
|
||||
|
||||
try await withCheckedThrowingContinuation { continuation in
|
||||
self.moveFeed(for: account, with: feed, from: from, to: to) { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume()
|
||||
case .failure(let error):
|
||||
continuation.resume(throwing: error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
guard let from = from as? Folder, let to = to as? Folder else {
|
||||
return DispatchQueue.main.async {
|
||||
|
@ -101,10 +101,10 @@ final class LocalAccountDelegate: AccountDelegate {
|
||||
container.removeFeed(feed)
|
||||
}
|
||||
|
||||
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws {
|
||||
|
||||
from.removeFeed(feed)
|
||||
to.addFeed(feed)
|
||||
completion(.success(()))
|
||||
}
|
||||
|
||||
func addFeed(for account: Account, with feed: Feed, to container: any Container) async throws {
|
||||
|
@ -629,7 +629,21 @@ final class NewsBlurAccountDelegate: AccountDelegate {
|
||||
deleteFeed(for: account, with: feed, from: container, completion: completion)
|
||||
}
|
||||
|
||||
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> ()) {
|
||||
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws {
|
||||
|
||||
try await withCheckedThrowingContinuation { continuation in
|
||||
self.moveFeed(for: account, with: feed, from: from, to: to) { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume()
|
||||
case .failure(let error):
|
||||
continuation.resume(throwing: error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> ()) {
|
||||
guard let feedID = feed.externalID else {
|
||||
completion(.failure(NewsBlurError.invalidParameter))
|
||||
return
|
||||
|
@ -605,7 +605,21 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws {
|
||||
|
||||
try await withCheckedThrowingContinuation { continuation in
|
||||
self.moveFeed(for: account, with: feed, from: from, to: to) { result in
|
||||
switch result {
|
||||
case .success:
|
||||
continuation.resume()
|
||||
case .failure(let error):
|
||||
continuation.resume(throwing: error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
if from is Account {
|
||||
addFeed(for: account, with: feed, to: to, completion: completion)
|
||||
} else {
|
||||
|
@ -331,12 +331,14 @@ private extension SidebarOutlineDataSource {
|
||||
}
|
||||
|
||||
BatchUpdate.shared.start()
|
||||
source.account?.moveFeed(feed, from: source, to: destination) { result in
|
||||
|
||||
Task { @MainActor in
|
||||
|
||||
do {
|
||||
try await source.account?.moveFeed(feed, from: source, to: destination)
|
||||
BatchUpdate.shared.end()
|
||||
} catch {
|
||||
BatchUpdate.shared.end()
|
||||
switch result {
|
||||
case .success:
|
||||
break
|
||||
case .failure(let error):
|
||||
NSApplication.shared.presentError(error)
|
||||
}
|
||||
}
|
||||
|
@ -104,12 +104,14 @@ extension SidebarViewController: UITableViewDropDelegate {
|
||||
guard sourceContainer !== destinationContainer else { return }
|
||||
|
||||
BatchUpdate.shared.start()
|
||||
sourceContainer.account?.moveFeed(feed, from: sourceContainer, to: destinationContainer) { result in
|
||||
|
||||
Task { @MainActor in
|
||||
|
||||
do {
|
||||
try await sourceContainer.account?.moveFeed(feed, from: sourceContainer, to: destinationContainer)
|
||||
BatchUpdate.shared.end()
|
||||
} catch {
|
||||
BatchUpdate.shared.end()
|
||||
switch result {
|
||||
case .success:
|
||||
break
|
||||
case .failure(let error):
|
||||
self.presentError(error)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user