From b9dfc1674cb9f690ebbcd351c397480b1eb38674 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 26 Jul 2016 13:51:18 +0200 Subject: [PATCH] only load sidebar previews when we know it's available --- apps/files/js/filelist.js | 6 ++++-- apps/files/js/sidebarpreviewmanager.js | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 3b55f842a09..24aa718872b 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -852,7 +852,8 @@ type: $el.attr('data-type'), size: parseInt($el.attr('data-size'), 10), etag: $el.attr('data-etag'), - permissions: parseInt($el.attr('data-permissions'), 10) + permissions: parseInt($el.attr('data-permissions'), 10), + hasPreview: $el.attr('data-has-preview') === 'true' }; var icon = $el.attr('data-icon'); if (icon) { @@ -1068,7 +1069,8 @@ "data-mime": mime, "data-mtime": mtime, "data-etag": fileData.etag, - "data-permissions": fileData.permissions || this.getDirectoryPermissions() + "data-permissions": fileData.permissions || this.getDirectoryPermissions(), + "data-has-preview": fileData.hasPreview !== false }); if (dataIcon) { diff --git a/apps/files/js/sidebarpreviewmanager.js b/apps/files/js/sidebarpreviewmanager.js index cfd1fffae13..3d540119189 100644 --- a/apps/files/js/sidebarpreviewmanager.js +++ b/apps/files/js/sidebarpreviewmanager.js @@ -32,9 +32,18 @@ }, loadPreview: function (model, $thumbnailDiv, $thumbnailContainer) { - var handler = this.getPreviewHandler(model.get('mimetype')); - var fallback = this.fallbackPreview.bind(this, model, $thumbnailDiv, $thumbnailContainer); - handler(model, $thumbnailDiv, $thumbnailContainer, fallback); + if (model.get('hasPreview') === false) { + var mimeIcon = OC.MimeType.getIconUrl(model.get('mimetype')); + $thumbnailDiv.removeClass('icon-loading icon-32'); + $thumbnailContainer.removeClass('image'); //fall back to regular view + $thumbnailDiv.css({ + 'background-image': 'url("' + mimeIcon + '")' + }); + } else { + var handler = this.getPreviewHandler(model.get('mimetype')); + var fallback = this.fallbackPreview.bind(this, model, $thumbnailDiv, $thumbnailContainer); + handler(model, $thumbnailDiv, $thumbnailContainer, fallback); + } }, // previews for images and mimetype icons -- 2.39.5