]> source.dussan.org Git - nextcloud-server.git/commitdiff
Return and use isPreviewAvailable for share previews
authorVincent Petry <pvince81@owncloud.com>
Fri, 4 Jul 2014 09:10:54 +0000 (11:10 +0200)
committerVincent Petry <pvince81@owncloud.com>
Fri, 4 Jul 2014 09:16:23 +0000 (11:16 +0200)
Since the mime type is known, now isPreviewAvailable is returned as well
and used by the JS side to properly render mime icon and previews.

apps/files_sharing/js/sharedfilelist.js
apps/files_sharing/lib/api.php

index 304f77a8d772fe5de79c48a717548c6ec508173a..ea9071cfcb8a38722a4ce61a998875eb753d6c4b 100644 (file)
                                        }
                                        else {
                                                file.type = 'file';
-                                               // force preview retrieval as we don't have mime types,
-                                               // the preview endpoint will fall back to the mime type
-                                               // icon if no preview exists
-                                               file.isPreviewAvailable = true;
-                                               file.icon = true;
+                                               if (share.isPreviewAvailable) {
+                                                       file.icon = true;
+                                                       file.isPreviewAvailable = true;
+                                               }
                                        }
                                        file.share = {
                                                id: share.id,
index 2e824a4a9dfa151a3b3e483f62a8ad90c240e1ac..50ba74f5beb5803f72c9b5abc0a9bb772706e7b7 100644 (file)
@@ -60,6 +60,9 @@ class Api {
                        foreach ($shares as &$share) {
                                if ($share['item_type'] === 'file' && isset($share['path'])) {
                                        $share['mimetype'] = \OC_Helper::getFileNameMimeType($share['path']);
+                                       if (\OC::$server->getPreviewManager()->isMimeSupported($share['mimetype'])) {
+                                               $share['isPreviewAvailable'] = true;
+                                       }
                                }
                                $newShares[] = $share;
                        }
@@ -214,6 +217,9 @@ class Api {
                        foreach ($shares as &$share) {
                                if ($share['item_type'] === 'file') {
                                        $share['mimetype'] = \OC_Helper::getFileNameMimeType($share['file_target']);
+                                       if (\OC::$server->getPreviewManager()->isMimeSupported($share['mimetype'])) {
+                                               $share['isPreviewAvailable'] = true;
+                                       }
                                }
                        }
                        $result = new \OC_OCS_Result($shares);