Skip to content

Commit 3119e75

Browse files
Merge pull request #19200 from wordpress-mobile/issue/13370-jetpack-stats-file-downloads
Stats: Hide file downloads stats section for Jetpack sites
2 parents f401fbe + 06cc1d9 commit 3119e75

6 files changed

Lines changed: 19 additions & 10 deletions

File tree

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* [*] [Jetpack-only] Recommend App: you can now share the Jetpack app with your friends. [#19174]
44
* [*] [Jetpack-only] Feature Announcements: new features are highlighted via the What's New modals. [#19176]
55
* [*] Pages List: Fixed an issue where the app would freeze when opening the pages list if one of the featured images is a GIF. [#19184]
6+
* [*] Stats: Fixed an issue where File Downloads section was being displayed for Jetpack sites even though it's not supported. [#19200]
67

78

89
20.5

WordPress/Classes/Models/Blog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ typedef NS_ENUM(NSUInteger, BlogFeature) {
9595
BlogFeatureLoomEmbed,
9696
/// Does the blog support Smartframe embed block?
9797
BlogFeatureSmartframeEmbed,
98+
/// Does the blog support File Downloads section in stats?
99+
BlogFeatureFileDownloadsStats,
98100

99101
};
100102

WordPress/Classes/Models/Blog.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,8 @@ - (BOOL)supports:(BlogFeature)feature
596596
return [self supportsEmbedVariation: @"9.0"];
597597
case BlogFeatureSmartframeEmbed:
598598
return [self supportsEmbedVariation: @"10.2"];
599+
case BlogFeatureFileDownloadsStats:
600+
return [self isHostedAtWPcom];
599601
}
600602
}
601603

WordPress/Classes/ViewRelated/Stats/Helpers/SiteStatsInformation.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Foundation
1313
@objc var siteID: NSNumber?
1414
@objc var siteTimeZone: TimeZone?
1515
@objc var oauth2Token: String?
16+
@objc var supportsFileDownloads: Bool = true
1617

1718
func updateTimeZone() {
1819
let context = ContextManager.shared.mainContext

WordPress/Classes/ViewRelated/Stats/Period Stats/SiteStatsPeriodViewModel.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,18 @@ class SiteStatsPeriodViewModel: Observable {
195195
}, error: {
196196
return errorBlock(.periodVideos)
197197
}))
198-
tableRows.append(contentsOf: blocks(for: .topFileDownloads,
199-
type: .period,
200-
status: store.topFileDownloadsStatus,
201-
block: { [weak self] in
202-
return self?.fileDownloadsTableRows() ?? errorBlock(.periodFileDownloads)
203-
}, loading: {
204-
return loadingBlock(.periodFileDownloads)
205-
}, error: {
206-
return errorBlock(.periodFileDownloads)
207-
}))
198+
if SiteStatsInformation.sharedInstance.supportsFileDownloads {
199+
tableRows.append(contentsOf: blocks(for: .topFileDownloads,
200+
type: .period,
201+
status: store.topFileDownloadsStatus,
202+
block: { [weak self] in
203+
return self?.fileDownloadsTableRows() ?? errorBlock(.periodFileDownloads)
204+
}, loading: {
205+
return loadingBlock(.periodFileDownloads)
206+
}, error: {
207+
return errorBlock(.periodFileDownloads)
208+
}))
209+
}
208210

209211
tableRows.append(TableFooterRow())
210212

WordPress/Classes/ViewRelated/Stats/StatsViewController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ - (void)initStats
130130

131131
SiteStatsInformation.sharedInstance.oauth2Token = self.blog.account.authToken;
132132
SiteStatsInformation.sharedInstance.siteID = self.blog.dotComID;
133+
SiteStatsInformation.sharedInstance.supportsFileDownloads = [self.blog supports:BlogFeatureFileDownloadsStats];
133134

134135
[self addStatsViewControllerToView];
135136
[self initializeStatsWidgetsIfNeeded];

0 commit comments

Comments
 (0)