Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class DashboardViewController: UIViewController {
configureView()
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
reloadData()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ extension PeriodDataViewController {

extension PeriodDataViewController {

/// Indicates if the receiver has Remote Stats, or not.
///
var shouldDisplayGhostContent: Bool {
return orderStats == nil
}

/// Displays the Placeholder Period Graph + Starts the Animation.
/// Why is this public? Because the actual Sync OP is handled by StoreStatsViewController. We coordinate multiple
/// placeholder animations from that spot!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extension StoreStatsViewController {
func syncAllStats(onCompletion: (() -> Void)? = nil) {
let group = DispatchGroup()

displayGhostContent()
ensureGhostContentIsDisplayed()

periodVCs.forEach { (vc) in
group.enter()
Expand Down Expand Up @@ -97,6 +97,16 @@ extension StoreStatsViewController {
//
private extension StoreStatsViewController {

/// Displays the Ghost Placeholder whenever there is no visible data.
///
func ensureGhostContentIsDisplayed() {
guard visibleChildViewController.shouldDisplayGhostContent else {
return
}

displayGhostContent()
}

/// Locks UI Interaction and displays Ghost Placeholder animations.
///
func displayGhostContent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ class TopPerformerDataViewController: UIViewController, IndicatorInfoProvider {

// MARK: - Properties

public let granularity: StatGranularity
let granularity: StatGranularity

var hasTopEarnerStatsItems: Bool {
return (topEarnerStats?.items?.count ?? 0) > 0
}

@IBOutlet private weak var tableView: IntrinsicTableView!

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

private var hasTopEarnerStatsItems: Bool {
return (topEarnerStats?.items?.count ?? 0) > 0
}

private var tabDescription: String {
switch granularity {
case .day:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension TopPerformersViewController {
func syncTopPerformers(onCompletion: (() -> Void)? = nil) {
let group = DispatchGroup()

displayGhostContent()
ensureGhostContentIsDisplayed()

dataVCs.forEach { vc in
group.enter()
Expand All @@ -83,6 +83,16 @@ extension TopPerformersViewController {
//
private extension TopPerformersViewController {

/// Displays the Ghost Placeholder whenever there is no visible data.
///
func ensureGhostContentIsDisplayed() {
guard visibleChildViewController.hasTopEarnerStatsItems == false else {
return
}

displayGhostContent()
}

/// Locks UI Interaction and displays Ghost Placeholder animations.
///
func displayGhostContent() {
Expand Down