Skip to content

Commit

Permalink
Fix StoreKit
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Oct 3, 2023
1 parent 7630469 commit fa9f521
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 40 deletions.
10 changes: 0 additions & 10 deletions Sources/OversizeKit/LauncherKit/Launcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,6 @@ public extension View {
}
}

extension View {
func withoutAnimation(action: @escaping () -> Void) {
var transaction = Transaction()
transaction.disablesAnimations = true
withTransaction(transaction) {
action()
}
}
}

struct LockscreenView_Previews: PreviewProvider {
static var previews: some View {
Launcher {
Expand Down
14 changes: 4 additions & 10 deletions Sources/OversizeKit/StoreKit/StoreScreen/StoreInstuctinsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@ public struct StoreInstuctinsView: View {
PageView { offset = $0 } content: {
Group {
switch viewModel.state {
case .initial:
contentPlaceholder()
.task {
await viewModel.fetchData()
if case let .result(products) = viewModel.state {
await viewModel.updateState(products: products)
}
}

case .loading:
case .initial, .loading:
contentPlaceholder()
case let .result(data):
content(data: data)
Expand Down Expand Up @@ -73,6 +64,9 @@ public struct StoreInstuctinsView: View {
dismiss()
}
}
.task {
await viewModel.fetchData()
}
#else
EmptyView()
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ public struct StoreSpecialOfferView: View {
HStack {
Spacer()
ProgressView()
.task {
await viewModel.fetchData()
if case let .result(products) = viewModel.state {
await viewModel.updateState(products: products)
}
}
Spacer()
}
Spacer()
Expand Down Expand Up @@ -82,6 +76,9 @@ public struct StoreSpecialOfferView: View {
dismiss()
}
}
.task {
await viewModel.fetchData()
}
#else
EmptyView()
#endif
Expand Down
14 changes: 4 additions & 10 deletions Sources/OversizeKit/StoreKit/StoreScreen/StoreView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@ import SwiftUI
PageView {
Group {
switch viewModel.state {
case .initial:
contentPlaceholder()
.task {
await viewModel.fetchData()
if case let .result(products) = viewModel.state {
await viewModel.updateState(products: products)
}
}

case .loading:
case .initial, .loading:
contentPlaceholder()
case let .result(data):
content(data: data)
Expand Down Expand Up @@ -75,6 +66,9 @@ import SwiftUI
Fireworks()
}
}
.task {
await viewModel.fetchData()
}
}

var titleText: String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,11 @@ extension StoreViewModel {
}
state = .result(finalProducts)
log("✅ StoeKit fetched")
// log(finalProducts)
if finalProducts.autoRenewable.isEmpty {
log("❌ NO autoRenewable products")
} else {
log("📦 \(finalProducts.autoRenewable.count) autoRenewable products")
}
case let .failure(error):
state = .error(error)
log("❌ Product not fetched (\(error.title))")
Expand Down
3 changes: 0 additions & 3 deletions Sources/OversizeKit/StoreKit/Views/PrmiumBannerRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public struct PrmiumBannerRow: View {
}
.task {
await viewModel.fetchData()
if case let .result(products) = viewModel.state {
await viewModel.updateState(products: products)
}
}
}

Expand Down

0 comments on commit fa9f521

Please sign in to comment.