From f116461d4b435b28cd62c3c121a33108e8812e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 26 Oct 2018 13:46:24 +0200 Subject: [PATCH] Show one share method per contact for inaccurate results MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- core/js/sharedialogview.js | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index cd7f07011c..c255152e66 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -325,16 +325,30 @@ return (aProperty < bProperty) ? -1 : (aProperty > bProperty) ? 1 : 0; } } + + /** + * Sort share entries by uuid to properly group them + */ var grouped = suggestions.sort(dynamicSort('uuid')); - console.log(grouped); + var previousUuid = null; - groupedLength = grouped.length; + var groupedLength = grouped.length; + var result = []; + /** + * build the result array that only contains all contact entries from + * merged contacts, if the search term matches its contact name + */ for (i = 0; i < groupedLength; i++) { + console.log(grouped[i]); if (typeof grouped[i].uuid !== 'undefined' && grouped[i].uuid === previousUuid) { grouped[i].merged = true; } else { grouped[i].merged = false; } + if (searchTerm === grouped[i].name || grouped[i].merged === false) { + result.push(grouped[i]); + } else { + } previousUuid = grouped[i].uuid; } var moreResultsAvailable = @@ -353,7 +367,7 @@ ) ); - deferred.resolve(grouped, exactMatches, moreResultsAvailable); + deferred.resolve(result, exactMatches, moreResultsAvailable); } else { deferred.reject(result.ocs.meta.message); } @@ -468,6 +482,9 @@ autocompleteRenderItem: function(ul, item) { var icon = 'icon-user'; var text = item.label; + if (typeof item.name !== 'undefined') { + text = item.name; + } if (item.value.shareType === OC.Share.SHARE_TYPE_GROUP) { icon = 'icon-contacts-dark'; } else if (item.value.shareType === OC.Share.SHARE_TYPE_REMOTE) { @@ -496,13 +513,10 @@ return type; } }; - if (typeof item.type !== 'undefined') { + if (typeof item.type !== 'undefined' && item.type !== null) { description = getTranslatedType(item.type); } var insert = $("