Skip to content

Commit

Permalink
fix(UnifiedSearch): request data only when opening modal
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Jan 17, 2025
1 parent 6afe125 commit e8171b3
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions core/src/components/UnifiedSearch/UnifiedSearchModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export default defineComponent({
contacts: [],
showDateRangeModal: false,
internalIsVisible: this.open,
initialized: false,
}
},

Expand Down Expand Up @@ -308,6 +309,18 @@ export default defineComponent({
// Load results when opened with already filled query
if (this.open) {
this.focusInput()
if (!this.initialized) {
Promise.all([getProviders(), getContacts({searchTerm: ''})])

Check failure on line 313 in core/src/components/UnifiedSearch/UnifiedSearchModal.vue

View workflow job for this annotation

GitHub Actions / NPM lint

A space is required after '{'

Check failure on line 313 in core/src/components/UnifiedSearch/UnifiedSearchModal.vue

View workflow job for this annotation

GitHub Actions / NPM lint

A space is required before '}'
.then(([providers, contacts]) => {
this.providers = this.groupProvidersByApp([...providers, ...this.externalFilters])
this.contacts = this.mapContacts(contacts)
unifiedSearchLogger.debug('Search providers and Contacts initialized:', {providers: this.providers, contacts: this.contacts})

Check failure on line 317 in core/src/components/UnifiedSearch/UnifiedSearchModal.vue

View workflow job for this annotation

GitHub Actions / NPM lint

A space is required after '{'

Check failure on line 317 in core/src/components/UnifiedSearch/UnifiedSearchModal.vue

View workflow job for this annotation

GitHub Actions / NPM lint

A space is required before '}'
this.initialized = true
})
.catch(error => {
console.error(error)
})
}
if (this.searchQuery) {
this.find(this.searchQuery)
}
Expand All @@ -324,18 +337,6 @@ export default defineComponent({

mounted() {
subscribe('nextcloud:unified-search:add-filter', this.handlePluginFilter)
getProviders().then((providers) => {
this.providers = providers
this.externalFilters.forEach(filter => {
this.providers.push(filter)
})
this.providers = this.groupProvidersByApp(this.providers)
unifiedSearchLogger.debug('Search providers', { providers: this.providers })
})
getContacts({ searchTerm: '' }).then((contacts) => {
this.contacts = this.mapContacts(contacts)
unifiedSearchLogger.debug('Contacts', { contacts: this.contacts })
})
},
methods: {
/**
Expand Down

0 comments on commit e8171b3

Please sign in to comment.