fix(plugins/settings.plugins): check default filters & sort instead of filter size to color the button primary
This commit is contained in:
parent
9fc88f51f6
commit
30499d543d
2 changed files with 16 additions and 2 deletions
|
|
@ -83,6 +83,11 @@ function Screen() {
|
|||
const [sort, setSort] = useState<BrowseSortKey>('name')
|
||||
const [reverse, setReverse] = useState(false)
|
||||
|
||||
const hasFilter = useMemo(
|
||||
() => excluded.length > 0 || sort !== 'name' || reverse,
|
||||
[excluded, sort, reverse],
|
||||
)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
const repos = await listRepos()
|
||||
const all: BrowseEntry[] = []
|
||||
|
|
@ -211,7 +216,7 @@ function Screen() {
|
|||
</View>
|
||||
<IconButton
|
||||
icon={FiltersHorizontalIcon}
|
||||
variant={repos.length > 0 ? 'primary' : 'tertiary'}
|
||||
variant={hasFilter ? 'primary' : 'tertiary'}
|
||||
onPress={() =>
|
||||
ActionSheetActionCreators.openLazy(
|
||||
import(
|
||||
|
|
|
|||
|
|
@ -220,6 +220,15 @@ function Screen() {
|
|||
const reverse = route.params?.reverse ?? false
|
||||
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)
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -270,7 +279,7 @@ function Screen() {
|
|||
</View>
|
||||
<IconButton
|
||||
icon={FiltersHorizontalIcon}
|
||||
variant={filter.length > 0 ? 'primary' : 'tertiary'}
|
||||
variant={hasFilter ? 'primary' : 'tertiary'}
|
||||
onPress={() =>
|
||||
ActionSheetActionCreators.openLazy(
|
||||
import('../components/FilterAndSortActionSheet'),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue