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 {
private func completeTransactions() {
// This SHOULD ONLY BE CALLED ONCE, in the AppDelegate
let log = self.log
log.info("Started complete transaction...")
SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
log.info("Complete transactions for \(purchases.count) purchases")
for purchase in purchases {
log.info("Purchase \(purchase.productId): \(purchase.transaction.transactionState)")
switch purchase.transaction.transactionState {
case .purchased, .restored:
if purchase.needsFinishTransaction {
......@@ -179,6 +182,8 @@ public class StoreManager {
if product.needsFinishTransaction {
SwiftyStoreKit.finishTransaction(product.transaction)
}
self.hasSubscription = true
self.everHadSubscription = true
completion(true)
case .error(error: let error):
log.error("Purchase: error for \(product.productIdentifier): \(error)")
......@@ -272,15 +277,11 @@ public class StoreManager {
}
case .error(let 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) {
observers.add(delegate: observer)
}
......
......@@ -137,6 +137,7 @@ class MinutelyForecastView: UIView {
private var minutelyForecast = [MinutelyItem]()
private var timer: Timer?
private var trackUserSwipe = false
private var initialyConfigured = false
private var forecastType = MinutelyForecastType.temperature
private var smartTextProvider: SmartTextProvider = SmartTextProvider(prioritizedSmartTexts: [])
......@@ -213,6 +214,13 @@ class MinutelyForecastView: UIView {
updateChart()
configureTimer()
updateCurrentSelectedLevel()
if let firstItem = location.minutely?.forecast.first {
if initialyConfigured == false {
updateDetailsView(minutelyItem: firstItem)
initialyConfigured = true
}
}
}
private func configureTimer() {
......
......@@ -52,7 +52,11 @@ class TodayViewModel: ViewModelProtocol {
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.configManager = configManager
self.shortsManager = shortsManager
......@@ -183,7 +187,7 @@ class TodayViewModel: ViewModelProtocol {
}
}
//MARK:- LocationManager Delegate
//MARK: LocationManager Delegate
extension TodayViewModel: LocationManagerDelegate {
func locationManager(_ locationManager: LocationManager, changedSelectedLocation newLocation: Location?) {
onMain {
......@@ -201,27 +205,28 @@ extension TodayViewModel: LocationManagerDelegate {
}
}
//MARK: StoreManager Observer
extension TodayViewModel: StoreManagerObserver {
func storeManagerUpdatedStatus(_ storeManager: StoreManager) {
handlePremiumStateChange()
}
}
//MARK:- Settings Delegate
//MARK: Settings Delegate
extension TodayViewModel: SettingsDelegate {
func settingsDidChange() {
delegate?.viewModelDidChange(model: self)
}
}
// MARK: CellFactoryDelegate
//MARK: CellFactoryDelegate
extension TodayViewModel: CellFactoryDelegate {
func cellFactoryCellsChanged(_ factory: CellFactory) {
delegate?.viewModelDidChange(model: self)
}
}
//MARK:- ShortsManager Delegate
//MARK: ShortsManager Delegate
extension TodayViewModel: ShortsManagerDelegate {
func shortsDidChange() {
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