]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make share results distinguishable if there are more than one with the exact same...
authorJulius Härtl <jus@bitgrid.net>
Wed, 23 Sep 2020 10:39:53 +0000 (12:39 +0200)
committerJulius Härtl <jus@bitgrid.net>
Mon, 14 Dec 2020 10:14:58 +0000 (11:14 +0100)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
apps/files_sharing/src/components/SharingInput.vue

index c8373c6c0aee3bd3936975061f5b538f638f0d87..6d7eb8220a1bbdee9363d41868b683ffd045546f 100644 (file)
@@ -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)