From 5b80eb742c5ba7c21ed7e8402e6f6b3c929283ff Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 14 Jan 2021 00:50:48 -0500 Subject: [PATCH] add support for restoring webfeeds --- .../FeedWranglerAccountDelegate.swift | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Account/Sources/Account/FeedWrangler/FeedWranglerAccountDelegate.swift b/Account/Sources/Account/FeedWrangler/FeedWranglerAccountDelegate.swift index 8ab0614db..37c6aa212 100644 --- a/Account/Sources/Account/FeedWrangler/FeedWranglerAccountDelegate.swift +++ b/Account/Sources/Account/FeedWrangler/FeedWranglerAccountDelegate.swift @@ -428,8 +428,26 @@ final class FeedWranglerAccountDelegate: AccountDelegate { fatalError() } - func restoreWebFeed(for account: Account, feed: WebFeed, container: Container, completion: @escaping (Result) -> Void) { - fatalError() + func restoreWebFeed(for account: Account, feed: WebFeed, container: Container, completion: @escaping (Result) -> Void) { + if let existingFeed = account.existingWebFeed(withURL: feed.url) { + account.addWebFeed(existingFeed, to: container) { result in + switch result { + case .success: + completion(.success(())) + case .failure(let error): + completion(.failure(error)) + } + } + } else { + createWebFeed(for: account, url: feed.url, name: feed.editedName, container: container) { result in + switch result { + case .success: + completion(.success(())) + case .failure(let error): + completion(.failure(error)) + } + } + } } func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result) -> Void) {