Skip to content

Commit 797b6e6

Browse files
Merge pull request #474 from woocommerce/issue/434-updating-dashboard-ghosts-behavior
Updating Dashboard Ghosts Behavior
2 parents 8f6240c + b0a9c87 commit 797b6e6

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/DashboardViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class DashboardViewController: UIViewController {
4242
configureView()
4343
}
4444

45-
override func viewDidAppear(_ animated: Bool) {
46-
super.viewDidAppear(animated)
45+
override func viewWillAppear(_ animated: Bool) {
46+
super.viewWillAppear(animated)
4747
reloadData()
4848
}
4949

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() {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ class TopPerformerDataViewController: UIViewController, IndicatorInfoProvider {
1010

1111
// MARK: - Properties
1212

13-
public let granularity: StatGranularity
13+
let granularity: StatGranularity
14+
15+
var hasTopEarnerStatsItems: Bool {
16+
return (topEarnerStats?.items?.count ?? 0) > 0
17+
}
1418

1519
@IBOutlet private weak var tableView: IntrinsicTableView!
1620

@@ -33,10 +37,6 @@ class TopPerformerDataViewController: UIViewController, IndicatorInfoProvider {
3337
return resultsController.fetchedObjects.first
3438
}
3539

36-
private var hasTopEarnerStatsItems: Bool {
37-
return (topEarnerStats?.items?.count ?? 0) > 0
38-
}
39-
4040
private var tabDescription: String {
4141
switch granularity {
4242
case .day:

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ extension TopPerformersViewController {
6262
func syncTopPerformers(onCompletion: (() -> Void)? = nil) {
6363
let group = DispatchGroup()
6464

65-
displayGhostContent()
65+
ensureGhostContentIsDisplayed()
6666

6767
dataVCs.forEach { vc in
6868
group.enter()
@@ -83,6 +83,16 @@ extension TopPerformersViewController {
8383
//
8484
private extension TopPerformersViewController {
8585

86+
/// Displays the Ghost Placeholder whenever there is no visible data.
87+
///
88+
func ensureGhostContentIsDisplayed() {
89+
guard visibleChildViewController.hasTopEarnerStatsItems == false else {
90+
return
91+
}
92+
93+
displayGhostContent()
94+
}
95+
8696
/// Locks UI Interaction and displays Ghost Placeholder animations.
8797
///
8898
func displayGhostContent() {

0 commit comments

Comments
 (0)