[BUGFIX] Create proper array of cached icons 69/44069/3
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Wed, 14 Oct 2015 22:10:52 +0000 (00:10 +0200)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 16 Oct 2015 09:05:27 +0000 (11:05 +0200)
Change the handling of fetching cached icons to create a proper
array containing only one object instead of having an object
per icon.

Resolves: #70730
Related: #70583
Releases: master
Change-Id: I863504bf4178367551849fbc5e82541a252318f7
Reviewed-on: http://review.typo3.org/44069
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/backend/Resources/Public/JavaScript/Icons.js

index aae5f6d..8490d97 100644 (file)
@@ -67,7 +67,8 @@ define(['jquery'], function($) {
         */
        Icons.fetch = function(icons) {
                var promises = [],
-                       requestedIcons = {};
+                       requestedIcons = {},
+                       cachedRequestedIcons = {};
 
                for (var i = 0; i < icons.length; ++i) {
                        /**
@@ -84,7 +85,7 @@ define(['jquery'], function($) {
 
                        var cacheIdentifier = icon.join('_');
                        if (Icons.isCached(cacheIdentifier)) {
-                               promises.push(Icons.getFromCache(cacheIdentifier));
+                               $.extend(cachedRequestedIcons, Icons.getFromCache(cacheIdentifier));
                        } else {
                                requestedIcons[icon[0]] = {
                                        cacheIdentifier: cacheIdentifier,
@@ -93,6 +94,10 @@ define(['jquery'], function($) {
                        }
                }
 
+               if (Object.keys(cachedRequestedIcons).length > 0) {
+                       promises.push(cachedRequestedIcons);
+               }
+
                if (Object.keys(requestedIcons).length > 0) {
                        promises.push(
                                $.ajax({