mirror of
https://github.com/StikDebug/StikDebug.git
synced 2026-10-16 04:20:30 +00:00
Final fixes
This commit is contained in:
parent
ed89a94913
commit
9fd2f51871
3 changed files with 51 additions and 10 deletions
|
|
@ -55,7 +55,7 @@
|
|||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
|
|
|
|||
|
|
@ -93,9 +93,11 @@ final class ThemeExpansionManager: ObservableObject {
|
|||
|
||||
guard !previewUnlocked else { return }
|
||||
|
||||
updatesTask = Task.detached(priority: .background) { [weak self] in
|
||||
// Listen for transaction updates and apply verified ones
|
||||
updatesTask = Task { [weak self] in
|
||||
guard let self else { return }
|
||||
for await result in StoreKit.Transaction.updates {
|
||||
await self?.handle(transactionResult: result)
|
||||
await self.handle(transactionResult: result)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -115,11 +117,33 @@ final class ThemeExpansionManager: ObservableObject {
|
|||
let products = try await Product.products(for: [Self.productIdentifier])
|
||||
themeExpansionProduct = products.first
|
||||
|
||||
if let latest = await StoreKit.Transaction.latest(for: Self.productIdentifier) {
|
||||
await handle(transactionResult: latest, finishTransaction: false)
|
||||
} else {
|
||||
hasThemeExpansion = false
|
||||
if products.isEmpty {
|
||||
#if targetEnvironment(simulator)
|
||||
lastError = """
|
||||
No products found for.
|
||||
"""
|
||||
#else
|
||||
lastError = """
|
||||
No products found for.
|
||||
"""
|
||||
#endif
|
||||
}
|
||||
|
||||
// Recompute entitlement from current entitlements
|
||||
hasThemeExpansion = await isEntitledToThemeExpansion()
|
||||
} catch {
|
||||
lastError = error.localizedDescription
|
||||
}
|
||||
}
|
||||
|
||||
func restorePurchases() async {
|
||||
guard !isPreviewInstance else { return }
|
||||
isProcessing = true
|
||||
defer { isProcessing = false }
|
||||
do {
|
||||
lastError = nil
|
||||
try await AppStore.sync()
|
||||
hasThemeExpansion = await isEntitledToThemeExpansion()
|
||||
} catch {
|
||||
lastError = error.localizedDescription
|
||||
}
|
||||
|
|
@ -138,7 +162,15 @@ final class ThemeExpansionManager: ObservableObject {
|
|||
themeExpansionProduct = first
|
||||
product = first
|
||||
} else {
|
||||
lastError = "Theme Expansion isn't available yet. Check your App Store configuration and try again."
|
||||
#if targetEnvironment(simulator)
|
||||
lastError = """
|
||||
Theme Expansion isn’t available.
|
||||
"""
|
||||
#else
|
||||
lastError = """
|
||||
Theme Expansion isn’t available.
|
||||
"""
|
||||
#endif
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
|
|
@ -278,7 +310,7 @@ final class ThemeExpansionManager: ObservableObject {
|
|||
switch transactionResult {
|
||||
case .verified(let transaction):
|
||||
if transaction.productID == Self.productIdentifier {
|
||||
hasThemeExpansion = true
|
||||
hasThemeExpansion = (transaction.revocationDate == nil)
|
||||
lastError = nil
|
||||
}
|
||||
if finishTransaction {
|
||||
|
|
@ -288,6 +320,15 @@ final class ThemeExpansionManager: ObservableObject {
|
|||
lastError = error.localizedDescription
|
||||
}
|
||||
}
|
||||
|
||||
private func isEntitledToThemeExpansion() async -> Bool {
|
||||
for await result in Transaction.currentEntitlements {
|
||||
if case .verified(let transaction) = result, transaction.productID == Self.productIdentifier {
|
||||
return transaction.revocationDate == nil
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ struct DisplayView: View {
|
|||
|
||||
if let manager = themeExpansion {
|
||||
Button {
|
||||
Task { await manager.refreshEntitlements() }
|
||||
Task { await manager.restorePurchases() }
|
||||
} label: {
|
||||
Text("Restore Purchase")
|
||||
.font(.subheadline)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue