From 2906ea3d78d2ff8ebfa3ceebe1c8cb5afa43225a Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Thu, 20 Oct 2011 23:02:38 +0200 Subject: [PATCH] Add caching for filelist sharing icon status to avoid many http req. --- apps/files_sharing/js/share.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index aaffc3824e..c0fc91e92a 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -1,8 +1,11 @@ $(document).ready(function() { + var shared_status = {}; if (typeof FileActions !== 'undefined') { FileActions.register('all', 'Share', function(filename) { var icon; var file = $('#dir').val()+'/'+filename; + if(shared_status[file]) + return shared_status[file].icon; $.ajax({ type: 'GET', url: OC.linkTo('files_sharing', 'ajax/getitem.php'), @@ -20,6 +23,7 @@ $(document).ready(function() { } else { icon = OC.imagePath('core', 'actions/share'); } + shared_status[file]= { timestamp: new Date().getTime(), icon: icon }; } }); return icon; @@ -54,6 +58,7 @@ $(document).ready(function() { $(this).click(function(event) { if (!($(event.target).hasClass('drop')) && $(event.target).parents().index($('#dropdown')) == -1) { if ($('#dropdown').is(':visible')) { + delete shared_status[$('#dropdown').data('file')]; //Remove File from icon cache $('#dropdown').hide('blind', function() { $('#dropdown').remove(); $('tr').removeClass('mouseOver');