If the data is relatively new, skip fetching data from remote: if !forceRefresh && DashboardTimestampStore.isTimestampFresh(for: .performance, at: timeRange.timestampRange)
else, start fetching data.
Meanwhile, the viewmodel has the siteVisitStatMode property, which decides whether to show or hide the visit stats:
Back in reloadDataIfNeeded(), the value of siteVisitStatMode is only changed after the skip fetching data logic. In other words, it's only updated if remote fetching is being done:
This created an edge case issue: if the app starts and loads visit data from cache, and the timestamp is fresh enough to skip remote fetching, then the cached data is available but redacted:
This can be replicated by doing so:
Have a demo site with a newly completed Order within this month, so stats can appear
Start app,
Enable Performance card, and set range to This Month.
Wait until data appears properly (Orders, Visitors, and Conversion), then quickly build the app again in Xcode. The rebuild needs to be done as soon as possible after the data appears, so if you're unsure, do pull-to-refresh, wait for data, then rebuild,
This will start the app again. Check how Visitors and Conversions value in Performance card are now redacted.
Expected: Visitors and Conversion values should be shown.
Inside
StorePerformanceViewModel.reloadDataIfNeeded()
, which handles the data loading, the logic is:periodViewModel?.loadCachedContent()
if !forceRefresh && DashboardTimestampStore.isTimestampFresh(for: .performance, at: timeRange.timestampRange)
Meanwhile, the viewmodel has the
siteVisitStatMode
property, which decides whether to show or hide the visit stats:https://github.com/woocommerce/woocommerce-ios/blob/cac1fca1cb771f750171cfc41800f473085e8f94/WooCommerce/Classes/ViewRelated/Dashboard/StoreStats/StorePerformanceViewModel.swift#L36
This property is checked inside
StorePerfomanceView
:https://github.com/woocommerce/woocommerce-ios/blob/cac1fca1cb771f750171cfc41800f473085e8f94/WooCommerce/Classes/ViewRelated/Dashboard/StoreStats/StorePerformanceView.swift#L214-L225
Back in
reloadDataIfNeeded()
, the value ofsiteVisitStatMode
is only changed after the skip fetching data logic. In other words, it's only updated if remote fetching is being done:https://github.com/woocommerce/woocommerce-ios/blob/cac1fca1cb771f750171cfc41800f473085e8f94/WooCommerce/Classes/ViewRelated/Dashboard/StoreStats/StorePerformanceViewModel.swift#L179-L188
This created an edge case issue: if the app starts and loads visit data from cache, and the timestamp is fresh enough to skip remote fetching, then the cached data is available but redacted:
This can be replicated by doing so:
Expected: Visitors and Conversion values should be shown.