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.
This commit is contained in:
Vincent Petry 2014-07-04 11:10:54 +02:00
parent e4a3f8d3c4
commit 5e8959a5b3
2 changed files with 10 additions and 5 deletions

View File

@ -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,

View 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);