Skip to content

Commit

Permalink
Handle collections in GET_SEARCH_RESULTS
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Nov 26, 2024
1 parent 3b86f8b commit 24005f1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 5 additions & 1 deletion frontend/src/stores/media/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,13 @@ export const useMediaStore = defineStore("media", {
let errorData: FetchingError | undefined

if (page == 1) {
const searchStore = useSearchStore()
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { searchType, ...paramsWithoutSearchType } =
searchStore.searchParamsForEvent
$sendCustomEvent("GET_SEARCH_RESULTS", {
...paramsWithoutSearchType,
mediaType: mediaType,
query: queryParams.q,
resultsCount: mediaCount,
})
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/stores/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const useSearchStore = defineStore("search", {
searchParamsForEvent(): SearchParamsForEvent {
return {
kind: this.strategy === "default" ? "search" : "collection",
query: this.searchTerm,
query: this.strategy === "default" ? this.searchTerm : "null",
searchType: isSearchTypeSupported(this.searchType)
? this.searchType
: ALL_MEDIA,
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/types/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ export type Events = {
* - How often are searches returning fewer than one page of results?
* - How many results do most searches yield?
*/
GET_SEARCH_RESULTS: {
GET_SEARCH_RESULTS: Omit<SearchParamsForEvent, "searchType"> & {
/** the media type being searched */
mediaType: SupportedMediaType
/** The search term */
query: string
/** The number of results found for this search */
resultsCount: number
}
Expand Down

0 comments on commit 24005f1

Please sign in to comment.