diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-06-16 11:41:44 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-06-16 11:41:44 +0200 |
commit | 829f6474ff4cd4e39647bcb5b68b5e5c0fb1b483 (patch) | |
tree | f2deb5f2143b8e8a0aad31c3b0a9ca61efaeb47d /settings | |
parent | 7d8b728066987bd312b3225eff6cff67ca6a610a (diff) | |
parent | 5ca6ec7ead2966a1cad1213d898a326a9e315550 (diff) | |
download | nextcloud-server-829f6474ff4cd4e39647bcb5b68b5e5c0fb1b483.tar.gz nextcloud-server-829f6474ff4cd4e39647bcb5b68b5e5c0fb1b483.zip |
Merge pull request #16856 from owncloud/issue-15851-fetch-updates-after-page-completion
Load the update information asyncroniously to fix the page load speed
Diffstat (limited to 'settings')
-rw-r--r-- | settings/controller/appsettingscontroller.php | 24 | ||||
-rw-r--r-- | settings/js/apps.js | 16 | ||||
-rw-r--r-- | settings/templates/apps.php | 4 |
3 files changed, 31 insertions, 13 deletions
diff --git a/settings/controller/appsettingscontroller.php b/settings/controller/appsettingscontroller.php index f1b62bb1d38..d64c945c02c 100644 --- a/settings/controller/appsettingscontroller.php +++ b/settings/controller/appsettingscontroller.php @@ -147,16 +147,20 @@ class AppSettingsController extends Controller { * Get all available apps in a category * * @param int $category + * @param bool $includeUpdateInfo Should we check whether there is an update + * in the app store? * @return array */ - public function listApps($category = 0) { - if(!is_null($this->cache->get('listApps-'.$category))) { - $apps = $this->cache->get('listApps-'.$category); + public function listApps($category = 0, $includeUpdateInfo = true) { + $cacheName = 'listApps-' . $category . '-' . (int) $includeUpdateInfo; + + if(!is_null($this->cache->get($cacheName))) { + $apps = $this->cache->get($cacheName); } else { switch ($category) { // installed apps case 0: - $apps = $this->getInstalledApps(); + $apps = $this->getInstalledApps($includeUpdateInfo); usort($apps, function ($a, $b) { $a = (string)$a['name']; $b = (string)$b['name']; @@ -168,7 +172,7 @@ class AppSettingsController extends Controller { break; // not-installed apps case 1: - $apps = \OC_App::listAllApps(true); + $apps = \OC_App::listAllApps(true, $includeUpdateInfo); $apps = array_filter($apps, function ($app) { return !$app['active']; }); @@ -189,7 +193,7 @@ class AppSettingsController extends Controller { $apps = array(); } else { // don't list installed apps - $installedApps = $this->getInstalledApps(); + $installedApps = $this->getInstalledApps(false); $installedApps = array_map(function ($app) { if (isset($app['ocsid'])) { return $app['ocsid']; @@ -239,16 +243,18 @@ class AppSettingsController extends Controller { return $app; }, $apps); - $this->cache->set('listApps-'.$category, $apps, 300); + $this->cache->set($cacheName, $apps, 300); return ['apps' => $apps, 'status' => 'success']; } /** + * @param bool $includeUpdateInfo Should we check whether there is an update + * in the app store? * @return array */ - private function getInstalledApps() { - $apps = \OC_App::listAllApps(true); + private function getInstalledApps($includeUpdateInfo = true) { + $apps = \OC_App::listAllApps(true, $includeUpdateInfo); $apps = array_filter($apps, function ($app) { return $app['active']; }); diff --git a/settings/js/apps.js b/settings/js/apps.js index 1d115eb8182..2863e86dba8 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -81,7 +81,7 @@ OC.Settings.Apps = OC.Settings.Apps || { $('#app-category-' + categoryId).addClass('active'); OC.Settings.Apps.State.currentCategory = categoryId; - this._loadCategoryCall = $.ajax(OC.generateUrl('settings/apps/list?category={categoryId}', { + this._loadCategoryCall = $.ajax(OC.generateUrl('settings/apps/list?category={categoryId}&includeUpdateInfo=0', { categoryId: categoryId }), { type:'GET', @@ -123,6 +123,20 @@ OC.Settings.Apps = OC.Settings.Apps || { }, complete: function() { $('#apps-list').removeClass('icon-loading'); + $.ajax(OC.generateUrl('settings/apps/list?category={categoryId}&includeUpdateInfo=1', { + categoryId: categoryId + }), { + type: 'GET', + success: function (apps) { + _.each(apps.apps, function(app) { + if (app.update) { + var $update = $('#app-' + app.id + ' .update'); + $update.removeClass('hidden'); + $update.val(t('settings', 'Update to %s').replace(/%s/g, app.update)); + } + }) + } + }); } }); }, diff --git a/settings/templates/apps.php b/settings/templates/apps.php index 0904f31df4d..c88efb8746a 100644 --- a/settings/templates/apps.php +++ b/settings/templates/apps.php @@ -108,9 +108,7 @@ script( </div> {{/unless}} - {{#if update}} - <input class="update" type="submit" value="<?php p($l->t('Update to %s', array('{{update}}'))); ?>" data-appid="{{id}}" /> - {{/if}} + <input class="update hidden" type="submit" value="<?php p($l->t('Update to %s', array('{{update}}'))); ?>" data-appid="{{id}}" /> {{#if active}} <input class="enable" type="submit" data-appid="{{id}}" data-active="true" value="<?php p($l->t("Disable"));?>"/> <input type="checkbox" class="groups-enable" id="groups_enable-{{id}}"/> |