summaryrefslogtreecommitdiffstats
path: root/core/js/shareitemmodel.js
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-10-29 13:58:14 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-11-01 21:29:40 +0100
commit1bd6d39b39dd527ad095510173e9012afaafd3b0 (patch)
tree9b3cad7e1dc621498cf519c3aadc53247f0582e1 /core/js/shareitemmodel.js
parentfeb9f72e8bd4b5601974ec894d60e1bad3570dde (diff)
downloadnextcloud-server-1bd6d39b39dd527ad095510173e9012afaafd3b0.tar.gz
nextcloud-server-1bd6d39b39dd527ad095510173e9012afaafd3b0.zip
Migrate link shares to array
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'core/js/shareitemmodel.js')
-rw-r--r--core/js/shareitemmodel.js59
1 files changed, 25 insertions, 34 deletions
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js
index 3f92a8591e5..ce7bc56ab8a 100644
--- a/core/js/shareitemmodel.js
+++ b/core/js/shareitemmodel.js
@@ -16,11 +16,9 @@
/**
* @typedef {object} OC.Share.Types.LinkShareInfo
- * @property {bool} isLinkShare
* @property {string} token
* @property {bool} hideDownload
* @property {string|null} password
- * @property {string} link
* @property {number} permissions
* @property {Date} expiration
* @property {number} stime share time
@@ -100,7 +98,7 @@
defaults: {
allowPublicUploadStatus: false,
permissions: 0,
- linkShare: {}
+ linkShares: []
},
/**
@@ -130,8 +128,11 @@
delete attributes.expiration;
}
- if (this.get('linkShare') && this.get('linkShare').isLinkShare) {
- shareId = this.get('linkShare').id;
+ var linkShares = this.get('linkShares');
+ var shareIndex = _.findIndex(linkShares, function(share) {return share.id === attributes.cid})
+
+ if (linkShares.length > 0 && shareIndex !== -1) {
+ shareId = linkShares[shareIndex].id;
// note: update can only update a single value at a time
call = this.updateShare(shareId, attributes, options);
@@ -151,12 +152,6 @@
return call;
},
- removeLinkShare: function() {
- if (this.get('linkShare')) {
- return this.removeShare(this.get('linkShare').id);
- }
- },
-
addShare: function(attributes, options) {
var shareType = attributes.shareType;
attributes = _.extend({}, attributes);
@@ -316,13 +311,13 @@
},
/**
- * Returns whether this item has a link share
+ * Returns whether this item has link shares
*
* @return {bool} true if a link share exists, false otherwise
*/
- hasLinkShare: function() {
- var linkShare = this.get('linkShare');
- if (linkShare && linkShare.isLinkShare) {
+ hasLinkShares: function() {
+ var linkShares = this.get('linkShares');
+ if (linkShares && linkShares.length > 0) {
return true;
}
return false;
@@ -630,12 +625,16 @@
/**
* @returns {int}
*/
- linkSharePermissions: function() {
- if (!this.hasLinkShare()) {
+ linkSharePermissions: function(shareId) {
+ var linkShares = this.get('linkShares');
+ var shareIndex = _.findIndex(linkShares, function(share) {return share.id === shareId})
+
+ if (!this.hasLinkShares()) {
return -1;
- } else {
- return this.get('linkShare').permissions;
+ } else if (linkShares.length > 0 && shareIndex !== -1) {
+ return linkShares[shareIndex].permissions;
}
+ return -1;
},
_getUrl: function(base, params) {
@@ -831,7 +830,7 @@
this._legacyFillCurrentShares(shares);
- var linkShare = { isLinkShare: false };
+ var linkShares = [];
// filter out the share by link
shares = _.reject(shares,
/**
@@ -844,7 +843,7 @@
|| share.item_source === this.get('itemSource'));
if (isShareLink) {
- /*
+ /**
* Ignore reshared link shares for now
* FIXME: Find a way to display properly
*/
@@ -864,20 +863,12 @@
} else {
link += OC.generateUrl('/s/') + share.token;
}
- linkShare = {
- isLinkShare: true,
- id: share.id,
- token: share.token,
+ linkShares.push(_.extend({}, share, {
// hide_download is returned as an int, so force it
// to a boolean
hideDownload: !!share.hide_download,
- password: share.share_with,
- link: link,
- permissions: share.permissions,
- // currently expiration is only effective for link shares.
- expiration: share.expiration,
- stime: share.stime
- };
+ password: share.share_with
+ }));
return share;
}
@@ -888,7 +879,7 @@
return {
reshare: data.reshare,
shares: shares,
- linkShare: linkShare,
+ linkShares: linkShares,
permissions: permissions,
allowPublicUploadStatus: allowPublicUploadStatus,
allowPublicEditingStatus: allowPublicEditingStatus,
@@ -924,7 +915,7 @@
getShareTypes: function() {
var result;
result = _.pluck(this.getSharesWithCurrentItem(), 'share_type');
- if (this.hasLinkShare()) {
+ if (this.hasLinkShares()) {
result.push(OC.Share.SHARE_TYPE_LINK);
}
return _.uniq(result);