updated recomendation section render process
This commit is contained in:
@@ -3320,9 +3320,9 @@ exit;
|
||||
* @param int $timeout
|
||||
* @return bool
|
||||
*/
|
||||
public static function isFresh($file, $timeout = _TIME_1_WEEK_)
|
||||
public static function isFresh($file, $timeout = _TIME_1_WEEK_, $check_size = true)
|
||||
{
|
||||
if (($time = @filemtime(_PS_ROOT_DIR_.$file)) && filesize(_PS_ROOT_DIR_.$file) > 0) {
|
||||
if (($time = @filemtime(_PS_ROOT_DIR_.$file)) && ($check_size ? filesize(_PS_ROOT_DIR_.$file) > 0: true)) {
|
||||
return ((time() - $time) < $timeout);
|
||||
}
|
||||
|
||||
|
||||
@@ -496,7 +496,7 @@ class AdminDashboardControllerCore extends AdminController
|
||||
|
||||
public function getRecommendationContent()
|
||||
{
|
||||
if (!Tools::isFresh(self::DASHBOARD_RECOMMENDATION_CONTENT, _TIME_1_DAY_)) {
|
||||
if (!Tools::isFresh(self::DASHBOARD_RECOMMENDATION_CONTENT, _TIME_1_DAY_, false)) {
|
||||
@file_put_contents(_PS_ROOT_DIR_.self::DASHBOARD_RECOMMENDATION_CONTENT, Tools::addonsRequest('dashboard-recommendation'));
|
||||
}
|
||||
if (file_exists(_PS_ROOT_DIR_.self::DASHBOARD_RECOMMENDATION_CONTENT)) {
|
||||
|
||||
@@ -242,7 +242,7 @@ class AdminModulesCatalogControllerCore extends AdminController
|
||||
|
||||
public function getRecommendationContent()
|
||||
{
|
||||
if (!Tools::isFresh(self::CATALOG_RECOMMENDATION_CONTENT, _TIME_1_DAY_)) {
|
||||
if (!Tools::isFresh(self::CATALOG_RECOMMENDATION_CONTENT, _TIME_1_DAY_, false)) {
|
||||
@file_put_contents(_PS_ROOT_DIR_.self::CATALOG_RECOMMENDATION_CONTENT, Tools::addonsRequest('catalog-recommendation'));
|
||||
}
|
||||
if (file_exists(_PS_ROOT_DIR_.self::CATALOG_RECOMMENDATION_CONTENT)) {
|
||||
|
||||
17
js/admin.js
17
js/admin.js
@@ -1622,12 +1622,17 @@ function loadRecommendation()
|
||||
let images = $('#recommendation-wrapper img');
|
||||
let loaded = 0;
|
||||
let total = $(images).length;
|
||||
$(images).on('load', function() {
|
||||
if (++loaded === total) {
|
||||
$('#recommendation-wrapper-skeleton').fadeOut('slow').hide();
|
||||
$('#recommendation-wrapper').fadeIn();
|
||||
}
|
||||
});
|
||||
if (images.length) {
|
||||
$(images).on('load', function() {
|
||||
if (++loaded === total) {
|
||||
$('#recommendation-wrapper-skeleton').fadeOut('slow').hide();
|
||||
$('#recommendation-wrapper').fadeIn();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('#recommendation-wrapper-skeleton').fadeOut('slow').hide();
|
||||
$('#recommendation-wrapper').fadeIn();
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(res) {
|
||||
|
||||
Reference in New Issue
Block a user