Skip to content

Commit

Permalink
Refactor: simplified PurchasesOrchestrator.syncPurchases (#2731)
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoSoto authored Jun 29, 2023
1 parent 7cf1274 commit 68892f3
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions Sources/Purchasing/Purchases/PurchasesOrchestrator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,6 @@ private extension PurchasesOrchestrator {
}
}

// swiftlint:disable:next function_body_length
func syncPurchases(receiptRefreshPolicy: ReceiptRefreshPolicy,
isRestore: Bool,
initiationSource: ProductRequestData.InitiationSource,
Expand Down Expand Up @@ -998,17 +997,14 @@ private extension PurchasesOrchestrator {
self.operationDispatcher.dispatchOnWorkerThread {
let hasTransactions = self.transactionsManager.customerHasTransactions(receiptData: receiptData)
let cachedCustomerInfo = self.customerInfoManager.cachedCustomerInfo(appUserID: currentAppUserID)
let hasOriginalPurchaseDate = cachedCustomerInfo?.originalPurchaseDate != nil

if !hasTransactions && hasOriginalPurchaseDate {
if !hasTransactions, let customerInfo = cachedCustomerInfo, customerInfo.originalPurchaseDate != nil {
if let completion = completion {
self.operationDispatcher.dispatchOnMainThread {
completion(
Result(cachedCustomerInfo,
ErrorUtils.customerInfoError(withMessage: "No cached customer info"))
)
completion(.success(customerInfo))
}
}

return
}

Expand Down

0 comments on commit 68892f3

Please sign in to comment.