diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-08-04 10:00:27 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-08-04 21:36:22 +0200 |
commit | 71b62c4203a25beefeab73f73668919c813e3a50 (patch) | |
tree | e75b6b0338ed800ddf88bfe27ce6703045c18e48 /core/src/services | |
parent | 6eced42b7a40f5b0ea0489244583219d0ee2e7af (diff) | |
download | nextcloud-server-71b62c4203a25beefeab73f73668919c813e3a50.tar.gz nextcloud-server-71b62c4203a25beefeab73f73668919c813e3a50.zip |
Show mime icon, bump bundles, make the SearchResultEntry class non-abstract, Fix header search icon, various fixes
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'core/src/services')
-rw-r--r-- | core/src/services/UnifiedSearchService.js | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/core/src/services/UnifiedSearchService.js b/core/src/services/UnifiedSearchService.js index 2e63f19767d..ff9a4aebe2a 100644 --- a/core/src/services/UnifiedSearchService.js +++ b/core/src/services/UnifiedSearchService.js @@ -24,15 +24,18 @@ import { loadState } from '@nextcloud/initial-state' import axios from '@nextcloud/axios' export const defaultLimit = loadState('unified-search', 'limit-default') +export const activeApp = loadState('core', 'active-app') /** * Get the list of available search providers + * + * @returns {Array} */ export async function getTypes() { try { const { data } = await axios.get(generateUrl('/search/providers')) if (Array.isArray(data) && data.length > 0) { - return data + return sortProviders(data) } } catch (error) { console.error(error) @@ -41,6 +44,29 @@ 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 |