Commit 26b4dba9 by Dmitry Stepanets

Merge branch 'bugfix/iOS-276-pro-getting-ads' into develop

parents e9df79fd b0525afd
...@@ -101,10 +101,13 @@ public class StoreManager { ...@@ -101,10 +101,13 @@ public class StoreManager {
private func completeTransactions() { private func completeTransactions() {
// This SHOULD ONLY BE CALLED ONCE, in the AppDelegate // This SHOULD ONLY BE CALLED ONCE, in the AppDelegate
let log = self.log let log = self.log
log.info("Started complete transaction...")
SwiftyStoreKit.completeTransactions(atomically: true) { purchases in SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
log.info("Complete transactions for \(purchases.count) purchases") log.info("Complete transactions for \(purchases.count) purchases")
for purchase in purchases { for purchase in purchases {
log.info("Purchase \(purchase.productId): \(purchase.transaction.transactionState)") log.info("Purchase \(purchase.productId): \(purchase.transaction.transactionState)")
switch purchase.transaction.transactionState { switch purchase.transaction.transactionState {
case .purchased, .restored: case .purchased, .restored:
if purchase.needsFinishTransaction { if purchase.needsFinishTransaction {
...@@ -179,6 +182,8 @@ public class StoreManager { ...@@ -179,6 +182,8 @@ public class StoreManager {
if product.needsFinishTransaction { if product.needsFinishTransaction {
SwiftyStoreKit.finishTransaction(product.transaction) SwiftyStoreKit.finishTransaction(product.transaction)
} }
self.hasSubscription = true
self.everHadSubscription = true
completion(true) completion(true)
case .error(error: let error): case .error(error: let error):
log.error("Purchase: error for \(product.productIdentifier): \(error)") log.error("Purchase: error for \(product.productIdentifier): \(error)")
...@@ -272,15 +277,11 @@ public class StoreManager { ...@@ -272,15 +277,11 @@ public class StoreManager {
} }
case .error(let error): case .error(let error):
log.error("Receipt verification failed: \(error)") log.error("Receipt verification failed: \(error)")
self.hasSubscription = false
self.everHadSubscription = false
self.removeAdsPurchased = false
self.subscriptionExpirationDate = nil
} }
} }
} }
//MARK: - Observers management
//MARK: - Observers management
public func add(observer: StoreManagerObserver) { public func add(observer: StoreManagerObserver) {
observers.add(delegate: observer) observers.add(delegate: observer)
} }
......
...@@ -137,6 +137,7 @@ class MinutelyForecastView: UIView { ...@@ -137,6 +137,7 @@ class MinutelyForecastView: UIView {
private var minutelyForecast = [MinutelyItem]() private var minutelyForecast = [MinutelyItem]()
private var timer: Timer? private var timer: Timer?
private var trackUserSwipe = false private var trackUserSwipe = false
private var initialyConfigured = false
private var forecastType = MinutelyForecastType.temperature private var forecastType = MinutelyForecastType.temperature
private var smartTextProvider: SmartTextProvider = SmartTextProvider(prioritizedSmartTexts: []) private var smartTextProvider: SmartTextProvider = SmartTextProvider(prioritizedSmartTexts: [])
...@@ -213,6 +214,13 @@ class MinutelyForecastView: UIView { ...@@ -213,6 +214,13 @@ class MinutelyForecastView: UIView {
updateChart() updateChart()
configureTimer() configureTimer()
updateCurrentSelectedLevel() updateCurrentSelectedLevel()
if let firstItem = location.minutely?.forecast.first {
if initialyConfigured == false {
updateDetailsView(minutelyItem: firstItem)
initialyConfigured = true
}
}
} }
private func configureTimer() { private func configureTimer() {
......
...@@ -52,7 +52,11 @@ class TodayViewModel: ViewModelProtocol { ...@@ -52,7 +52,11 @@ class TodayViewModel: ViewModelProtocol {
NotificationCenter.default.removeObserver(self) NotificationCenter.default.removeObserver(self)
} }
public init(locationManager: LocationManager = LocationManager.shared, configManager: ConfigManager = ConfigManager.shared, shortsManager: ShortsManager = ShortsManager.shared, storeManager: StoreManager = StoreManager.shared) { public init(locationManager: LocationManager = LocationManager.shared,
configManager: ConfigManager = ConfigManager.shared,
shortsManager: ShortsManager = ShortsManager.shared,
storeManager: StoreManager = StoreManager.shared)
{
self.locationManager = locationManager self.locationManager = locationManager
self.configManager = configManager self.configManager = configManager
self.shortsManager = shortsManager self.shortsManager = shortsManager
...@@ -183,7 +187,7 @@ class TodayViewModel: ViewModelProtocol { ...@@ -183,7 +187,7 @@ class TodayViewModel: ViewModelProtocol {
} }
} }
//MARK:- LocationManager Delegate //MARK: LocationManager Delegate
extension TodayViewModel: LocationManagerDelegate { extension TodayViewModel: LocationManagerDelegate {
func locationManager(_ locationManager: LocationManager, changedSelectedLocation newLocation: Location?) { func locationManager(_ locationManager: LocationManager, changedSelectedLocation newLocation: Location?) {
onMain { onMain {
...@@ -201,27 +205,28 @@ extension TodayViewModel: LocationManagerDelegate { ...@@ -201,27 +205,28 @@ extension TodayViewModel: LocationManagerDelegate {
} }
} }
//MARK: StoreManager Observer
extension TodayViewModel: StoreManagerObserver { extension TodayViewModel: StoreManagerObserver {
func storeManagerUpdatedStatus(_ storeManager: StoreManager) { func storeManagerUpdatedStatus(_ storeManager: StoreManager) {
handlePremiumStateChange() handlePremiumStateChange()
} }
} }
//MARK:- Settings Delegate //MARK: Settings Delegate
extension TodayViewModel: SettingsDelegate { extension TodayViewModel: SettingsDelegate {
func settingsDidChange() { func settingsDidChange() {
delegate?.viewModelDidChange(model: self) delegate?.viewModelDidChange(model: self)
} }
} }
// MARK: CellFactoryDelegate //MARK: CellFactoryDelegate
extension TodayViewModel: CellFactoryDelegate { extension TodayViewModel: CellFactoryDelegate {
func cellFactoryCellsChanged(_ factory: CellFactory) { func cellFactoryCellsChanged(_ factory: CellFactory) {
delegate?.viewModelDidChange(model: self) delegate?.viewModelDidChange(model: self)
} }
} }
//MARK:- ShortsManager Delegate //MARK: ShortsManager Delegate
extension TodayViewModel: ShortsManagerDelegate { extension TodayViewModel: ShortsManagerDelegate {
func shortsDidChange() { func shortsDidChange() {
onMain { onMain {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment