Remove numerous superfluous MainActor annotations.
This commit is contained in:
parent
f872f8aa86
commit
fe49f3bbe4
@ -87,7 +87,7 @@ enum CloudKitAccountDelegateError: LocalizedError {
|
||||
op.completionBlock = { mainThreadOperaion in
|
||||
completion()
|
||||
}
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
mainThreadOperationQueue.add(op)
|
||||
}
|
||||
}
|
||||
@ -658,7 +658,7 @@ private extension CloudKitAccountDelegate {
|
||||
|
||||
func sendNewArticlesToTheCloud(_ account: Account, _ feed: Feed) {
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
|
||||
do {
|
||||
let articles = try await account.articles(for: .feed(feed))
|
||||
@ -786,12 +786,12 @@ private extension CloudKitAccountDelegate {
|
||||
|
||||
extension CloudKitAccountDelegate: CloudKitFeedInfoDelegate {
|
||||
|
||||
@MainActor func feedExternalID(article: Article) -> String? {
|
||||
func feedExternalID(article: Article) -> String? {
|
||||
|
||||
article.feed?.externalID
|
||||
}
|
||||
|
||||
@MainActor func feedURL(article: Article) -> String? {
|
||||
func feedURL(article: Article) -> String? {
|
||||
|
||||
article.feed?.url
|
||||
}
|
||||
@ -799,14 +799,14 @@ extension CloudKitAccountDelegate: CloudKitFeedInfoDelegate {
|
||||
|
||||
extension CloudKitAccountDelegate: CloudKitSendStatusOperationDelegate {
|
||||
|
||||
@MainActor func cloudKitSendStatusOperation(_ : CloudKitSendStatusOperation, articlesFor articleIDs: Set<String>) async throws -> Set<Article> {
|
||||
func cloudKitSendStatusOperation(_ : CloudKitSendStatusOperation, articlesFor articleIDs: Set<String>) async throws -> Set<Article> {
|
||||
|
||||
guard let account else { return Set<Article>() }
|
||||
|
||||
return try await account.articles(articleIDs: articleIDs)
|
||||
}
|
||||
|
||||
@MainActor func cloudKitSendStatusOperation(_ : CloudKitSendStatusOperation, userDidDeleteZone: Error) {
|
||||
func cloudKitSendStatusOperation(_ : CloudKitSendStatusOperation, userDidDeleteZone: Error) {
|
||||
|
||||
// Delete feeds and folders
|
||||
|
||||
|
@ -935,7 +935,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
|
||||
extension FeedlyAccountDelegate: FeedlyAPICallerDelegate {
|
||||
|
||||
@MainActor func reauthorizeFeedlyAPICaller(_ caller: FeedlyAPICaller) async -> Bool {
|
||||
func reauthorizeFeedlyAPICaller(_ caller: FeedlyAPICaller) async -> Bool {
|
||||
|
||||
guard let account else {
|
||||
return false
|
||||
@ -1006,7 +1006,7 @@ public enum FeedlyOAuthAccountAuthorizationOperationError: LocalizedError {
|
||||
self.oauthClient = FeedlyAPICaller.API.cloud.oauthAuthorizationClient(secretsProvider: secretsProvider)
|
||||
}
|
||||
|
||||
@MainActor public func run() {
|
||||
public func run() {
|
||||
assert(presentationAnchor != nil, "\(self) outlived presentation anchor.")
|
||||
|
||||
let request = FeedlyAPICaller.oauthAuthorizationCodeGrantRequest(secretsProvider: secretsProvider)
|
||||
@ -1057,7 +1057,7 @@ public enum FeedlyOAuthAccountAuthorizationOperationError: LocalizedError {
|
||||
|
||||
private func didEndAuthentication(url: URL?, error: Error?) {
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
guard !isCanceled else {
|
||||
didFinish()
|
||||
return
|
||||
@ -1085,7 +1085,7 @@ public enum FeedlyOAuthAccountAuthorizationOperationError: LocalizedError {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor private func saveAccount(for grant: OAuthAuthorizationGrant) {
|
||||
private func saveAccount(for grant: OAuthAuthorizationGrant) {
|
||||
guard !AccountManager.shared.duplicateServiceAccount(type: .feedly, username: grant.accessToken.username) else {
|
||||
didFinish(FeedlyOAuthAccountAuthorizationOperationError.duplicateAccount)
|
||||
return
|
||||
@ -1112,12 +1112,12 @@ public enum FeedlyOAuthAccountAuthorizationOperationError: LocalizedError {
|
||||
|
||||
// MARK: Managing Operation State
|
||||
|
||||
@MainActor private func didFinish() {
|
||||
private func didFinish() {
|
||||
assert(Thread.isMainThread)
|
||||
// operationDelegate?.operationDidComplete(self)
|
||||
}
|
||||
|
||||
@MainActor private func didFinish(_ error: Error) {
|
||||
private func didFinish(_ error: Error) {
|
||||
assert(Thread.isMainThread)
|
||||
delegate?.oauthAccountAuthorizationOperation(self, didFailWith: error)
|
||||
didFinish()
|
||||
|
@ -17,19 +17,19 @@ import Core
|
||||
private let fileURL: URL
|
||||
private let account: Account
|
||||
|
||||
@MainActor private var isDirty = false {
|
||||
private var isDirty = false {
|
||||
didSet {
|
||||
queueSaveToDiskIfNeeded()
|
||||
}
|
||||
}
|
||||
@MainActor private let saveQueue = CoalescingQueue(name: "Save Queue", interval: 0.5)
|
||||
private let saveQueue = CoalescingQueue(name: "Save Queue", interval: 0.5)
|
||||
|
||||
init(filename: String, account: Account) {
|
||||
self.fileURL = URL(fileURLWithPath: filename)
|
||||
self.account = account
|
||||
}
|
||||
|
||||
@MainActor func markAsDirty() {
|
||||
func markAsDirty() {
|
||||
isDirty = true
|
||||
}
|
||||
|
||||
@ -61,11 +61,11 @@ import Core
|
||||
|
||||
private extension FeedMetadataFile {
|
||||
|
||||
@MainActor func queueSaveToDiskIfNeeded() {
|
||||
func queueSaveToDiskIfNeeded() {
|
||||
saveQueue.add(self, #selector(saveToDiskIfNeeded))
|
||||
}
|
||||
|
||||
@MainActor @objc func saveToDiskIfNeeded() {
|
||||
@objc func saveToDiskIfNeeded() {
|
||||
if isDirty {
|
||||
isDirty = false
|
||||
save()
|
||||
|
@ -54,7 +54,7 @@ import CrashReporter
|
||||
let formData = formString.data(using: .utf8, allowLossyConversion: true)
|
||||
request.httpBody = formData
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
try? await OneShotDownloadManager.shared.download(request)
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ private extension FeedInspectorViewController {
|
||||
return
|
||||
}
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
|
||||
do {
|
||||
try await account.renameFeed(feed, to: newName)
|
||||
|
@ -113,7 +113,7 @@ private extension FolderInspectorViewController {
|
||||
return
|
||||
}
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
|
||||
do {
|
||||
try await account.renameFolder(folder, to: newName)
|
||||
|
@ -65,7 +65,7 @@ import CommonErrors
|
||||
|
||||
beginShowingProgress()
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
do {
|
||||
let feed = try await account.createFeed(url: url.absoluteString, name: title, container: container, validateFeed: true)
|
||||
NotificationCenter.default.post(name: .UserDidAddFeed, object: self, userInfo: [UserInfoKey.feed: feed])
|
||||
|
@ -48,7 +48,7 @@ private extension NNW3ImportController {
|
||||
return
|
||||
}
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
do {
|
||||
try await account.importOPML(opmlURL)
|
||||
try? FileManager.default.removeItem(at: opmlURL)
|
||||
|
@ -314,7 +314,7 @@ private extension SidebarOutlineDataSource {
|
||||
return
|
||||
}
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
do {
|
||||
try await destination.account?.addFeed(feed, to: destination)
|
||||
} catch {
|
||||
@ -332,7 +332,7 @@ private extension SidebarOutlineDataSource {
|
||||
|
||||
BatchUpdate.shared.start()
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
|
||||
do {
|
||||
try await source.account?.moveFeed(feed, from: source, to: destination)
|
||||
@ -353,7 +353,7 @@ private extension SidebarOutlineDataSource {
|
||||
|
||||
if let existingFeed = destinationAccount.existingFeed(withURL: feed.url) {
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
do {
|
||||
try await destinationAccount.addFeed(existingFeed, to: destinationContainer)
|
||||
} catch {
|
||||
@ -361,7 +361,7 @@ private extension SidebarOutlineDataSource {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
do {
|
||||
try await destinationAccount.createFeed(url: feed.url, name: feed.nameForDisplay, container: destinationContainer, validateFeed: false)
|
||||
} catch {
|
||||
@ -430,7 +430,7 @@ private extension SidebarOutlineDataSource {
|
||||
return
|
||||
}
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
|
||||
do {
|
||||
let destinationFolder = try await destinationAccount.addFolder(folder.name ?? "")
|
||||
|
@ -256,14 +256,14 @@ protocol SidebarDelegate: AnyObject {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor @IBAction func doubleClickedSidebar(_ sender: Any?) {
|
||||
@IBAction func doubleClickedSidebar(_ sender: Any?) {
|
||||
|
||||
guard outlineView.clickedRow == outlineView.selectedRow else {
|
||||
return
|
||||
}
|
||||
|
||||
if AppDefaults.shared.feedDoubleClickMarkAsRead, let feed = singleSelectedFeed {
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
await markArticlesInFeedAsRead(feed: feed)
|
||||
}
|
||||
}
|
||||
@ -271,7 +271,7 @@ protocol SidebarDelegate: AnyObject {
|
||||
openInBrowser(sender)
|
||||
}
|
||||
|
||||
@MainActor private func markArticlesInFeedAsRead(feed: Feed) async {
|
||||
private func markArticlesInFeedAsRead(feed: Feed) async {
|
||||
|
||||
guard let articles = try? await feed.fetchUnreadArticles() else {
|
||||
return
|
||||
|
@ -67,7 +67,7 @@ import Core
|
||||
return self.classDescription as! NSScriptClassDescription
|
||||
}
|
||||
|
||||
@MainActor func deleteElement(_ element:ScriptingObject) {
|
||||
func deleteElement(_ element:ScriptingObject) {
|
||||
// TODO: fix this
|
||||
// if let scriptableFolder = element as? ScriptableFolder {
|
||||
// BatchUpdate.shared.perform {
|
||||
|
@ -111,7 +111,7 @@ import Articles
|
||||
return article.status.boolStatus(forKey:.read)
|
||||
}
|
||||
set {
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
markArticles([self.article], statusKey: .read, flag: newValue)
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,7 @@ import Articles
|
||||
return article.status.boolStatus(forKey:.starred)
|
||||
}
|
||||
set {
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
markArticles([self.article], statusKey: .starred, flag: newValue)
|
||||
}
|
||||
}
|
||||
@ -146,7 +146,7 @@ import Articles
|
||||
}
|
||||
|
||||
@objc(feed)
|
||||
@MainActor var feed: ScriptableFeed? {
|
||||
var feed: ScriptableFeed? {
|
||||
guard let parentFeed = self.article.feed,
|
||||
let account = parentFeed.account
|
||||
else { return nil }
|
||||
|
@ -52,7 +52,7 @@ import Core
|
||||
return self.classDescription as! NSScriptClassDescription
|
||||
}
|
||||
|
||||
@MainActor func deleteElement(_ element:ScriptingObject) {
|
||||
func deleteElement(_ element:ScriptingObject) {
|
||||
// TODO: fix this
|
||||
// if let scriptableFeed = element as? ScriptableFeed {
|
||||
// BatchUpdate.shared.perform {
|
||||
@ -68,7 +68,7 @@ import Core
|
||||
or
|
||||
tell account X to make new folder at end with properties {name:"new folder name"}
|
||||
*/
|
||||
@MainActor class func handleCreateElement(command:NSCreateCommand) -> Any? {
|
||||
class func handleCreateElement(command:NSCreateCommand) -> Any? {
|
||||
guard command.isCreateCommand(forClass:"fold") else { return nil }
|
||||
let name = command.property(forKey:"name") as? String ?? ""
|
||||
|
||||
@ -82,7 +82,7 @@ import Core
|
||||
|
||||
command.suspendExecution()
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
do {
|
||||
let folder = try await account.addFolder(name)
|
||||
let scriptableAccount = ScriptableAccount(account)
|
||||
|
@ -113,9 +113,9 @@ import CoreSpotlight
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
@MainActor static func cleanUp(_ account: Account) {
|
||||
static func cleanUp(_ account: Account) {
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
var ids = [String]()
|
||||
|
||||
if let folders = account.folders {
|
||||
@ -133,9 +133,9 @@ import CoreSpotlight
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor static func cleanUp(_ folder: Folder) {
|
||||
static func cleanUp(_ folder: Folder) {
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
|
||||
var ids: [String] = [String]()
|
||||
ids.append(identifier(for: folder))
|
||||
@ -150,9 +150,9 @@ import CoreSpotlight
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor static func cleanUp(_ feed: Feed) {
|
||||
static func cleanUp(_ feed: Feed) {
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
let feedIdentifiers = await identifiers(for: feed)
|
||||
try? await CSSearchableIndex.default().deleteSearchableItems(withIdentifiers: feedIdentifiers)
|
||||
}
|
||||
@ -264,7 +264,7 @@ private extension ActivityManager {
|
||||
return value?.components(separatedBy: " ").filter { $0.count > 2 } ?? []
|
||||
}
|
||||
|
||||
@MainActor func updateSelectingActivityFeedSearchAttributes(with feed: Feed) {
|
||||
func updateSelectingActivityFeedSearchAttributes(with feed: Feed) {
|
||||
|
||||
let attributeSet = CSSearchableItemAttributeSet(contentType: UTType.item)
|
||||
attributeSet.title = feed.nameForDisplay
|
||||
@ -305,7 +305,7 @@ private extension ActivityManager {
|
||||
return "account_\(article.accountID)_feed_\(article.feedID)_article_\(article.articleID)"
|
||||
}
|
||||
|
||||
@MainActor static func identifiers(for feed: Feed) async -> [String] {
|
||||
static func identifiers(for feed: Feed) async -> [String] {
|
||||
|
||||
var ids = [String]()
|
||||
ids.append(identifier(for: feed))
|
||||
|
@ -47,7 +47,7 @@ import Core
|
||||
|
||||
func perform() {
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
|
||||
for itemSpecifier in itemSpecifiers {
|
||||
await itemSpecifier.delete()
|
||||
@ -65,7 +65,7 @@ import Core
|
||||
registerRedo()
|
||||
}
|
||||
|
||||
@MainActor static func canDelete(_ nodes: [Node]) -> Bool {
|
||||
static func canDelete(_ nodes: [Node]) -> Bool {
|
||||
|
||||
// Return true if all nodes are feeds and folders.
|
||||
// Any other type: return false.
|
||||
@ -190,7 +190,7 @@ import Core
|
||||
|
||||
BatchUpdate.shared.start()
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
|
||||
do {
|
||||
try await account.restoreFeed(feed, container: container)
|
||||
@ -208,7 +208,7 @@ import Core
|
||||
return
|
||||
}
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
BatchUpdate.shared.start()
|
||||
do {
|
||||
try await account.restoreFolder(folder)
|
||||
|
@ -50,12 +50,12 @@ import Core
|
||||
self.init(initialArticles: initialArticles, statusKey: .starred, flag: markingStarred, undoManager: undoManager, completion: completion)
|
||||
}
|
||||
|
||||
@MainActor func perform() {
|
||||
func perform() {
|
||||
mark(statusKey, flag)
|
||||
registerUndo()
|
||||
}
|
||||
|
||||
@MainActor func undo() {
|
||||
func undo() {
|
||||
mark(statusKey, !flag)
|
||||
registerRedo()
|
||||
}
|
||||
@ -63,7 +63,7 @@ import Core
|
||||
|
||||
private extension MarkStatusCommand {
|
||||
|
||||
@MainActor func mark(_ statusKey: ArticleStatus.Key, _ flag: Bool) {
|
||||
func mark(_ statusKey: ArticleStatus.Key, _ flag: Bool) {
|
||||
markArticles(articles, statusKey: statusKey, flag: flag, completion: completion)
|
||||
completion = nil
|
||||
}
|
||||
@ -83,7 +83,7 @@ private extension MarkStatusCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor static func filteredArticles(_ articles: [Article], _ statusKey: ArticleStatus.Key, _ flag: Bool) -> [Article] {
|
||||
static func filteredArticles(_ articles: [Article], _ statusKey: ArticleStatus.Key, _ flag: Bool) -> [Article] {
|
||||
|
||||
return articles.filter{ article in
|
||||
guard article.status.boolStatus(forKey: statusKey) != flag else { return false }
|
||||
|
@ -22,7 +22,7 @@ import Core
|
||||
appToUse() != nil
|
||||
}
|
||||
|
||||
@MainActor func sendObject(_ object: Any?, selectedText: String?) {
|
||||
func sendObject(_ object: Any?, selectedText: String?) {
|
||||
|
||||
guard canSendObject(object, selectedText: selectedText) else {
|
||||
return
|
||||
@ -34,7 +34,7 @@ import Core
|
||||
return
|
||||
}
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
guard await app.launchIfNeeded(), app.bringToFront() else {
|
||||
return
|
||||
}
|
||||
@ -44,7 +44,7 @@ import Core
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor private extension SendToMarsEditCommand {
|
||||
private extension SendToMarsEditCommand {
|
||||
|
||||
func send(_ article: Article, to app: UserApp) {
|
||||
|
||||
|
@ -39,7 +39,7 @@ import Core
|
||||
return
|
||||
}
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
guard await microBlogApp.launchIfNeeded(), microBlogApp.bringToFront() else {
|
||||
return
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import Account
|
||||
|
||||
@MainActor struct AddFeedDefaultContainer {
|
||||
|
||||
@MainActor static var defaultContainer: Container? {
|
||||
static var defaultContainer: Container? {
|
||||
|
||||
if let accountID = AppDefaults.shared.addFeedAccountID, let account = AccountManager.shared.activeAccounts.first(where: { $0.accountID == accountID }) {
|
||||
if let folderName = AppDefaults.shared.addFeedFolderName, let folder = account.existingFolder(withDisplayName: folderName) {
|
||||
|
@ -15,7 +15,7 @@ import Account
|
||||
|
||||
let defaultFeedsURL = Bundle.main.url(forResource: "DefaultFeeds", withExtension: "opml")!
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
try? await AccountManager.shared.defaultAccount.importOPML(defaultFeedsURL)
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import Core
|
||||
return containerURL!.appendingPathComponent("extension_containers.plist").path
|
||||
}()
|
||||
|
||||
@MainActor private var isDirty = false {
|
||||
private var isDirty = false {
|
||||
didSet {
|
||||
queueSaveToDiskIfNeeded()
|
||||
}
|
||||
@ -65,15 +65,15 @@ import Core
|
||||
|
||||
private extension ExtensionContainersFile {
|
||||
|
||||
@MainActor @objc func markAsDirty() {
|
||||
@objc func markAsDirty() {
|
||||
isDirty = true
|
||||
}
|
||||
|
||||
@MainActor func queueSaveToDiskIfNeeded() {
|
||||
func queueSaveToDiskIfNeeded() {
|
||||
saveQueue.add(self, #selector(saveToDiskIfNeeded))
|
||||
}
|
||||
|
||||
@MainActor @objc func saveToDiskIfNeeded() {
|
||||
@objc func saveToDiskIfNeeded() {
|
||||
if isDirty {
|
||||
isDirty = false
|
||||
save()
|
||||
|
@ -64,8 +64,8 @@ import Account
|
||||
|
||||
}
|
||||
|
||||
@objc @MainActor func timedRefresh(_ sender: Timer?) {
|
||||
|
||||
@objc func timedRefresh(_ sender: Timer?) {
|
||||
|
||||
guard !shuttingDown else {
|
||||
return
|
||||
}
|
||||
@ -73,7 +73,7 @@ import Account
|
||||
lastTimedRefresh = Date()
|
||||
update()
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
await AccountManager.shared.refreshAll()
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ import Account
|
||||
lastTimedRefresh = Date()
|
||||
update()
|
||||
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
await AccountManager.shared.syncArticleStatusAll()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user