Skip to content

Commit

Permalink
prioritize displaying file types
Browse files Browse the repository at this point in the history
  • Loading branch information
xishang0128 committed Nov 26, 2024
1 parent ceb89d2 commit 2b42f68
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/renderer/src/components/resources/proxy-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ const ProxyProvider: React.FC = () => {
const { data, mutate } = useSWR('mihomoProxyProviders', mihomoProxyProviders)
const providers = useMemo(() => {
if (!data) return []
if (!data.providers) return []
return Object.keys(data.providers)
.map((key) => data.providers[key])
.filter((provider) => {
return 'subscriptionInfo' in provider
return Object.values(data.providers)
.filter(provider => 'subscriptionInfo' in provider)
.sort((a, b) => {
if (a.vehicleType === 'File' && b.vehicleType !== 'File') {
return -1
}
if (a.vehicleType !== 'File' && b.vehicleType === 'File') {
return 1
}
return 0
})
}, [data])
const [updating, setUpdating] = useState(Array(providers.length).fill(false))
Expand Down
11 changes: 9 additions & 2 deletions src/renderer/src/components/resources/rule-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ const RuleProvider: React.FC = () => {
const { data, mutate } = useSWR('mihomoRuleProviders', mihomoRuleProviders)
const providers = useMemo(() => {
if (!data) return []
if (!data.providers) return []
return Object.keys(data.providers).map((key) => data.providers[key])
return Object.values(data.providers).sort((a, b) => {
if (a.vehicleType === 'File' && b.vehicleType !== 'File') {
return -1
}
if (a.vehicleType !== 'File' && b.vehicleType === 'File') {
return 1
}
return 0
})
}, [data])
const [updating, setUpdating] = useState(Array(providers.length).fill(false))

Expand Down

0 comments on commit 2b42f68

Please sign in to comment.