diff --git a/assets/js/src/mailpoet.js b/assets/js/src/mailpoet.js index 5f3ce4e845..cc9e5c36d4 100644 --- a/assets/js/src/mailpoet.js +++ b/assets/js/src/mailpoet.js @@ -21,6 +21,7 @@ var MailPoet = { apiVersion: window.mailpoet_api_version, emailRegex: window.mailpoet_email_regex, wpSegmentState: window.mailpoet_wp_segment_state, + subscribersCountsCacheCreatedAt: window.mailpoet_subscribers_counts_cache_created_at, getShortcodeLinks: () => (window.mailpoet_shortcode_links ? window.mailpoet_shortcode_links : []), }; diff --git a/assets/js/src/segments/heading.jsx b/assets/js/src/segments/heading.jsx index f81155a240..3d4446882f 100644 --- a/assets/js/src/segments/heading.jsx +++ b/assets/js/src/segments/heading.jsx @@ -26,7 +26,9 @@ const ListHeading = () => ( subscribersInPlanLimit={MailPoet.subscribersLimit} /> - + pageRenderer = $pageRenderer; $this->listingPageLimit = $listingPageLimit; @@ -75,6 +81,7 @@ class Segments { $this->segmentDependencyValidator = $segmentDependencyValidator; $this->customFieldsRepository = $customFieldsRepository; $this->customFieldsResponseBuilder = $customFieldsResponseBuilder; + $this->transientCache = $transientCache; } public function render() { @@ -123,7 +130,9 @@ class Segments { $wooCurrencySymbol = $this->woocommerceHelper->isWooCommerceActive() ? $this->woocommerceHelper->getWoocommerceCurrencySymbol() : ''; $data['woocommerce_currency_symbol'] = html_entity_decode($wooCurrencySymbol); $data['tracking_enabled'] = $this->settings->get('tracking.enabled'); - + $subscribersCacheCreatedAt = $this->transientCache->getOldestCreatedAt(TransientCache::SUBSCRIBERS_STATISTICS_COUNT_KEY); + $subscribersCacheCreatedAt = $subscribersCacheCreatedAt ?: Carbon::now(); + $data['subscribers_counts_cache_created_at'] = $subscribersCacheCreatedAt->format('Y-m-d\TH:i:sO'); $this->pageRenderer->displayPage('segments.html', $data); } } diff --git a/views/segments.html b/views/segments.html index b6714c02f5..c517239d44 100644 --- a/views/segments.html +++ b/views/segments.html @@ -33,6 +33,7 @@ var mailpoet_woocommerce_currency_symbol = <%= json_encode(woocommerce_currency_symbol) %>; var mailpoet_woocommerce_countries = <%= json_encode(woocommerce_countries) %>; var mailpoet_tracking_enabled = <%= json_encode(tracking_enabled) %>; + var mailpoet_subscribers_counts_cache_created_at = <%= json_encode(subscribers_counts_cache_created_at) %>; <% endblock %>