<commit_before>import * as React from 'react'
import {StyleSheet} from 'react-native'
import {
	updateRecentSearches,
	updateRecentFilters,
} from '../../../redux/parts/courses'
import {LoadingView} from '@frogpond/notice'
import type {CourseType} from '../../../lib/course-search'
import type {ReduxState} from '../../../redux'
import {useSelector, useDispatch} from 'react-redux'
import {CourseResultsList} from './list'
import {applyFiltersToItem} from '@frogpond/filter'
import {FilterType} from '@frogpond/filter'
import {buildFilters} from './lib/build-filters'
import {RouteProp, useNavigation, useRoute} from '@react-navigation/native'
import {ChangeTextEvent, RootStackParamList} from '../../../navigation/types'
import {NativeStackNavigationOptions} from '@react-navigation/native-stack'
import {white} from '@frogpond/colors'
import {useDebounce} from '@frogpond/use-debounce'

type ReduxStateProps = {
	allCourses: Array<CourseType>
	courseDataState: string
}

type ReduxDispatchProps = {
	updateRecentFilters: (filters: FilterType[]) => any
	updateRecentSearches: (query: string) => any
}

// type DefaultProps = {
// 	applyFilters: (filters: FilterType[], item: CourseType) => boolean
// }

type Props = ReduxStateProps & ReduxDispatchProps //& DefaultProps

const CourseSearchResultsView = (props: Props) => {
	let route = useRoute<RouteProp<RootStackParamList, 'CourseSearchResults'>>()
	let {initialFilters, initialQuery} = route.params

	let [searchbarActive, setSearchbarActive] = React.useState(false)
	let [filters, setFilters] = React.useState<FilterType[]>(initialFilters ?? [])
	let [filtersLoaded, setFiltersLoaded] = React.useState(
		initialFilters ?? false,
	)

	let [searchQuery, setSearchQuery] = React.useState(initialQuery ?? '')
	let delayedQuery = useDebounce(searchQuery, 500)

	let navigation = useNavigation()

	React.useLayoutEffect(() => {
		navigation.setOptions({
			headerSearchBarOptions: {<commit_msg>fix initialization of filters loaded by assigning a boolean and not mixed<commit_after>import * as React from 'react'
import {StyleSheet} from 'react-native'
import {
	updateRecentSearches,
	updateRecentFilters,
} from '../../../redux/parts/courses'
import {LoadingView} from '@frogpond/notice'
import type {CourseType} from '../../../lib/course-search'
import type {ReduxState} from '../../../redux'
import {useSelector, useDispatch} from 'react-redux'
import {CourseResultsList} from './list'
import {applyFiltersToItem} from '@frogpond/filter'
import {FilterType} from '@frogpond/filter'
import {buildFilters} from './lib/build-filters'
import {RouteProp, useNavigation, useRoute} from '@react-navigation/native'
import {ChangeTextEvent, RootStackParamList} from '../../../navigation/types'
import {NativeStackNavigationOptions} from '@react-navigation/native-stack'
import {white} from '@frogpond/colors'
import {useDebounce} from '@frogpond/use-debounce'

type ReduxStateProps = {
	allCourses: Array<CourseType>
	courseDataState: string
}

type ReduxDispatchProps = {
	updateRecentFilters: (filters: FilterType[]) => any
	updateRecentSearches: (query: string) => any
}

// type DefaultProps = {
// 	applyFilters: (filters: FilterType[], item: CourseType) => boolean
// }

type Props = ReduxStateProps & ReduxDispatchProps //& DefaultProps

const CourseSearchResultsView = (props: Props) => {
	let route = useRoute<RouteProp<RootStackParamList, 'CourseSearchResults'>>()
	let {initialFilters, initialQuery} = route.params

	let [searchbarActive, setSearchbarActive] = React.useState(false)
	let [filters, setFilters] = React.useState<FilterType[]>(initialFilters ?? [])
	let [filtersLoaded, setFiltersLoaded] = React.useState(
		Boolean(initialFilters),
	)

	let [searchQuery, setSearchQuery] = React.useState(initialQuery ?? '')
	let delayedQuery = useDebounce(searchQuery, 500)

	let navigation = useNavigation()

	React.useLayoutEffect(() => {
		navigation.setOptions({
			headerSearchBarOptions: {
{'fraction_non_alphanumeric': 0.13721518987341771, 'fraction_numerical': 0.0015189873417721519, 'mean_word_length': 5.719387755102041, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '121590', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1201, 'n_words': 292}