mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-18 12:31:01 +01:00
Make BatchUpdate MainActor.
This commit is contained in:
parent
177d660cff
commit
e867487031
@ -675,6 +675,8 @@ private extension FeedbinAccountDelegate {
|
||||
self.refreshProgress.completeTask()
|
||||
self.forceExpireFolderFeedRelationship(account, tags)
|
||||
self.caller.retrieveTaggings { result in
|
||||
|
||||
MainActor.assumeIsolated {
|
||||
switch result {
|
||||
case .success(let taggings):
|
||||
|
||||
@ -690,7 +692,7 @@ private extension FeedbinAccountDelegate {
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
case .failure(let error):
|
||||
|
@ -81,6 +81,8 @@ final class LocalAccountDelegate: AccountDelegate {
|
||||
}
|
||||
|
||||
func importOPML(for account:Account, opmlFile: URL, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
|
||||
Task { @MainActor in
|
||||
var fileData: Data?
|
||||
|
||||
do {
|
||||
@ -119,7 +121,7 @@ final class LocalAccountDelegate: AccountDelegate {
|
||||
}
|
||||
|
||||
completion(.success(()))
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func createFeed(for account: Account, url urlString: String, name: String?, container: Container, validateFeed: Bool, completion: @escaping (Result<Feed, Error>) -> Void) {
|
||||
@ -233,6 +235,7 @@ private extension LocalAccountDelegate {
|
||||
|
||||
func createRSSFeed(for account: Account, url: URL, editedName: String?, container: Container, completion: @escaping (Result<Feed, Error>) -> Void) {
|
||||
|
||||
Task { @MainActor in
|
||||
// We need to use a batch update here because we need to assign add the feed to the
|
||||
// container before the name has been downloaded. This will put it in the sidebar
|
||||
// with an Untitled name if we don't delay it being added to the sidebar.
|
||||
@ -240,6 +243,7 @@ private extension LocalAccountDelegate {
|
||||
refreshProgress.addToNumberOfTasksAndRemaining(1)
|
||||
FeedFinder.find(url: url) { result in
|
||||
|
||||
MainActor.assumeIsolated {
|
||||
switch result {
|
||||
case .success(let feedSpecifiers):
|
||||
guard let bestFeedSpecifier = FeedSpecifier.bestFeed(in: feedSpecifiers),
|
||||
@ -266,8 +270,10 @@ private extension LocalAccountDelegate {
|
||||
container.addFeed(feed)
|
||||
|
||||
account.update(feed, with: parsedFeed, {_ in
|
||||
MainActor.assumeIsolated {
|
||||
BatchUpdate.shared.end()
|
||||
completion(.success(feed))
|
||||
}
|
||||
})
|
||||
} else {
|
||||
BatchUpdate.shared.end()
|
||||
@ -281,9 +287,8 @@ private extension LocalAccountDelegate {
|
||||
self.refreshProgress.completeTask()
|
||||
completion(.failure(AccountError.createErrorNotFound))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ extension NewsBlurAccountDelegate {
|
||||
os_log(.debug, log: log, "Refreshing feeds...")
|
||||
|
||||
caller.retrieveFeeds { result in
|
||||
|
||||
MainActor.assumeIsolated {
|
||||
switch result {
|
||||
case .success((let feeds, let folders)):
|
||||
BatchUpdate.shared.perform {
|
||||
@ -34,6 +36,7 @@ extension NewsBlurAccountDelegate {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func syncFolders(_ account: Account, _ folders: [NewsBlurFolder]?) {
|
||||
guard let folders = folders else { return }
|
||||
|
@ -689,11 +689,13 @@ private extension ReaderAPIAccountDelegate {
|
||||
self.refreshProgress.completeTask()
|
||||
switch result {
|
||||
case .success(let subscriptions):
|
||||
MainActor.assumeIsolated {
|
||||
BatchUpdate.shared.perform {
|
||||
self.syncFolders(account, tags)
|
||||
self.syncFeeds(account, subscriptions)
|
||||
self.syncFeedFolderRelationship(account, subscriptions)
|
||||
}
|
||||
}
|
||||
completion(.success(()))
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
|
@ -19,10 +19,10 @@ public extension Notification.Name {
|
||||
}
|
||||
|
||||
/// A class for batch updating.
|
||||
public final class BatchUpdate {
|
||||
@MainActor public final class BatchUpdate {
|
||||
|
||||
/// The shared batch update object.
|
||||
public static let shared = BatchUpdate()
|
||||
@MainActor public static let shared = BatchUpdate()
|
||||
|
||||
private var count = 0
|
||||
|
||||
|
@ -67,7 +67,7 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
return self.classDescription as! NSScriptClassDescription
|
||||
}
|
||||
|
||||
func deleteElement(_ element:ScriptingObject) {
|
||||
@MainActor func deleteElement(_ element:ScriptingObject) {
|
||||
if let scriptableFolder = element as? ScriptableFolder {
|
||||
BatchUpdate.shared.perform {
|
||||
account.removeFolder(scriptableFolder.folder) { result in
|
||||
|
@ -50,7 +50,7 @@ class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContai
|
||||
return self.classDescription as! NSScriptClassDescription
|
||||
}
|
||||
|
||||
func deleteElement(_ element:ScriptingObject) {
|
||||
@MainActor func deleteElement(_ element:ScriptingObject) {
|
||||
if let scriptableFeed = element as? ScriptableFeed {
|
||||
BatchUpdate.shared.perform {
|
||||
folder.account?.removeFeed(scriptableFeed.feed, from: folder) { result in }
|
||||
|
@ -15,7 +15,7 @@ extension UIView: MarkAsReadAlertControllerSourceType {}
|
||||
extension UIBarButtonItem: MarkAsReadAlertControllerSourceType {}
|
||||
|
||||
|
||||
struct MarkAsReadAlertController {
|
||||
@MainActor struct MarkAsReadAlertController {
|
||||
|
||||
static func confirm<T>(_ controller: UIViewController?,
|
||||
coordinator: SceneCoordinator?,
|
||||
|
Loading…
Reference in New Issue
Block a user