@@ -345,25 +345,39 @@ const isLoading = computed(
345345 () => companiesLoading .value || speakersLoading .value ,
346346);
347347
348- const companyFuzzy = computed (() => {
349- const list = companiesData .value ?.data ?? [];
350- if (! list .length ) return null ;
351-
352- return createFuzzySearch (list , {
353- // match on multiple fields
354- getText : (company : Company ) => [company .name , company .description ?? " " ],
355- });
356- });
357-
358- const speakerFuzzy = computed (() => {
359- const list = speakersData .value ?.data ?? [];
360- if (! list .length ) return null ;
348+ // Memoized fuzzy search instances
349+ import { ref , watch } from " vue" ;
361350
362- return createFuzzySearch (list , {
363- getText : (speaker : Speaker ) => [speaker .name , speaker .companyName ?? " " ],
364- });
365- });
351+ const companyFuzzy = ref (null );
352+ watch (
353+ () => companiesData .value ?.data ,
354+ (list ) => {
355+ if (! list || ! list .length ) {
356+ companyFuzzy .value = null ;
357+ } else {
358+ companyFuzzy .value = createFuzzySearch (list , {
359+ // match on multiple fields
360+ getText : (company : Company ) => [company .name , company .description ?? " " ],
361+ });
362+ }
363+ },
364+ { immediate: true }
365+ );
366366
367+ const speakerFuzzy = ref (null );
368+ watch (
369+ () => speakersData .value ?.data ,
370+ (list ) => {
371+ if (! list || ! list .length ) {
372+ speakerFuzzy .value = null ;
373+ } else {
374+ speakerFuzzy .value = createFuzzySearch (list , {
375+ getText : (speaker : Speaker ) => [speaker .name , speaker .companyName ?? " " ],
376+ });
377+ }
378+ },
379+ { immediate: true }
380+ );
367381const filteredCompanies = computed (() => {
368382 const list = companiesData .value ?.data ?? [];
369383 const term = searchTerm .value .trim ();
0 commit comments