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 [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(
|
||||||
|
|
|
||||||
|
|
@ -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'),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue