Use MainActor Task instead of GCD.

This commit is contained in:
Brent Simmons
2023-07-09 22:54:55 -07:00
parent 1fa9fa5e10
commit 1be7e680d0
5 changed files with 19 additions and 20 deletions

View File

@@ -66,11 +66,11 @@ import RSParser
}
account.createFeed(url: url.absoluteString, name: title, container: container, validateFeed: true) { result in
DispatchQueue.main.async {
Task { @MainActor in
self.endShowingProgress()
}
switch result {
case .success(let feed):
NotificationCenter.default.post(name: .UserDidAddFeed, object: self, userInfo: [UserInfoKey.feed: feed])
@@ -81,7 +81,7 @@ import RSParser
case AccountError.createErrorNotFound:
self.showNoFeedsErrorMessage()
default:
DispatchQueue.main.async {
Task { @MainActor in
NSApplication.shared.presentError(error)
}
}

View File

@@ -106,11 +106,10 @@ enum TimelineSourceMode {
NotificationCenter.default.addObserver(self, selector: #selector(articleThemeNamesDidChangeNotification(_:)), name: .ArticleThemeNamesDidChangeNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(currentArticleThemeDidChangeNotification(_:)), name: .CurrentArticleThemeDidChangeNotification, object: nil)
DispatchQueue.main.async {
Task { @MainActor in
self.updateWindowTitle()
}
}
// MARK: - API

View File

@@ -88,7 +88,7 @@ import Account
panel.beginSheetModal(for: hostWindow!) { result in
if result == NSApplication.ModalResponse.OK, let url = panel.url {
DispatchQueue.main.async {
Task { @MainActor in
let filename = url.lastPathComponent
let opmlString = OPMLExporter.OPMLString(with: account, title: filename)
do {

View File

@@ -320,7 +320,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
if let selectedIndex = articles.firstIndex(where: { $0.articleID == articleID }) {
tableView.selectRow(selectedIndex)
DispatchQueue.main.async {
Task { @MainActor in
self.tableView.scrollTo(row: selectedIndex)
}
focus()