@@ -109,7 +109,6 @@ private extension StoreStatsAndTopPerformersViewController {
109109 defer {
110110 group. notify ( queue: . main) { [ weak self] in
111111 self ? . isSyncing = false
112- self ? . removeGhostContent ( )
113112 self ? . showSpinner ( shouldShowSpinner: false )
114113 if let error = syncError {
115114 DDLogError ( " ⛔️ Error loading dashboard: \( error) " )
@@ -150,8 +149,12 @@ private extension StoreStatsAndTopPerformersViewController {
150149 // For tasks dispatched for each time period.
151150 let periodGroup = DispatchGroup ( )
152151
152+ // For tasks dispatched for store stats (order and visitor stats) for each time period.
153+ let periodStoreStatsGroup = DispatchGroup ( )
154+
153155 group. enter ( )
154156 periodGroup. enter ( )
157+ periodStoreStatsGroup. enter ( )
155158 self . syncStats ( for: siteID,
156159 siteTimezone: timezoneForSync,
157160 timeRange: vc. timeRange,
@@ -165,10 +168,12 @@ private extension StoreStatsAndTopPerformersViewController {
165168 }
166169 group. leave ( )
167170 periodGroup. leave ( )
171+ periodStoreStatsGroup. leave ( )
168172 }
169173
170174 group. enter ( )
171175 periodGroup. enter ( )
176+ periodStoreStatsGroup. enter ( )
172177 self . syncSiteVisitStats ( for: siteID,
173178 siteTimezone: timezoneForSync,
174179 timeRange: vc. timeRange,
@@ -179,6 +184,7 @@ private extension StoreStatsAndTopPerformersViewController {
179184 }
180185 group. leave ( )
181186 periodGroup. leave ( )
187+ periodStoreStatsGroup. leave ( )
182188 }
183189
184190 group. enter ( )
@@ -193,6 +199,8 @@ private extension StoreStatsAndTopPerformersViewController {
193199 }
194200 group. leave ( )
195201 periodGroup. leave ( )
202+
203+ vc. removeTopPerformersGhostContent ( )
196204 }
197205
198206 periodGroup. notify ( queue: . main) {
@@ -203,6 +211,10 @@ private extension StoreStatsAndTopPerformersViewController {
203211 syncError = periodSyncError
204212 }
205213 }
214+
215+ periodStoreStatsGroup. notify ( queue: . main) {
216+ vc. removeStoreStatsGhostContent ( )
217+ }
206218 }
207219 }
208220
@@ -224,27 +236,12 @@ private extension StoreStatsAndTopPerformersViewController {
224236 /// Displays the Ghost Placeholder whenever there is no visible data.
225237 ///
226238 func ensureGhostContentIsDisplayed( ) {
227- guard visibleChildViewController. shouldDisplayStoreStatsGhostContent else {
228- return
239+ periodVCs. forEach { periodVC in
240+ guard periodVC. shouldDisplayStoreStatsGhostContent else {
241+ return
242+ }
243+ periodVC. displayGhostContent ( )
229244 }
230-
231- displayGhostContent ( )
232- }
233-
234- /// Locks UI Interaction and displays Ghost Placeholder animations.
235- ///
236- func displayGhostContent( ) {
237- view. isUserInteractionEnabled = false
238- buttonBarView. startGhostAnimation ( style: . wooDefaultGhostStyle)
239- visibleChildViewController. displayGhostContent ( )
240- }
241-
242- /// Unlocks the and removes the Placeholder Content
243- ///
244- func removeGhostContent( ) {
245- view. isUserInteractionEnabled = true
246- buttonBarView. stopGhostAnimation ( )
247- visibleChildViewController. removeGhostContent ( )
248245 }
249246
250247 /// If the Ghost Content was previously onscreen, this method will restart the animations.
0 commit comments