Skip to content

Commit

Permalink
Make object type filter in search work with new search backend
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMStraub committed Jul 26, 2024
1 parent 07cfcd5 commit 2e591ea
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/views/GrampsjsViewSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ export class GrampsjsViewSearch extends GrampsjsView {
this._totalCount = -1
return
}
query = this._filterQueryByObjectType(query)
if (window._oldSearchBackend) {
query = this._filterQueryByObjectType(query)
}
}
this.loading = true
this._fetchData(query, page)
Expand Down Expand Up @@ -272,11 +274,16 @@ export class GrampsjsViewSearch extends GrampsjsView {
}

async _fetchData(query, page) {
const data = await apiGet(
`/api/search/?query=${query}&locale=${
this.strings?.__lang__ || 'en'
}&profile=all&page=${page}&pagesize=20`
)
let url = `/api/search/?query=${query}&locale=${
this.strings?.__lang__ || 'en'
}&profile=all&page=${page}&pagesize=20`
if (!window._oldSearchBackend) {
const objectTypes = Object.keys(this._objectTypes).filter(
key => this._objectTypes[key]
)
url = `${url}&type=${objectTypes.join(',')}`
}
const data = await apiGet(url)
this.loading = false
if ('data' in data) {
this.error = false
Expand Down

0 comments on commit 2e591ea

Please sign in to comment.