Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetpack Social: Hide Jetpack Social for private posts #21362

Merged
merged 1 commit into from
Aug 21, 2023
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 @@ -17,6 +17,7 @@ extension PostSettingsViewController {
&& blogSupportsPublicize
&& blogHasNoConnections
&& blogHasServices
&& !isPostPrivate
}

@objc func createNoConnectionView() -> UIView {
Expand Down Expand Up @@ -45,6 +46,7 @@ extension PostSettingsViewController {
&& blogSupportsPublicize
&& blogHasConnections
&& blogHasSharingLimit
&& !isPostPrivate
}

@objc func createRemainingSharesView() -> UIView {
Expand Down Expand Up @@ -92,6 +94,10 @@ extension PostSettingsViewController {

private extension PostSettingsViewController {

var isPostPrivate: Bool {
apost.status == .publishPrivate
}

func hideNoConnectionViewKey() -> String {
guard let dotComID = apost.blog.dotComID?.stringValue else {
return Constants.hideNoConnectionViewKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,10 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

- (NSInteger)numberOfRowsForShareSection
{
if ([self.apost.status isEqualToString:@"private"]) {
return 0;
}

if (self.apost.blog.supportsPublicize && self.publicizeConnections.count > 0) {
// One row per publicize connection plus an extra row for the publicze message
return self.publicizeConnections.count + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extension PrepublishingViewController {
/// Determines whether the account and the post's blog is eligible to see the Jetpack Social row.
func canDisplaySocialRow(isJetpack: Bool = AppConfiguration.isJetpack,
isFeatureEnabled: Bool = RemoteFeatureFlag.jetpackSocialImprovements.enabled()) -> Bool {
guard isJetpack && isFeatureEnabled else {
guard isJetpack && isFeatureEnabled && !isPostPrivate else {
return false
}

Expand Down Expand Up @@ -86,6 +86,15 @@ private extension PrepublishingViewController {
}
}

var isPostPrivate: Bool {
coreDataStack.performQuery { [postObjectID = post.objectID] context in
guard let post = (try? context.existingObject(with: postObjectID)) as? Post else {
return false
}
return post.status == .publishPrivate
}
}

// MARK: Auto Sharing View

func configureAutoSharingView(for cell: UITableViewCell) {
Expand Down