fix(plugins/settings.plugins): check default filters & sort instead of filter size to color the button primary

This commit is contained in:
PalmDevs 2026-08-04 23:09:09 +07:00
parent 9fc88f51f6
commit 30499d543d
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA
2 changed files with 16 additions and 2 deletions

View file

@ -83,6 +83,11 @@ function Screen() {
const [sort, setSort] = useState<BrowseSortKey>('name') const [sort, setSort] = useState<BrowseSortKey>('name')
const [reverse, setReverse] = useState(false) const [reverse, setReverse] = useState(false)
const hasFilter = useMemo(
() => excluded.length > 0 || sort !== 'name' || reverse,
[excluded, sort, reverse],
)
const load = useCallback(async () => { const load = useCallback(async () => {
const repos = await listRepos() const repos = await listRepos()
const all: BrowseEntry[] = [] const all: BrowseEntry[] = []
@ -211,7 +216,7 @@ function Screen() {
</View> </View>
<IconButton <IconButton
icon={FiltersHorizontalIcon} icon={FiltersHorizontalIcon}
variant={repos.length > 0 ? 'primary' : 'tertiary'} variant={hasFilter ? 'primary' : 'tertiary'}
onPress={() => onPress={() =>
ActionSheetActionCreators.openLazy( ActionSheetActionCreators.openLazy(
import( import(

View file

@ -220,6 +220,15 @@ function Screen() {
const reverse = route.params?.reverse ?? false const reverse = route.params?.reverse ?? false
const sort = route.params?.sort ?? DefaultSort const sort = route.params?.sort ?? DefaultSort
const hasFilter = useMemo(
() =>
filter.some(f => !DefaultFilters.includes(f)) ||
matchAll !== true ||
reverse !== false ||
sort !== DefaultSort,
[filter, matchAll, reverse, sort],
)
const [allPlugins, setAllPlugins] = useState(snapshotPlugins) const [allPlugins, setAllPlugins] = useState(snapshotPlugins)
useEffect(() => { useEffect(() => {
@ -270,7 +279,7 @@ function Screen() {
</View> </View>
<IconButton <IconButton
icon={FiltersHorizontalIcon} icon={FiltersHorizontalIcon}
variant={filter.length > 0 ? 'primary' : 'tertiary'} variant={hasFilter ? 'primary' : 'tertiary'}
onPress={() => onPress={() =>
ActionSheetActionCreators.openLazy( ActionSheetActionCreators.openLazy(
import('../components/FilterAndSortActionSheet'), import('../components/FilterAndSortActionSheet'),