Commit cdd773d7 by Dmitry Stepanets

[IOS-259]: Fixed incorrect events order for widgets

parent c464fb65
......@@ -91,11 +91,11 @@
<EnvironmentVariable
key = "_XCWidgetDefaultView"
value = "timeline"
isEnabled = "NO">
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "_XCWidgetFamily"
value = "medium"
value = "small"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
......
......@@ -15,7 +15,7 @@ protocol TodayCoordinatorDelegate: AnyObject {
class TodayCoordinator: Coordinator {
// MARK: - Private
private let navigationController = ColoredNavigationController(nibName: nil, bundle: nil)
private var tabBarController:UITabBarController?
private var tabBarController: UITabBarController?
var todayViewController: TodayViewController?
// MARK: - Public
......
......@@ -14,7 +14,6 @@ import OneWeatherAnalytics
public class PushNotificationsManager: NSObject, PushNotificationsManagerProtocol {
// MARK: - Private
private let log = Logger(componentName: "PushNotificationsManager")
private let configManager: ConfigManager
......
......@@ -111,7 +111,7 @@ public class WidgetManager {
private let smartTextProvider = SmartTextProvider(prioritizedSmartTexts: SmartTextProvider.defaultSmartTexts)
private var widgetOptions: WidgetOptions = []
public func refreshAnalytics() {
public func refreshAnalytics(completion: (() -> Void)? = nil) {
WidgetCenter.shared.getCurrentConfigurations {[weak self] result in
switch result {
case .success(let widgetInfo):
......@@ -119,6 +119,7 @@ public class WidgetManager {
case .failure(let error):
self?.log.error(error.localizedDescription)
}
completion?()
}
}
......@@ -156,8 +157,7 @@ public class WidgetManager {
}
}
AppAnalytics.shared.log(event: .ANALYTICS_WIDGET_UPDATED,
params: params)
AppAnalytics.shared.log(event: .ANALYTICS_WIDGET_UPDATED, params: params)
}
}
......
......@@ -43,6 +43,7 @@ class WeatherProvider: TimelineProvider {
locationSource.getUpToDateLocation { [weak self] location in
guard let self = self else { return }
var needToLogUpdate = false
if
let fetchedLocation = location,
let coordinates = fetchedLocation.coordinates
......@@ -55,9 +56,7 @@ class WeatherProvider: TimelineProvider {
let nextRefresh = Calendar.current.date(byAdding: .minute, value: 30, to: Date())!
let entry = WeatherEntry(location: fetchedLocation, date: nextRefresh, radarMapImage: mapImage)
let timeline = Timeline(entries: [entry], policy: .atEnd)
if !context.isPreview {
WidgetManager.shared.logUpdate(forLocation: location, kind: self.widgetKind, family: context.family)
}
needToLogUpdate = true
completion(timeline)
}
}
......@@ -78,10 +77,11 @@ class WeatherProvider: TimelineProvider {
}
if !context.isPreview {
WidgetManager.shared.refreshAnalytics()
if needToLogUpdate {
WidgetManager.shared.logUpdate(forLocation: location, kind: self.widgetKind, family: context.family)
}
WidgetManager.shared.refreshAnalytics(completion: {
if needToLogUpdate {
WidgetManager.shared.logUpdate(forLocation: location, kind: self.widgetKind, family: context.family)
}
})
}
}
}
......
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