Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions WordPress/Classes/Models/Blog.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
@class UserSuggestion;
@class SiteSuggestion;
@class PageTemplateCategory;
@class JetpackFeaturesRemovalCoordinator;

extern NSString * const BlogEntityName;
extern NSString * const PostFormatStandard;
Expand Down
3 changes: 2 additions & 1 deletion WordPress/Classes/Models/Blog.m
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,8 @@ - (BOOL)supportsPluginManagement
- (BOOL)supportsStories
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally considered checking the isPad and feature removal conditions in a specific helper within the StoryAction class. But I finally ended up using the supports functionality of the Blog model as the logic seemed closer to me. In any case, please let me know if there's a better approach for this, thanks!

{
BOOL hasRequiredJetpack = [self hasRequiredJetpackVersion:@"9.1"];
return hasRequiredJetpack || self.isHostedAtWPcom;
// Stories are disabled in iPad until this Kanvas issue is solved: https://github.com/tumblr/kanvas-ios/issues/104
return (hasRequiredJetpack || self.isHostedAtWPcom) && ![UIDevice isPad] && ![JetpackFeaturesRemovalCoordinator shouldRemoveJetpackFeatures];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that we weren't using the same conditions for determining if the Story Post action should be shown in different places. For this reason, I decided to unify the logic into a single function. Specifically, checking if the device is an iPad. Based on this PR and this Kanvas issue, I understand that the Story post shouldn't be enabled on iPad.

}

- (BOOL)supportsContactInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension MySiteViewController {

var actions: [ActionSheetItem] = []

if shouldShowNewStory {
if blog?.supports(.stories) ?? false {
actions.append(StoryAction(handler: newStory, source: source))
}

Expand All @@ -38,8 +38,4 @@ extension MySiteViewController {
let coordinator = CreateButtonCoordinator(self, actions: actions, source: source, blog: blog)
return coordinator
}

private var shouldShowNewStory: Bool {
return (blog?.supports(.stories) ?? false) && !UIDevice.isPad()
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

/// A class containing convenience methods for the the Jetpack features removal experience
class JetpackFeaturesRemovalCoordinator {
class JetpackFeaturesRemovalCoordinator: NSObject {

/// Enum descibing the current phase of the Jetpack features removal
enum GeneralPhase: String {
Expand Down Expand Up @@ -108,6 +108,7 @@ class JetpackFeaturesRemovalCoordinator {
}

/// Used to determine if the Jetpack features should be removed based on the removal phase.
@objc
static func shouldRemoveJetpackFeatures() -> Bool {
switch generalPhase() {
case .four, .newUsers:
Expand Down