mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
fix(search): prevent pagefind filter hangs
Resolve the Pagefind browser loader in Vite dev and cap filter-only result hydration so broad filters render promptly instead of stalling behind thousands of fragment fetches.
This commit is contained in:
parent
e1da6eb880
commit
a1ae595717
2 changed files with 85 additions and 2 deletions
|
|
@ -366,6 +366,9 @@ export default {
|
|||
...this.filterQueryList
|
||||
].filter( Boolean ).join(' ')
|
||||
},
|
||||
pagefindResultLimit () {
|
||||
return Math.max( this.initialList.length, 25 )
|
||||
},
|
||||
pagefindFilters () {
|
||||
const filters = new SearchFilters()
|
||||
filters.setFromStringArray( this.filterQueryList )
|
||||
|
|
@ -518,10 +521,20 @@ export default {
|
|||
return null
|
||||
}
|
||||
|
||||
const resultData = await Promise.all( ( pagefindQuery.results || [] ).map( async result => {
|
||||
const limitedResults = ( pagefindQuery.results || [] ).slice( 0, this.pagefindResultLimit )
|
||||
const settledResultData = await Promise.allSettled( limitedResults.map( async result => {
|
||||
return await result.data()
|
||||
} ) )
|
||||
|
||||
const resultData = settledResultData.flatMap( settledResult => {
|
||||
if ( settledResult.status === 'fulfilled' ) {
|
||||
return [ settledResult.value ]
|
||||
}
|
||||
|
||||
console.warn('Failed to load Pagefind result data', settledResult.reason)
|
||||
return []
|
||||
} )
|
||||
|
||||
return resultData.map( data => {
|
||||
return mapPagefindDataToListing( data, {
|
||||
highlightTerms: this.inputTerms
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue