summaryrefslogtreecommitdiffstats
path: root/core/js/sharedialogview.js
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-03-19 16:57:16 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-03-20 19:09:04 +0100
commit89b0e34d9b0d80315839ce022439b58466b3d5db (patch)
tree95a8bdd71d1bf793402d758dca8e284cd745c4b3 /core/js/sharedialogview.js
parent1c440519c2653323dd49fb4ec3a06851d114c4fe (diff)
downloadnextcloud-server-89b0e34d9b0d80315839ce022439b58466b3d5db.tar.gz
nextcloud-server-89b0e34d9b0d80315839ce022439b58466b3d5db.zip
Extract code to filter suggestions to its own function
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'core/js/sharedialogview.js')
-rw-r--r--core/js/sharedialogview.js124
1 files changed, 64 insertions, 60 deletions
diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js
index 7c31239d4a1..bfa63a63bd1 100644
--- a/core/js/sharedialogview.js
+++ b/core/js/sharedialogview.js
@@ -160,83 +160,87 @@
circles = result.ocs.data.exact.circles.concat(result.ocs.data.circles);
}
- var usersLength;
- var groupsLength;
- var remotesLength;
- var emailsLength;
- var circlesLength;
-
- var i, j;
-
- //Filter out the current user
- usersLength = users.length;
- for (i = 0; i < usersLength; i++) {
- if (users[i].value.shareWith === OC.currentUser) {
- users.splice(i, 1);
- break;
- }
- }
+ var filter = function(users, groups, remotes, emails, circles) {
+ var usersLength;
+ var groupsLength;
+ var remotesLength;
+ var emailsLength;
+ var circlesLength;
+
+ var i, j;
- // Filter out the owner of the share
- if (model.hasReshare()) {
+ //Filter out the current user
usersLength = users.length;
- for (i = 0 ; i < usersLength; i++) {
- if (users[i].value.shareWith === model.getReshareOwner()) {
+ for (i = 0; i < usersLength; i++) {
+ if (users[i].value.shareWith === OC.currentUser) {
users.splice(i, 1);
break;
}
}
- }
-
- var shares = model.get('shares');
- var sharesLength = shares.length;
- // Now filter out all sharees that are already shared with
- for (i = 0; i < sharesLength; i++) {
- var share = shares[i];
-
- if (share.share_type === OC.Share.SHARE_TYPE_USER) {
+ // Filter out the owner of the share
+ if (model.hasReshare()) {
usersLength = users.length;
- for (j = 0; j < usersLength; j++) {
- if (users[j].value.shareWith === share.share_with) {
- users.splice(j, 1);
+ for (i = 0 ; i < usersLength; i++) {
+ if (users[i].value.shareWith === model.getReshareOwner()) {
+ users.splice(i, 1);
break;
}
}
- } else if (share.share_type === OC.Share.SHARE_TYPE_GROUP) {
- groupsLength = groups.length;
- for (j = 0; j < groupsLength; j++) {
- if (groups[j].value.shareWith === share.share_with) {
- groups.splice(j, 1);
- break;
+ }
+
+ var shares = model.get('shares');
+ var sharesLength = shares.length;
+
+ // Now filter out all sharees that are already shared with
+ for (i = 0; i < sharesLength; i++) {
+ var share = shares[i];
+
+ if (share.share_type === OC.Share.SHARE_TYPE_USER) {
+ usersLength = users.length;
+ for (j = 0; j < usersLength; j++) {
+ if (users[j].value.shareWith === share.share_with) {
+ users.splice(j, 1);
+ break;
+ }
}
- }
- } else if (share.share_type === OC.Share.SHARE_TYPE_REMOTE) {
- remotesLength = remotes.length;
- for (j = 0; j < remotesLength; j++) {
- if (remotes[j].value.shareWith === share.share_with) {
- remotes.splice(j, 1);
- break;
+ } else if (share.share_type === OC.Share.SHARE_TYPE_GROUP) {
+ groupsLength = groups.length;
+ for (j = 0; j < groupsLength; j++) {
+ if (groups[j].value.shareWith === share.share_with) {
+ groups.splice(j, 1);
+ break;
+ }
}
- }
- } else if (share.share_type === OC.Share.SHARE_TYPE_EMAIL) {
- emailsLength = emails.length;
- for (j = 0; j < emailsLength; j++) {
- if (emails[j].value.shareWith === share.share_with) {
- emails.splice(j, 1);
- break;
+ } else if (share.share_type === OC.Share.SHARE_TYPE_REMOTE) {
+ remotesLength = remotes.length;
+ for (j = 0; j < remotesLength; j++) {
+ if (remotes[j].value.shareWith === share.share_with) {
+ remotes.splice(j, 1);
+ break;
+ }
}
- }
- } else if (share.share_type === OC.Share.SHARE_TYPE_CIRCLE) {
- circlesLength = circles.length;
- for (j = 0; j < circlesLength; j++) {
- if (circles[j].value.shareWith === share.share_with) {
- circles.splice(j, 1);
- break;
+ } else if (share.share_type === OC.Share.SHARE_TYPE_EMAIL) {
+ emailsLength = emails.length;
+ for (j = 0; j < emailsLength; j++) {
+ if (emails[j].value.shareWith === share.share_with) {
+ emails.splice(j, 1);
+ break;
+ }
+ }
+ } else if (share.share_type === OC.Share.SHARE_TYPE_CIRCLE) {
+ circlesLength = circles.length;
+ for (j = 0; j < circlesLength; j++) {
+ if (circles[j].value.shareWith === share.share_with) {
+ circles.splice(j, 1);
+ break;
+ }
}
}
}
- }
+ };
+
+ filter(users, groups, remotes, emails, circles);
var suggestions = users.concat(groups).concat(remotes).concat(emails).concat(circles).concat(lookup);