Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-09-23 13:39:53 +0300
committerJulius Härtl <jus@bitgrid.net>2020-12-14 13:14:58 +0300
commita86746ea08be193ae69c4dcbf8001c9032c1a2c1 (patch)
tree6429ee4abce253e30db63309cdd45d85744ec252 /apps/files_sharing/src/components
parent99a6665888af1ac89af7269c6d40d14aba94b613 (diff)
Make share results distinguishable if there are more than one with the exact same display name
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/files_sharing/src/components')
-rw-r--r--apps/files_sharing/src/components/SharingInput.vue22
1 files changed, 21 insertions, 1 deletions
diff --git a/apps/files_sharing/src/components/SharingInput.vue b/apps/files_sharing/src/components/SharingInput.vue
index c8373c6c0ae..6d7eb8220a1 100644
--- a/apps/files_sharing/src/components/SharingInput.vue
+++ b/apps/files_sharing/src/components/SharingInput.vue
@@ -241,7 +241,27 @@ export default {
// if there is a condition specified, filter it
const externalResults = this.externalResults.filter(result => !result.condition || result.condition(this))
- this.suggestions = exactSuggestions.concat(suggestions).concat(externalResults).concat(lookupEntry)
+ const allSuggestions = exactSuggestions.concat(suggestions).concat(externalResults).concat(lookupEntry)
+
+ // Count occurances of display names in order to provide a distinguishable description if needed
+ const nameCounts = allSuggestions.reduce((nameCounts, result) => {
+ if (!result.displayName) {
+ return nameCounts
+ }
+ if (!nameCounts[result.displayName]) {
+ nameCounts[result.displayName] = 0
+ }
+ nameCounts[result.displayName]++
+ return nameCounts
+ }, {})
+
+ this.suggestions = allSuggestions.map(item => {
+ // Make sure that items with duplicate displayName get the shareWith applied as a description
+ if (nameCounts[item.displayName] > 1 && !item.desc) {
+ return { ...item, desc: item.shareWith }
+ }
+ return item
+ })
this.loading = false
console.info('suggestions', this.suggestions)