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

Email stats: hide when post was not sent #97739

Merged
merged 1 commit into from
Dec 23, 2024
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 @@ -18,6 +18,7 @@ type PostThumbnail = {

type Post = {
date: string | null;
dont_email_post_to_subs: boolean | null;
title: string;
type: string | null;
like_count: number | null;
Expand Down Expand Up @@ -80,10 +81,11 @@ export default function PostDetailHighlightsSection( {
);

// postId > 0: Show the tabs for posts except for the Home Page (postId = 0).
// TODO: remove the (post?.date && new Date(post?.date) >= new Date("2023-05-30")) check when the Newsletter Stats data is backfilled.
const isEmailTabsAvailable =
postId > 0 &&
! post?.dont_email_post_to_subs &&
post?.date &&
// The Newsletter Stats data was never backfilled (internal ref pdDOJh-1Uy-p2).
new Date( post?.date ) >= new Date( '2023-05-30' ) &&
supportsEmailStats;

Expand Down
6 changes: 6 additions & 0 deletions client/my-sites/stats/stats-post-detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class StatsPostDetail extends Component {
return null;
}

hasDontSendEmailPostToSubs( metadata ) {
return metadata?.some( ( { key } ) => key === '_jetpack_dont_email_post_to_subs' );
}

getPost() {
const { isPostHomepage, post, postFallback, countLikes } = this.props;

Expand All @@ -120,6 +124,7 @@ class StatsPostDetail extends Component {
return {
...postBase,
date: post?.date,
dont_email_post_to_subs: this.hasDontSendEmailPostToSubs( post?.metadata ),
post_thumbnail: post?.post_thumbnail,
comment_count: post?.discussion?.comment_count,
type: post?.type,
Expand All @@ -131,6 +136,7 @@ class StatsPostDetail extends Component {
return {
...postBase,
date: postFallback?.post_date_gmt,
dont_email_post_to_subs: this.hasDontSendEmailPostToSubs( post?.metadata ),
post_thumbnail: null,
comment_count: parseInt( postFallback?.comment_count, 10 ),
type: postFallback?.post_type,
Expand Down
Loading