]> source.dussan.org Git - nextcloud-server.git/commitdiff
only load sidebar previews when we know it's available
authorRobin Appelman <robin@icewind.nl>
Tue, 26 Jul 2016 11:51:18 +0000 (13:51 +0200)
committerRobin Appelman <robin@icewind.nl>
Wed, 27 Jul 2016 10:59:43 +0000 (12:59 +0200)
apps/files/js/filelist.js
apps/files/js/sidebarpreviewmanager.js

index 6ac72d8c169cc49bdec24de45dafa847c5ec201d..f50322953d291463edda022d9c5ab2ea270e1f29 100644 (file)
                                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) {
                                "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) {
index cfd1fffae130fcc2b959ab4fe95447e0e01f510a..3d5401191899a92aadf3da741e80e34c7e5e6b0e 100644 (file)
                },
 
                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