Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move AsyncOperation and AsyncBlockOperation to WordPressShared #24185

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class AsyncBlockOperation: AsyncOperation, @unchecked Sendable {
public class AsyncBlockOperation: AsyncOperation, @unchecked Sendable {

private let block: (@escaping () -> Void) -> Void

init(block: @escaping (@escaping () -> Void) -> Void) {
public init(block: @escaping (@escaping () -> Void) -> Void) {
self.block = block
}

override func main() {
public override func main() {
self.block { [weak self] in
self?.state = .isFinished
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class AsyncOperation: Operation, @unchecked Sendable {
enum State: String {
open class AsyncOperation: Operation, @unchecked Sendable {
public enum State: String {
case isReady, isExecuting, isFinished
}

override var isAsynchronous: Bool {
public override var isAsynchronous: Bool {
return true
}

var state = State.isReady {
public var state = State.isReady {
willSet {
willChangeValue(forKey: state.rawValue)
willChangeValue(forKey: newValue.rawValue)
Expand All @@ -18,15 +18,15 @@ class AsyncOperation: Operation, @unchecked Sendable {
}
}

override var isExecuting: Bool {
public override var isExecuting: Bool {
return state == .isExecuting
}

override var isFinished: Bool {
public override var isFinished: Bool {
return state == .isFinished
}

override func start() {
public override func start() {
if isCancelled {
state = .isFinished
return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import XCTest
@testable import WordPress
import WordPressShared

class AsyncOperationTests: XCTestCase {
let operation = AsyncOperation()
Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Services/MediaCoordinator.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import WordPressData
import WordPressFlux
import WordPressShared

import class AutomatticTracks.CrashLogging
import enum Alamofire.AFError
Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Services/NotificationSyncMediator.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import WordPressData
import WordPressKit
import WordPressShared

/// Notes:
///
Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Stores/RemoteFeatureFlagStore.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressShared
import WordPressKit

class RemoteFeatureFlagStore {
Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Utility/CoreData/ContextManager.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import CoreData
import Foundation
import WordPressData
import WordPressShared

/// A constant representing the current version of the data model.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import WordPressShared

final class StatsPeriodAsyncOperation<TimeStatsType: StatsTimeIntervalData>: AsyncOperation, @unchecked Sendable {
typealias StatsPeriodCompletion = (TimeStatsType?, Error?) -> Void

Expand Down
4 changes: 0 additions & 4 deletions WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,6 @@
93F2E5441E9E5A570050D489 /* CoreSpotlight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F2E5431E9E5A570050D489 /* CoreSpotlight.framework */; };
98BFF57E23984345008A1DCB /* AllTimeWidgetStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BFF57D23984344008A1DCB /* AllTimeWidgetStats.swift */; };
98E58A2F2360D23400E5534B /* TodayWidgetStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98E58A2E2360D23400E5534B /* TodayWidgetStats.swift */; };
9A9D34FD23607CCC00BC95A3 /* AsyncOperationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A9D34FC23607CCC00BC95A3 /* AsyncOperationTests.swift */; };
9A9D34FF2360A4E200BC95A3 /* StatsPeriodAsyncOperationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A9D34FE2360A4E200BC95A3 /* StatsPeriodAsyncOperationTests.swift */; };
A01C542E0E24E88400D411F2 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A01C542D0E24E88400D411F2 /* SystemConfiguration.framework */; };
A01C55480E25E0D000D411F2 /* defaultPostTemplate.html in Resources */ = {isa = PBXBuildFile; fileRef = A01C55470E25E0D000D411F2 /* defaultPostTemplate.html */; };
Expand Down Expand Up @@ -2800,7 +2799,6 @@
98BFF57D23984344008A1DCB /* AllTimeWidgetStats.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AllTimeWidgetStats.swift; sourceTree = "<group>"; };
98E58A2E2360D23400E5534B /* TodayWidgetStats.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TodayWidgetStats.swift; sourceTree = "<group>"; };
98FB6E9F23074CE5002DDC8D /* Common.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Common.xcconfig; sourceTree = "<group>"; };
9A9D34FC23607CCC00BC95A3 /* AsyncOperationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncOperationTests.swift; sourceTree = "<group>"; };
9A9D34FE2360A4E200BC95A3 /* StatsPeriodAsyncOperationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatsPeriodAsyncOperationTests.swift; sourceTree = "<group>"; };
A01C542D0E24E88400D411F2 /* SystemConfiguration.framework */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
A01C55470E25E0D000D411F2 /* defaultPostTemplate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = defaultPostTemplate.html; path = Resources/HTML/defaultPostTemplate.html; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5935,7 +5933,6 @@
9A9D34FB23607C8400BC95A3 /* Operations */ = {
isa = PBXGroup;
children = (
9A9D34FC23607CCC00BC95A3 /* AsyncOperationTests.swift */,
9A9D34FE2360A4E200BC95A3 /* StatsPeriodAsyncOperationTests.swift */,
);
name = Operations;
Expand Down Expand Up @@ -9682,7 +9679,6 @@
DCF892D0282FA42A00BB71E1 /* SiteStatsImmuTableRowsTests.swift in Sources */,
93EF094C19ED533500C89770 /* ContextManagerTests.swift in Sources */,
F17A2A2023BFBD84001E96AC /* UIView+ExistingConstraints.swift in Sources */,
9A9D34FD23607CCC00BC95A3 /* AsyncOperationTests.swift in Sources */,
B5552D821CD1061F00B26DF6 /* StringExtensionsTests.swift in Sources */,
3F759FBA2A2DA93B0039A845 /* WPAccount+Fixture.swift in Sources */,
77A141172B68546100BF75DD /* BooleanUserDefaultsDebugViewModelTests.swift in Sources */,
Expand Down