From 7b87e00db1314a72d0878492a0cdda3d88182b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 3 Jul 2018 12:14:34 +0200 Subject: [PATCH] Properly insert app icons into navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the app menu is rebuild with the first icon being updated, the whole list was empty, therefore we need a fallback to properly insert the element then. Fixes https://github.com/nextcloud/dashboard/issues/10 Signed-off-by: Julius Härtl --- settings/js/apps.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/settings/js/apps.js b/settings/js/apps.js index e860f1dbed..c9b1ea6b8d 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -6,7 +6,7 @@ OC.Settings.Apps = OC.Settings.Apps || { if(response.ocs.meta.status === 'ok') { var addedApps = {}; var navEntries = response.ocs.data; - var container = $('#apps ul'); + var container = $('#navigation #apps'); // remove disabled apps for (var i = 0; i < navEntries.length; i++) { @@ -43,7 +43,13 @@ OC.Settings.Apps = OC.Settings.Apps || { a.prepend(img); li.append(a); - $('#navigation li[data-id=' + previousEntry.id + ']').after(li); + // add app icon to the navigation + var previousElement = $('#navigation li[data-id=' + previousEntry.id + ']'); + if (previousElement.length > 0) { + previousElement.after(li); + } else { + $('#navigation #apps').prepend(li); + } // draw attention to the newly added app entry // by flashing twice the more apps menu @@ -73,7 +79,15 @@ OC.Settings.Apps = OC.Settings.Apps || { a.prepend(loading); a.prepend(img); li.append(a); - $('#appmenu li[data-id='+ previousEntry.id+']').after(li); + + // add app icon to the navigation + var previousElement = $('#appmenu li[data-id=' + previousEntry.id + ']'); + if (previousElement.length > 0) { + previousElement.after(li); + } else { + $('#appmenu').prepend(li); + } + if(addedApps[entry.id]) { li.animate({opacity: 0.5}) .animate({opacity: 1})