Commit a79fbc1a by Demid Merzlyakov

Minutely: only request minutely data if minutely forecast is available.

parent 040ee70b
......@@ -277,6 +277,7 @@
CEEB3549266F5DA900E16F90 /* MRECAdCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEEB3548266F5DA900E16F90 /* MRECAdCell.swift */; };
CEEF4100265E47FF00425D8F /* BlendFIPSSource.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEEF40FF265E47FF00425D8F /* BlendFIPSSource.framework */; };
CEEF4101265E47FF00425D8F /* BlendFIPSSource.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CEEF40FF265E47FF00425D8F /* BlendFIPSSource.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
CEEF506D27105B440057680D /* LocationManager+StoreManagerObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEEF506C27105B430057680D /* LocationManager+StoreManagerObserver.swift */; };
F227B22E26B2A45700DD7EBB /* AppInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = F227B22D26B2A45700DD7EBB /* AppInfo.swift */; };
F227B23026B7B97200DD7EBB /* TerceptSDKEnablerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F227B22F26B7B97200DD7EBB /* TerceptSDKEnablerTests.swift */; };
F227B23226B7CC0000DD7EBB /* TerceptSDKEnabler.swift in Sources */ = {isa = PBXBuildFile; fileRef = F227B23126B7CC0000DD7EBB /* TerceptSDKEnabler.swift */; };
......@@ -635,6 +636,7 @@
CEEB3546266F5D9900E16F90 /* BannerAdCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BannerAdCell.swift; sourceTree = "<group>"; };
CEEB3548266F5DA900E16F90 /* MRECAdCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MRECAdCell.swift; sourceTree = "<group>"; };
CEEF40FF265E47FF00425D8F /* BlendFIPSSource.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = BlendFIPSSource.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CEEF506C27105B430057680D /* LocationManager+StoreManagerObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LocationManager+StoreManagerObserver.swift"; sourceTree = "<group>"; };
DF826CF4702D9DCCB9A9DD71 /* Pods-1Weather.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-1Weather.release.xcconfig"; path = "Target Support Files/Pods-1Weather/Pods-1Weather.release.xcconfig"; sourceTree = "<group>"; };
F227B22D26B2A45700DD7EBB /* AppInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppInfo.swift; sourceTree = "<group>"; };
F227B22F26B7B97200DD7EBB /* TerceptSDKEnablerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerceptSDKEnablerTests.swift; sourceTree = "<group>"; };
......@@ -1037,6 +1039,7 @@
CD85797226721DD400CC4CDA /* UIColor+Highlight.swift */,
CDB0D4CD2670DABF0081C773 /* UIImage+AverageColor.swift */,
CD1000AD26D92A8F002D6C61 /* Array+Unique.swift */,
CEEF506C27105B430057680D /* LocationManager+StoreManagerObserver.swift */,
);
path = Extensions;
sourceTree = "<group>";
......@@ -2306,6 +2309,7 @@
CD86246925E672A20097F3FB /* PrecipButton.swift in Sources */,
CD8579782672214700CC4CDA /* UIStackView+RemoveAll.swift in Sources */,
CD3F6E6C25FA5A90002DB99B /* PeriodButtonProtocol.swift in Sources */,
CEEF506D27105B440057680D /* LocationManager+StoreManagerObserver.swift in Sources */,
CD1DDD30260218AE00AC62B2 /* DaysControlView.swift in Sources */,
CD85796D2671FCF700CC4CDA /* ShortsItemCell.swift in Sources */,
CE578FE725FB415F00E8B85D /* LocationsViewModel.swift in Sources */,
......
......@@ -145,6 +145,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
// Initializing Essential Dependencies
EssentialDependencies().resolve()
storeManager.add(observer: LocationManager.shared)
return true
}
......
//
// LocationManager+StoreManagerObserver.swift
// 1Weather
//
// Created by Demid Merzlyakov on 08.10.2021.
//
import Foundation
import OneWeatherCore
extension LocationManager: StoreManagerObserver {
public func storeManagerUpdatedStatus(_ storeManager: StoreManager) {
updateEverythingIfNeeded()
}
}
......@@ -212,7 +212,18 @@ public class LocationManager {
!locations.isEmpty || deviceLocationMonitor.hasLocationPermissions
}
public init(weatherUpdateSource: WeatherSource, healthSource: HealthSource, minutelyForecastSource: MinutelyForecastSource, nwsAlertsManager: NWSAlertsManager, fipsSource: FIPSSource, pushNotificationsManager: PushNotificationsManagerProtocol?, storage: Storage) {
private var featureAvailabilityManager: FeatureAvailabilityManager? {
//TODO: there's a circular dependency between LocationManager and FeatureAvailabilityManager. Got to resolve it. For now leaving it as is.
FeatureAvailabilityManager.shared
}
public init(weatherUpdateSource: WeatherSource,
healthSource: HealthSource,
minutelyForecastSource: MinutelyForecastSource,
nwsAlertsManager: NWSAlertsManager,
fipsSource: FIPSSource,
pushNotificationsManager: PushNotificationsManagerProtocol?,
storage: Storage) {
self.weatherUpdateSource = weatherUpdateSource
self.healthSource = healthSource
self.minutelyForecastSource = minutelyForecastSource
......@@ -376,6 +387,10 @@ public class LocationManager {
}
public func updateMinutelyForecast(for location: Location) {
guard featureAvailabilityManager?.isAvailable(feature: .minutelyForecast) ?? true else {
log.verbose("Minutely forecast unavaillable.")
return
}
if let lastTimeUpdated = location.minutely?.lastUpdateTime {
guard Date().timeIntervalSince(lastTimeUpdated) >= minutelyForecastSource.minutelyUpdateInterval else {
log.verbose("Update minutely forecast (\(location)): fresh enough (last updated at \(lastTimeUpdated)), skip update.")
......
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