Skip to content

Commit b0a9c87

Browse files
committed
StoreStatsViewController: Updating Placeholder's Behavior
1 parent 2692856 commit b0a9c87

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/MyStore/PeriodDataViewController.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ extension PeriodDataViewController {
145145

146146
extension PeriodDataViewController {
147147

148+
/// Indicates if the receiver has Remote Stats, or not.
149+
///
150+
var shouldDisplayGhostContent: Bool {
151+
return orderStats == nil
152+
}
153+
148154
/// Displays the Placeholder Period Graph + Starts the Animation.
149155
/// Why is this public? Because the actual Sync OP is handled by StoreStatsViewController. We coordinate multiple
150156
/// placeholder animations from that spot!

WooCommerce/Classes/ViewRelated/Dashboard/MyStore/StoreStatsViewController.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ extension StoreStatsViewController {
6969
func syncAllStats(onCompletion: (() -> Void)? = nil) {
7070
let group = DispatchGroup()
7171

72-
displayGhostContent()
72+
ensureGhostContentIsDisplayed()
7373

7474
periodVCs.forEach { (vc) in
7575
group.enter()
@@ -97,6 +97,16 @@ extension StoreStatsViewController {
9797
//
9898
private extension StoreStatsViewController {
9999

100+
/// Displays the Ghost Placeholder whenever there is no visible data.
101+
///
102+
func ensureGhostContentIsDisplayed() {
103+
guard visibleChildViewController.shouldDisplayGhostContent else {
104+
return
105+
}
106+
107+
displayGhostContent()
108+
}
109+
100110
/// Locks UI Interaction and displays Ghost Placeholder animations.
101111
///
102112
func displayGhostContent() {

0 commit comments

Comments
 (0)