diff options
author | fenn-cs <fenn25.fn@gmail.com> | 2023-12-12 19:46:56 +0100 |
---|---|---|
committer | Eduardo Morales <emoral435@gmail.com> | 2023-12-26 11:19:25 -0600 |
commit | 8b286fbd0ea91601fca68583201f4d9bbec08c17 (patch) | |
tree | f7b3f4ee4a771b3636b00cae52a11d1dd1715805 /core/src | |
parent | 44c689ac1ef307ad01780870d3cc2736701c48b3 (diff) | |
download | nextcloud-server-8b286fbd0ea91601fca68583201f4d9bbec08c17.tar.gz nextcloud-server-8b286fbd0ea91601fca68583201f4d9bbec08c17.zip |
Add authenicated user to person list for search filtering
As expected, a user does not see themselves in their contact list,
however, when using the contact list for filtering search, a user,
might want to limit the search to things that pertain to them.
Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/services/UnifiedSearchService.js | 16 | ||||
-rw-r--r-- | core/src/views/UnifiedSearchModal.vue | 6 |
2 files changed, 19 insertions, 3 deletions
diff --git a/core/src/services/UnifiedSearchService.js b/core/src/services/UnifiedSearchService.js index e477a59eb4c..fddbd6b1e1d 100644 --- a/core/src/services/UnifiedSearchService.js +++ b/core/src/services/UnifiedSearchService.js @@ -22,6 +22,7 @@ import { generateOcsUrl, generateUrl } from '@nextcloud/router' import axios from '@nextcloud/axios' +import { getCurrentUser } from '@nextcloud/auth' /** * Create a cancel token @@ -103,5 +104,20 @@ export async function getContacts({ searchTerm }) { const { data: { contacts } } = await axios.post(generateUrl('/contactsmenu/contacts'), { filter: searchTerm, }) + /* + * Add authenticated user to list of contacts for search filter + * If authtenicated user is searching/filtering, do not add them to the list + */ + if (!searchTerm) { + let authenticatedUser = getCurrentUser() + authenticatedUser = { + id: authenticatedUser.uid, + fullName: 'Me', + emailAddresses: [], + } + contacts.unshift(authenticatedUser) + return contacts + } + return contacts } diff --git a/core/src/views/UnifiedSearchModal.vue b/core/src/views/UnifiedSearchModal.vue index 76a4486d021..8d2d2820495 100644 --- a/core/src/views/UnifiedSearchModal.vue +++ b/core/src/views/UnifiedSearchModal.vue @@ -193,7 +193,7 @@ export default { filteredProviders: [], searching: false, searchQuery: '', - placesFilter: '', + placessearchTerm: '', dateTimeFilter: null, filters: [], results: [], @@ -243,7 +243,7 @@ export default { this.providers = providers console.debug('Search providers', this.providers) }) - getContacts({ filter: '' }).then((contacts) => { + getContacts({ searchTerm: '' }).then((contacts) => { this.contacts = this.mapContacts(contacts) console.debug('Contacts', this.contacts) }) @@ -363,7 +363,7 @@ export default { }) }, filterContacts(query) { - getContacts({ filter: query }).then((contacts) => { + getContacts({ searchTerm: query }).then((contacts) => { this.contacts = this.mapContacts(contacts) console.debug(`Contacts filtered by ${query}`, this.contacts) }) |