Skip to content

Commit eedc08e

Browse files
committed
Replace store TZ with device TZ in widgets API requests
1 parent 49687de commit eedc08e

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

WooCommerce/StoreWidgets/StoreInfoDataService.swift

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,10 @@ final class StoreInfoDataService {
2525
///
2626
private var network: AlamofireNetwork
2727

28-
/// Timezone of the website
29-
///
30-
private let siteTimeZone: TimeZone
31-
32-
init(authToken: String, siteTimeZone: TimeZone) {
28+
init(authToken: String) {
3329
network = AlamofireNetwork(credentials: Credentials(authToken: authToken))
3430
orderStatsRemoteV4 = OrderStatsRemoteV4(network: network)
3531
siteVisitStatsRemote = SiteVisitStatsRemote(network: network)
36-
self.siteTimeZone = siteTimeZone
3732
}
3833

3934
/// Async function that fetches todays stats data.
@@ -63,12 +58,12 @@ private extension StoreInfoDataService {
6358
///
6459
func fetchTodaysRevenueAndOrders(for storeID: Int64) async throws -> OrderStatsV4 {
6560
try await withCheckedThrowingContinuation { continuation in
66-
// `WKWebView` is accessed internally, we are foreced to dispatch the call in the main thread.
61+
// `WKWebView` is accessed internally, we are forced to dispatch the call in the main thread.
6762
Task { @MainActor in
6863
orderStatsRemoteV4.loadOrderStats(for: storeID,
6964
unit: .hourly,
70-
earliestDateToInclude: Date().startOfDay(timezone: siteTimeZone),
71-
latestDateToInclude: Date().endOfDay(timezone: siteTimeZone),
65+
earliestDateToInclude: Date().startOfDay(timezone: .current),
66+
latestDateToInclude: Date().endOfDay(timezone: .current),
7267
quantity: 24,
7368
forceRefresh: true) { result in
7469
continuation.resume(with: result)
@@ -85,7 +80,7 @@ private extension StoreInfoDataService {
8580
Task { @MainActor in
8681
siteVisitStatsRemote.loadSiteVisitorStats(for: storeID,
8782
unit: .day,
88-
latestDateToInclude: Date().endOfDay(timezone: siteTimeZone),
83+
latestDateToInclude: Date().endOfDay(timezone: .current),
8984
quantity: 1) { result in
9085
continuation.resume(with: result)
9186
}

WooCommerce/StoreWidgets/StoreInfoProvider.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ final class StoreInfoProvider: TimelineProvider {
7979
return completion(Timeline<StoreInfoEntry>(entries: [StoreInfoEntry.notConnected], policy: .never))
8080
}
8181

82-
let strongService = StoreInfoDataService(authToken: dependencies.authToken, siteTimeZone: dependencies.storeTimeZone)
82+
let strongService = StoreInfoDataService(authToken: dependencies.authToken)
8383
networkService = strongService
8484
Task {
8585
do {

0 commit comments

Comments
 (0)