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
path: root/core/src
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2020-08-04 19:15:09 +0300
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2020-08-05 12:37:45 +0300
commitd98f7c1bd83fc03fd297ebeac6279ffe17316950 (patch)
tree4f1f261e1033f441a0deaa30f5aeb56cbbb51c43 /core/src
parent71b62c4203a25beefeab73f73668919c813e3a50 (diff)
Make apps handle the order logic
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'core/src')
-rw-r--r--core/src/services/UnifiedSearchService.js33
-rw-r--r--core/src/views/UnifiedSearch.vue13
2 files changed, 9 insertions, 37 deletions
diff --git a/core/src/services/UnifiedSearchService.js b/core/src/services/UnifiedSearchService.js
index ff9a4aebe2a..bc8cca19ce8 100644
--- a/core/src/services/UnifiedSearchService.js
+++ b/core/src/services/UnifiedSearchService.js
@@ -33,9 +33,15 @@ export const activeApp = loadState('core', 'active-app')
*/
export async function getTypes() {
try {
- const { data } = await axios.get(generateUrl('/search/providers'))
+ const { data } = await axios.get(generateUrl('/search/providers'), {
+ params: {
+ // Sending which location we're currently at
+ from: window.location.pathname.replace('/index.php', '') + window.location.search,
+ },
+ })
if (Array.isArray(data) && data.length > 0) {
- return sortProviders(data)
+ // Providers are sorted by the api based on their order key
+ return data
}
} catch (error) {
console.error(error)
@@ -44,29 +50,6 @@ export async function getTypes() {
}
/**
- * Sort the providers by the current active app
- *
- * @param {Array} providers the providers list
- * @returns {Array}
- */
-export function sortProviders(providers) {
- providers.sort((a, b) => {
- if (a.id.startsWith(activeApp) && b.id.startsWith(activeApp)) {
- return a.order - b.order
- }
-
- if (a.id.startsWith(activeApp)) {
- return -1
- }
- if (b.id.startsWith(activeApp)) {
- return 1
- }
- return 0
- })
- return providers
-}
-
-/**
* Get the list of available search providers
*
* @param {string} type the type to search
diff --git a/core/src/views/UnifiedSearch.vue b/core/src/views/UnifiedSearch.vue
index d7ad58ae202..4e32bdbedd1 100644
--- a/core/src/views/UnifiedSearch.vue
+++ b/core/src/views/UnifiedSearch.vue
@@ -169,18 +169,7 @@ export default {
orderedResults() {
const ordered = {}
Object.keys(this.results)
- .sort((a, b) => {
- if (a.startsWith(activeApp) && b.startsWith(activeApp)) {
- return this.typesMap[a].order - this.typesMap[b].order
- }
- if (a.startsWith(activeApp)) {
- return -1
- }
- if (b.startsWith(activeApp)) {
- return 1
- }
- return 0
- })
+ .sort((a, b) => this.typesMap[a].order - this.typesMap[b].order)
.forEach(type => {
ordered[type] = this.results[type]
})