Skip to content

Commit

Permalink
#74 implemented speakers search
Browse files Browse the repository at this point in the history
  • Loading branch information
fcamblor committed Oct 31, 2024
1 parent ed0204c commit bb9df1a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
15 changes: 15 additions & 0 deletions mobile/src/models/VoxxrinSpeaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,18 @@ export const createVoxxrinSpeakerFromFirestore = (conferenceDescriptor: VoxxrinC
})
}
}

export const speakerMatchesSearchTerms = (speaker: VoxxrinLineupSpeaker, searchTerms: string|undefined): boolean => {
if(!searchTerms) {
return true;
}

const speakerSearchableContent = `
${speaker.fullName}
${speaker.companyName || ''}
${speaker.bio}
${speaker.talks.map(talk => `${talk.title} ${talk.format.title} ${talk.track.title}`).join("\n")}
`.toLowerCase()

return searchTerms.split(" ").every(searchTerm => speakerSearchableContent.includes(searchTerm.toLowerCase()));
}
11 changes: 7 additions & 4 deletions mobile/src/state/useEventSpeakers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {collection, CollectionReference, doc, DocumentReference} from "firebase/
import {db} from "@/state/firebase";
import {resolvedEventFirestorePath} from "../../../shared/utilities/event-utils";
import {LineupSpeaker} from "../../../shared/event-lineup.firestore";
import {createVoxxrinSpeakerFromFirestore} from "@/models/VoxxrinSpeaker";
import {createVoxxrinSpeakerFromFirestore, speakerMatchesSearchTerms} from "@/models/VoxxrinSpeaker";
import {match} from "ts-pattern";
import {sortBy} from "@/models/utils";

export function useLineupSpeakers(eventDescriptorRef: Ref<VoxxrinConferenceDescriptor|undefined>) {
export function useLineupSpeakers(eventDescriptorRef: Ref<VoxxrinConferenceDescriptor|undefined>, searchTermsRef: Ref<string|undefined>) {

const firestoreSpeakersRef = deferredVuefireUseCollection([ eventDescriptorRef ],
([eventDescriptor]) => eventLineupSpeakersCollections(eventDescriptor),
Expand All @@ -27,14 +27,17 @@ export function useLineupSpeakers(eventDescriptorRef: Ref<VoxxrinConferenceDescr
return {
speakers: computed(() => {
const firestoreSpeakersLineup = toValue(firestoreSpeakersRef),
eventDescriptor = toValue(eventDescriptorRef);
eventDescriptor = toValue(eventDescriptorRef),
searchTerms = toValue(searchTermsRef);

if(!firestoreSpeakersLineup || !eventDescriptor) {
return undefined;
}

const speakers = sortBy(
[...firestoreSpeakersLineup.values()].map(fSpeaker => createVoxxrinSpeakerFromFirestore(eventDescriptor, fSpeaker)),
[...firestoreSpeakersLineup.values()]
.map(fSpeaker => createVoxxrinSpeakerFromFirestore(eventDescriptor, fSpeaker))
.filter(speaker => speakerMatchesSearchTerms(speaker, searchTerms)),
sp => sp.fullName
);
return speakers;
Expand Down
7 changes: 3 additions & 4 deletions mobile/src/views/event/SpeakersDirectoryPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
const spacedEventIdRef = useCurrentSpaceEventIdRef();
const {conferenceDescriptor: confDescriptor} = useSharedConferenceDescriptor(spacedEventIdRef);
const { triggerTabbedPageNavigate } = useTabbedPageNav();
const { speakers } = useLineupSpeakers(confDescriptor)
const searchTermsRef = ref<string|undefined>(undefined);
const { speakers } = useLineupSpeakers(confDescriptor, searchTermsRef)
const baseUrl = import.meta.env.BASE_URL;
Expand All @@ -57,9 +59,6 @@
{ id: "compact", icon: list, label: LL.value.Compact_list_mode(), preSelected: true },
] as const
const searchTermsRef = ref<string|undefined>(undefined);
// TODO: take searchTermsRef into consideration when looking for speakers/talks
async function openSpeakerDetails(speaker: VoxxrinSimpleSpeaker) {
if(speaker) {
// TODO: Re-enable this once *tabbed* talk details as feedback viewer routing has been fixed
Expand Down

0 comments on commit bb9df1a

Please sign in to comment.