diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-09-19 14:46:33 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-09-19 14:46:33 +0200 |
commit | 98ff8478301676c99ffefd5756ad22466dfb6acf (patch) | |
tree | 767517d57c8c2ac28672e2ac86a27bd71d613738 /apps | |
parent | 078bf0df2583a8a93f2fe8df15cf29f14c4ee02b (diff) | |
download | nextcloud-server-98ff8478301676c99ffefd5756ad22466dfb6acf.tar.gz nextcloud-server-98ff8478301676c99ffefd5756ad22466dfb6acf.zip |
fix race condition in lazy preview loading
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/js/files.js | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index ccb40e7216f..5ec65d87457 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -628,18 +628,24 @@ function getPathForPreview(name) { } function lazyLoadPreview(path, mime, ready, width, height) { - getMimeIcon(mime,ready); - if (!width) { - width = $('#filestable').data('preview-x'); - } - if (!height) { - height = $('#filestable').data('preview-y'); - } - var previewURL = OC.Router.generate('core_ajax_preview', {file: encodeURIComponent(path), x:width, y:height}); - $.get(previewURL, function() { - previewURL = previewURL.replace('(','%28'); - previewURL = previewURL.replace(')','%29'); - ready(previewURL + '&reload=true'); + // get mime icon url + getMimeIcon(mime, function(iconURL) { + ready(iconURL); // set mimeicon URL + + // now try getting a preview thumbnail URL + if ( ! width ) { + width = $('#filestable').data('preview-x'); + } + if ( ! height ) { + height = $('#filestable').data('preview-y'); + } + var previewURL = OC.Router.generate('core_ajax_preview', {file: encodeURIComponent(path), x:width, y:height}); + $.get(previewURL, function() { + previewURL = previewURL.replace('(', '%28'); + previewURL = previewURL.replace(')', '%29'); + //set preview thumbnail URL + ready(previewURL + '&reload=true'); + }); }); } |