aboutsummaryrefslogtreecommitdiffstats
path: root/core/js/shareitemmodel.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-09-23 12:44:25 +0200
committerVincent Petry <pvince81@owncloud.com>2015-09-23 14:41:13 +0200
commit0db9b28f3fa6bfdc236218c84a507da47cd29e43 (patch)
tree3ba9917f3ba7ffb617ec561ac346a48d918b3439 /core/js/shareitemmodel.js
parentd54d9a573fac498c4aaeea0df832a204cf525b58 (diff)
downloadnextcloud-server-0db9b28f3fa6bfdc236218c84a507da47cd29e43.tar.gz
nextcloud-server-0db9b28f3fa6bfdc236218c84a507da47cd29e43.zip
Fix ShareItemModel.hasUserShares to only check shares of current item
The shares array is based on what the server returns and can contain share info for parent folders. hasUserShares is now fixed to ignore parent folders and only checks for shares on the current item.
Diffstat (limited to 'core/js/shareitemmodel.js')
-rw-r--r--core/js/shareitemmodel.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js
index d883497433f..0c8b5f6f199 100644
--- a/core/js/shareitemmodel.js
+++ b/core/js/shareitemmodel.js
@@ -297,8 +297,7 @@
* @returns {boolean}
*/
hasUserShares: function() {
- var shares = this.get('shares');
- return _.isArray(shares) && shares.length > 0;
+ return this.getSharesWithCurrentItem().length > 0;
},
/**
@@ -408,6 +407,20 @@
},
/**
+ * Returns all share entries that only apply to the current item
+ * (file/folder)
+ *
+ * @return {Array.<OC.Share.Types.ShareInfo>}
+ */
+ getSharesWithCurrentItem: function() {
+ var shares = this.get('shares') || [];
+ var fileId = this.fileInfoModel.get('id');
+ return _.filter(shares, function(share) {
+ return share.item_source === fileId;
+ });
+ },
+
+ /**
* @param shareIndex
* @returns {string}
*/