Skip to content

Commit a6ae587

Browse files
committed
Reloads the store info widget after reloading stats in the app
1 parent 5323ed6 commit a6ae587

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

WooCommerce/Classes/System/WooConstants.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ enum WooConstants {
4949
/// before an app review prompt appears
5050
///
5151
static let systemEventCount = 10
52+
53+
/// Store Info Widget Identifier.
54+
///
55+
static let storeInfoWidgetKind = "StoreInfoWidget"
5256
}
5357

5458
// MARK: URLs

WooCommerce/Classes/ViewRelated/Dashboard/Stats v4/StoreStatsAndTopPerformersViewController.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Combine
22
import UIKit
33
import XLPagerTabStrip
44
import Yosemite
5+
import class WidgetKit.WidgetCenter
56

67
/// Top-level stats container view controller that consists of a button bar with 4 time ranges.
78
/// Each time range tab is managed by a `StoreStatsAndTopPerformersPeriodViewController`.
@@ -298,6 +299,12 @@ private extension StoreStatsAndTopPerformersViewController {
298299
// Update last successful data sync timestamp
299300
if periodSyncError == nil {
300301
vc.lastFullSyncTimestamp = Date()
302+
303+
// Reload the Store Info Widget after syncing the today's stats.
304+
if vc.timeRange == .today {
305+
WidgetCenter.shared.reloadTimelines(ofKind: WooConstants.storeInfoWidgetKind)
306+
}
307+
301308
} else {
302309
syncError = periodSyncError
303310
}

WooCommerce/StoreWidgets/StoreInfoWidget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct StoreInfoWidget: Widget {
1010
let enableWidgets = DefaultFeatureFlagService().isFeatureFlagEnabled(.storeWidgets)
1111

1212
var body: some WidgetConfiguration {
13-
StaticConfiguration(kind: "StoreInfoWidget", provider: StoreInfoProvider()) { entry in
13+
StaticConfiguration(kind: WooConstants.storeInfoWidgetKind, provider: StoreInfoProvider()) { entry in
1414
Group {
1515
switch entry {
1616
case .notConnected:

0 commit comments

Comments
 (0)