mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-02 20:16:54 +01:00
Fix concurrency warnings by marking things as MainActor.
This commit is contained in:
parent
3fea0f0758
commit
0949aefa93
@ -612,6 +612,7 @@ public enum FetchType {
|
||||
try await delegate.addFeed(for: self, with: feed, to: container)
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
public func createFeed(url: String, name: String?, container: Container, validateFeed: Bool) async throws -> Feed {
|
||||
|
||||
try await delegate.createFeed(for: self, url: url, name: name, container: container, validateFeed: validateFeed)
|
||||
|
@ -14,11 +14,11 @@ import ArticlesDatabase
|
||||
import FoundationExtras
|
||||
|
||||
protocol LocalAccountRefresherDelegate {
|
||||
func localAccountRefresher(_ refresher: LocalAccountRefresher, requestCompletedFor: Feed)
|
||||
func localAccountRefresher(_ refresher: LocalAccountRefresher, articleChanges: ArticleChanges, completion: @escaping () -> Void)
|
||||
@MainActor func localAccountRefresher(_ refresher: LocalAccountRefresher, requestCompletedFor: Feed)
|
||||
@MainActor func localAccountRefresher(_ refresher: LocalAccountRefresher, articleChanges: ArticleChanges, completion: @escaping () -> Void)
|
||||
}
|
||||
|
||||
final class LocalAccountRefresher {
|
||||
@MainActor final class LocalAccountRefresher {
|
||||
|
||||
private var completion: (() -> Void)? = nil
|
||||
private var isSuspended = false
|
||||
|
@ -13,7 +13,7 @@ import AppKitExtras
|
||||
|
||||
typealias PasteboardFeedDictionary = [String: String]
|
||||
|
||||
struct PasteboardFeed: Hashable {
|
||||
@MainActor struct PasteboardFeed: Hashable {
|
||||
|
||||
private struct Key {
|
||||
static let url = "URL"
|
||||
|
@ -36,36 +36,42 @@ extension Article: PasteboardWriterOwner {
|
||||
|
||||
// MARK: - NSPasteboardWriting
|
||||
|
||||
func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] {
|
||||
var types = [ArticlePasteboardWriter.articleUTIType]
|
||||
nonisolated func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] {
|
||||
|
||||
if let _ = article.preferredURL {
|
||||
types += [.URL]
|
||||
MainActor.assumeIsolated {
|
||||
var types = [ArticlePasteboardWriter.articleUTIType]
|
||||
|
||||
if let _ = article.preferredURL {
|
||||
types += [.URL]
|
||||
}
|
||||
types += [.string, .html, ArticlePasteboardWriter.articleUTIInternalType]
|
||||
|
||||
return types
|
||||
}
|
||||
types += [.string, .html, ArticlePasteboardWriter.articleUTIInternalType]
|
||||
|
||||
return types
|
||||
}
|
||||
|
||||
func pasteboardPropertyList(forType type: NSPasteboard.PasteboardType) -> Any? {
|
||||
let plist: Any?
|
||||
nonisolated func pasteboardPropertyList(forType type: NSPasteboard.PasteboardType) -> Any? {
|
||||
|
||||
switch type {
|
||||
case .html:
|
||||
return renderedHTML
|
||||
case .string:
|
||||
plist = plainText()
|
||||
case .URL:
|
||||
return article.preferredLink ?? ""
|
||||
case ArticlePasteboardWriter.articleUTIType:
|
||||
plist = exportDictionary()
|
||||
case ArticlePasteboardWriter.articleUTIInternalType:
|
||||
plist = internalDictionary()
|
||||
default:
|
||||
plist = nil
|
||||
MainActor.assumeIsolated {
|
||||
let plist: Any?
|
||||
|
||||
switch type {
|
||||
case .html:
|
||||
return renderedHTML
|
||||
case .string:
|
||||
plist = plainText()
|
||||
case .URL:
|
||||
return article.preferredLink ?? ""
|
||||
case ArticlePasteboardWriter.articleUTIType:
|
||||
plist = exportDictionary()
|
||||
case ArticlePasteboardWriter.articleUTIInternalType:
|
||||
plist = internalDictionary()
|
||||
default:
|
||||
plist = nil
|
||||
}
|
||||
|
||||
return plist
|
||||
}
|
||||
|
||||
return plist
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import Account
|
||||
|
||||
protocol SmallIconProvider {
|
||||
|
||||
var smallIcon: IconImage? { get }
|
||||
@MainActor var smallIcon: IconImage? { get }
|
||||
}
|
||||
|
||||
extension Account: SmallIconProvider {
|
||||
|
@ -12,7 +12,7 @@ import Parser
|
||||
import Account
|
||||
import Core
|
||||
|
||||
final class ExtensionContainersFile {
|
||||
@MainActor final class ExtensionContainersFile {
|
||||
|
||||
private static let log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "extensionContainersFile")
|
||||
|
||||
|
@ -10,7 +10,7 @@ import Foundation
|
||||
import Account
|
||||
|
||||
protocol SidebarItemIdentifiable {
|
||||
var sidebarItemID: SidebarItemIdentifier? { get }
|
||||
@MainActor var sidebarItemID: SidebarItemIdentifier? { get }
|
||||
}
|
||||
|
||||
enum SidebarItemIdentifier: CustomStringConvertible, Hashable, Equatable {
|
||||
|
@ -11,7 +11,7 @@ import Account
|
||||
import Articles
|
||||
import ArticlesDatabase
|
||||
|
||||
struct SearchFeedDelegate: SmartFeedDelegate {
|
||||
@MainActor struct SearchFeedDelegate: SmartFeedDelegate {
|
||||
|
||||
var sidebarItemID: SidebarItemIdentifier? {
|
||||
return SidebarItemIdentifier.smartFeed(String(describing: SearchFeedDelegate.self))
|
||||
|
@ -11,7 +11,7 @@ import Account
|
||||
import Articles
|
||||
import ArticlesDatabase
|
||||
|
||||
struct SearchTimelineFeedDelegate: SmartFeedDelegate {
|
||||
@MainActor struct SearchTimelineFeedDelegate: SmartFeedDelegate {
|
||||
|
||||
var sidebarItemID: SidebarItemIdentifier? {
|
||||
return SidebarItemIdentifier.smartFeed(String(describing: SearchTimelineFeedDelegate.self))
|
||||
|
@ -13,17 +13,17 @@ import Foundation
|
||||
|
||||
public protocol DownloadSessionDelegate {
|
||||
|
||||
func downloadSession(_ downloadSession: DownloadSession, requestForRepresentedObject: AnyObject) -> URLRequest?
|
||||
func downloadSession(_ downloadSession: DownloadSession, downloadDidCompleteForRepresentedObject: AnyObject, response: URLResponse?, data: Data, error: NSError?, completion: @escaping () -> Void)
|
||||
func downloadSession(_ downloadSession: DownloadSession, shouldContinueAfterReceivingData: Data, representedObject: AnyObject) -> Bool
|
||||
func downloadSession(_ downloadSession: DownloadSession, didReceiveUnexpectedResponse: URLResponse, representedObject: AnyObject)
|
||||
func downloadSession(_ downloadSession: DownloadSession, didReceiveNotModifiedResponse: URLResponse, representedObject: AnyObject)
|
||||
func downloadSession(_ downloadSession: DownloadSession, didDiscardDuplicateRepresentedObject: AnyObject)
|
||||
func downloadSessionDidCompleteDownloadObjects(_ downloadSession: DownloadSession)
|
||||
|
||||
@MainActor func downloadSession(_ downloadSession: DownloadSession, requestForRepresentedObject: AnyObject) -> URLRequest?
|
||||
@MainActor func downloadSession(_ downloadSession: DownloadSession, downloadDidCompleteForRepresentedObject: AnyObject, response: URLResponse?, data: Data, error: NSError?, completion: @escaping () -> Void)
|
||||
@MainActor func downloadSession(_ downloadSession: DownloadSession, shouldContinueAfterReceivingData: Data, representedObject: AnyObject) -> Bool
|
||||
@MainActor func downloadSession(_ downloadSession: DownloadSession, didReceiveUnexpectedResponse: URLResponse, representedObject: AnyObject)
|
||||
@MainActor func downloadSession(_ downloadSession: DownloadSession, didReceiveNotModifiedResponse: URLResponse, representedObject: AnyObject)
|
||||
@MainActor func downloadSession(_ downloadSession: DownloadSession, didDiscardDuplicateRepresentedObject: AnyObject)
|
||||
@MainActor func downloadSessionDidCompleteDownloadObjects(_ downloadSession: DownloadSession)
|
||||
|
||||
}
|
||||
|
||||
@objc public final class DownloadSession: NSObject {
|
||||
@MainActor @objc public final class DownloadSession: NSObject {
|
||||
|
||||
private var urlSession: URLSession!
|
||||
private var tasksInProgress = Set<URLSessionTask>()
|
||||
@ -70,7 +70,7 @@ public protocol DownloadSessionDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
public func downloadObjects(_ objects: NSSet) {
|
||||
@MainActor public func downloadObjects(_ objects: NSSet) {
|
||||
for oneObject in objects {
|
||||
if !representedObjects.contains(oneObject) {
|
||||
representedObjects.add(oneObject)
|
||||
@ -175,7 +175,7 @@ extension DownloadSession: URLSessionDataDelegate {
|
||||
|
||||
private extension DownloadSession {
|
||||
|
||||
func addDataTask(_ representedObject: AnyObject) {
|
||||
@MainActor func addDataTask(_ representedObject: AnyObject) {
|
||||
guard tasksPending.count < 500 else {
|
||||
queue.insert(representedObject, at: 0)
|
||||
return
|
||||
@ -213,7 +213,7 @@ private extension DownloadSession {
|
||||
return taskIdentifierToInfoDictionary[task.taskIdentifier]
|
||||
}
|
||||
|
||||
func removeTask(_ task: URLSessionTask) {
|
||||
@MainActor func removeTask(_ task: URLSessionTask) {
|
||||
tasksInProgress.remove(task)
|
||||
tasksPending.remove(task)
|
||||
taskIdentifierToInfoDictionary[task.taskIdentifier] = nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user