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

Extracted TransactionPoster from PurchasesOrchestrator #2540

Merged
merged 1 commit into from
May 26, 2023
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
4 changes: 4 additions & 0 deletions RevenueCat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
4F69EB092A14406E00ED6D4B /* Matchers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F69EB082A14406E00ED6D4B /* Matchers.swift */; };
4F69EB0A2A14406E00ED6D4B /* Matchers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F69EB082A14406E00ED6D4B /* Matchers.swift */; };
4F7DBFBD2A1E986C00A2F511 /* StoreKit2TransactionFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F7DBFBC2A1E986C00A2F511 /* StoreKit2TransactionFetcher.swift */; };
4F8038332A1EA7C300D21039 /* TransactionPoster.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8038322A1EA7C300D21039 /* TransactionPoster.swift */; };
4F8A58172A16EE3500EF97AD /* MockOfflineCustomerInfoCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8A58162A16EE3500EF97AD /* MockOfflineCustomerInfoCreator.swift */; };
4F8A58182A16EE3500EF97AD /* MockOfflineCustomerInfoCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8A58162A16EE3500EF97AD /* MockOfflineCustomerInfoCreator.swift */; };
4FA4C8DA2A168956007D2803 /* OfflineCustomerInfoCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FA4C8D92A168956007D2803 /* OfflineCustomerInfoCreator.swift */; };
Expand Down Expand Up @@ -882,6 +883,7 @@
4F2017D42A15587F0061F6EF /* OfflineStoreKitIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OfflineStoreKitIntegrationTests.swift; sourceTree = "<group>"; };
4F69EB082A14406E00ED6D4B /* Matchers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Matchers.swift; sourceTree = "<group>"; };
4F7DBFBC2A1E986C00A2F511 /* StoreKit2TransactionFetcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreKit2TransactionFetcher.swift; sourceTree = "<group>"; };
4F8038322A1EA7C300D21039 /* TransactionPoster.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionPoster.swift; sourceTree = "<group>"; };
4F8A58162A16EE3500EF97AD /* MockOfflineCustomerInfoCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockOfflineCustomerInfoCreator.swift; sourceTree = "<group>"; };
4FA4C8D92A168956007D2803 /* OfflineCustomerInfoCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OfflineCustomerInfoCreator.swift; sourceTree = "<group>"; };
4FA4C9722A16D3AC007D2803 /* MockBackendConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockBackendConfiguration.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2397,6 +2399,7 @@
B35042C326CDB79A00905B95 /* Purchases.swift */,
B35042C526CDD3B100905B95 /* PurchasesDelegate.swift */,
2D9F4A5426C30CA800B07B43 /* PurchasesOrchestrator.swift */,
4F8038322A1EA7C300D21039 /* TransactionPoster.swift */,
);
path = Purchases;
sourceTree = "<group>";
Expand Down Expand Up @@ -3138,6 +3141,7 @@
2D971CC12744364C0093F35F /* SKError+Extensions.swift in Sources */,
57F2C60C29784C11009EE527 /* SwiftVersionCheck.swift in Sources */,
57EAE527274324C60060EB74 /* Lock.swift in Sources */,
4F8038332A1EA7C300D21039 /* TransactionPoster.swift in Sources */,
B32B74FF26868AEB005647BF /* Package.swift in Sources */,
578DAA482948EEAD001700FD /* Clock.swift in Sources */,
2DDF41B324F6F387005BC22D /* InAppPurchaseBuilder.swift in Sources */,
Expand Down
4 changes: 1 addition & 3 deletions Sources/Misc/Concurrency/OperationDispatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,5 @@ extension OperationDispatcher {

}

#if swift(<5.8)
// `DispatchQueue` is not `Sendable` as of Swift 5.7, but this class performs no mutations.
// `DispatchQueue` is not `Sendable` as of Swift 5.8, but this class performs no mutations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the swift version check no longer needed? I thought you could still build using Xcode 13 and upload to app store

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to explain this.
Until this PR, turns out we weren't relying on OperationDispatcher being Sendable. This broke on Swift 5.8, because we didn't have an #else.
I don't think they're ever going to make DispatchQueue Sendable, but our @unchecked Sendable is still valid, hence why I removed the conditional.

extension OperationDispatcher: @unchecked Sendable {}
#endif
13 changes: 13 additions & 0 deletions Sources/Purchasing/Purchases/Purchases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,17 @@ public typealias StartPurchaseBlock = (@escaping PurchaseCompletedBlock) -> Void
let beginRefundRequestHelper = BeginRefundRequestHelper(systemInfo: systemInfo,
customerInfoManager: customerInfoManager,
currentUserProvider: identityManager)
let transactionPoster = TransactionPoster(
productsManager: productsManager,
receiptFetcher: receiptFetcher,
currentUserProvider: identityManager,
attribution: subscriberAttributes,
backend: backend,
paymentQueueWrapper: paymentQueueWrapper,
systemInfo: systemInfo,
operationDispatcher: operationDispatcher
)

let purchasesOrchestrator: PurchasesOrchestrator = {
if #available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *) {
return .init(
Expand All @@ -365,6 +376,7 @@ public typealias StartPurchaseBlock = (@escaping PurchaseCompletedBlock) -> Void
receiptParser: receiptParser,
customerInfoManager: customerInfoManager,
backend: backend,
transactionPoster: transactionPoster,
currentUserProvider: identityManager,
transactionsManager: transactionsManager,
deviceCache: deviceCache,
Expand All @@ -385,6 +397,7 @@ public typealias StartPurchaseBlock = (@escaping PurchaseCompletedBlock) -> Void
receiptParser: receiptParser,
customerInfoManager: customerInfoManager,
backend: backend,
transactionPoster: transactionPoster,
currentUserProvider: identityManager,
transactionsManager: transactionsManager,
deviceCache: deviceCache,
Expand Down
Loading