mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-12 03:21:09 +00:00
Fix restore
This commit is contained in:
1 parent
406f1ab78b
commit
0c3ccc278a
4 files changed
+20
-28
No files matched your search
@@ -273,23 +273,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, MainAppDelegate{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct TransferInfo {
|
||||
let device: RemoteDeviceInfo
|
||||
let transfer: TransferMetadata
|
||||
}
|
||||
|
||||
class WindowDelegate: NSObject, NSWindowDelegate {
|
||||
|
||||
let willClose: () -> Void
|
||||
|
||||
init(willClose: @escaping () -> Void) {
|
||||
self.willClose = willClose
|
||||
}
|
||||
|
||||
|
||||
func windowWillClose(_ notification: Notification) {
|
||||
print("Window closed!")
|
||||
// Perform any cleanup or state updates here
|
||||
willClose()
|
||||
}
|
||||
}
|
||||
@@ -105,16 +105,19 @@ struct GetPlusView: View {
|
||||
switch result {
|
||||
case .success(let success):
|
||||
if success {
|
||||
log("[LUI] Restored purchases successfully")
|
||||
withAnimation {
|
||||
isPlusVersion = true
|
||||
}
|
||||
boughtSuccessAlert = true
|
||||
} else {
|
||||
log("[LUI] Nothing to restore")
|
||||
//nothing to restore
|
||||
restoreFailed(message: "plusview_nothingtorestore")
|
||||
restoreFailed(message: "plusview_nothingtorestore".localized())
|
||||
}
|
||||
|
||||
case .failure(let error):
|
||||
log("[LUI] Error restoring purchases: \(error.localizedDescription)")
|
||||
log(error.localizedDescription)
|
||||
restoreFailed(message: error.localizedDescription)
|
||||
}
|
||||
|
||||
@@ -88,14 +88,19 @@ class IAPManager: NSObject, ObservableObject {
|
||||
|
||||
extension IAPManager: SKPaymentTransactionObserver {
|
||||
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
|
||||
|
||||
log("IAP updatedTransactions")
|
||||
|
||||
transactions.forEach { (transaction) in
|
||||
|
||||
|
||||
switch transaction.transactionState {
|
||||
case .purchased:
|
||||
log("IAP purchased")
|
||||
onBuyProductHandler?(.success(true))
|
||||
SKPaymentQueue.default().finishTransaction(transaction)
|
||||
|
||||
case .restored:
|
||||
log("IAP restored")
|
||||
totalRestoredPurchases += 1
|
||||
onBuyProductHandler?(.success(true))
|
||||
SKPaymentQueue.default().finishTransaction(transaction)
|
||||
@@ -120,17 +125,16 @@ extension IAPManager: SKPaymentTransactionObserver {
|
||||
}
|
||||
|
||||
|
||||
|
||||
func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {
|
||||
if totalRestoredPurchases != 0 {
|
||||
onBuyProductHandler?(.success(true))
|
||||
} else {
|
||||
log("[LUI] IAP: No purchases to restore!")
|
||||
onBuyProductHandler?(.success(false))
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
||||
if self.totalRestoredPurchases == 0 {
|
||||
log("[LUI] IAP: No purchases to restore!")
|
||||
self.onBuyProductHandler?(.success(false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
func paymentQueue(_ queue: SKPaymentQueue, restoreCompletedTransactionsFailedWithError error: Error) {
|
||||
if let error = error as? SKError {
|
||||
if error.code != .paymentCancelled {
|
||||
|
||||
@@ -786,7 +786,7 @@
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
SHARED_BUILD = 7;
|
||||
SHARED_VERSION = 1.2;
|
||||
SHARED_VERSION = 1.2.1;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
@@ -845,7 +845,7 @@
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = macosx;
|
||||
SHARED_BUILD = 7;
|
||||
SHARED_VERSION = 1.2;
|
||||
SHARED_VERSION = 1.2.1;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user