diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-08-04 18:15:09 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-08-05 11:37:45 +0200 |
commit | d98f7c1bd83fc03fd297ebeac6279ffe17316950 (patch) | |
tree | 4f1f261e1033f441a0deaa30f5aeb56cbbb51c43 /core/src/services | |
parent | 71b62c4203a25beefeab73f73668919c813e3a50 (diff) | |
download | nextcloud-server-d98f7c1bd83fc03fd297ebeac6279ffe17316950.tar.gz nextcloud-server-d98f7c1bd83fc03fd297ebeac6279ffe17316950.zip |
Make apps handle the order logic
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'core/src/services')
-rw-r--r-- | core/src/services/UnifiedSearchService.js | 33 |
1 files changed, 8 insertions, 25 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 |