[Pkg-owncloud-commits] [owncloud] 01/70: Return and use isPreviewAvailable for share previews

David Prévot taffit at moszumanska.debian.org
Mon Jul 14 17:38:02 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit ed4ba00b773fb7b82fb21d63411f244edbc371aa
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Fri Jul 4 11:10:54 2014 +0200

    Return and use isPreviewAvailable for share previews
    
    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 | 9 ++++-----
 apps/files_sharing/lib/api.php          | 6 ++++++
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js
index 304f77a..ea9071c 100644
--- a/apps/files_sharing/js/sharedfilelist.js
+++ b/apps/files_sharing/js/sharedfilelist.js
@@ -166,11 +166,10 @@
 					}
 					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,
diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php
index 2e824a4..50ba74f 100644
--- a/apps/files_sharing/lib/api.php
+++ b/apps/files_sharing/lib/api.php
@@ -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);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list