Files
streamyfin/components/filters/ResetFiltersButton.tsx
Gauvain 8a37ec46bf fix(library): reset (X) also clears sort & order, via a shared hook
The mobile ResetFiltersButton and the TV filter header each had their own
active-state and reset logic, and both ignored sort & order — so the reset
chip never appeared for a changed sort and reset never restored it.

Centralise both in useFilterReset(libraryId): the chip now reflects a
non-default sort, and reset restores SortName/Ascending and clears the
per-library persisted sort/order/filter preferences so the reset sticks.
2026-06-24 23:14:55 +02:00

29 lines
742 B
TypeScript

import { Ionicons } from "@expo/vector-icons";
import { TouchableOpacity, type TouchableOpacityProps } from "react-native";
import { useFilterReset } from "@/hooks/useFilterReset";
interface Props extends TouchableOpacityProps {
libraryId: string;
}
export const ResetFiltersButton: React.FC<Props> = ({
libraryId,
...props
}) => {
const { hasActiveFilters, resetAllFilters } = useFilterReset(libraryId);
if (!hasActiveFilters) {
return null;
}
return (
<TouchableOpacity
onPress={resetAllFilters}
className='bg-purple-600 rounded-full w-[30px] h-[30px] flex items-center justify-center mr-1'
{...props}
>
<Ionicons name='close' size={20} color='white' />
</TouchableOpacity>
);
};