Performance Card Unable to Fetch Cached Site Summary Data When Site and Device Timezone differs #14462
Labels
feature: dashboard
Related to the My Store dashboard
priority: low
Not many people are affected or there’s a workaround, etc.
type: bug
A confirmed bug.
This issue is discovered when testing #14438 and is affecting
trunk
too.The trigger is:
Expected: Performance card should be able to show the cached data that's downloaded on step 3-4.
The issue does not seem to appear when site and device timezone are the same, but I can't really tell how different the timezones should be to trigger the issue. So, this might be an edge case as I don't think we've heard report about it.
Investigation.
This is what I can investigate so far.
When logging in to a new site for the first time, as
DashboardViewModel
is being initialized, it also initializesself.storePerformanceViewModel
.StorePerformanceViewModel
then initializes itssiteTimezone: TimeZone = .siteTimezone,
which calls this:woocommerce-ios/WooCommerce/Classes/Extensions/TimeZone+Woo.swift
Lines 6 to 12 in e3571f9
In my test,
defaultSite
is still nil (perhaps because it's still early in the process), soStorePerformanceViewModel
uses device timezone instead (UTC+7 in my case). The part that sets the predicate for fetching cached data then uses this timezone:woocommerce-ios/WooCommerce/Classes/ViewRelated/Dashboard/StoreStats/StoreStatsPeriodViewModel.swift
Lines 106 to 113 in e3571f9
The card then fetches and saves "Day" time range data by default. As we change the time range "This Year", the app then proceeds to fetch and save it, still using the device timezone. The data is saved with
"2024-12-31"
in itsdate
value.Now, on Step 5 after the app is rebuilt,
defaultSite
is now available. AsStorePerformanceViewModel
is recreated, it now uses the site's timezone (UTC-6 in my case). I can't figure out why yet, but this causes theformattedDateString
insummaryStatsResultsController
above to be off by one,"2025-01-01"
. As the saved data's value is"2024-12-31"
, the app now is unable to show the cached data.The text was updated successfully, but these errors were encountered: