Skip to content

Commit

Permalink
feat: infinite scroll for proxy card
Browse files Browse the repository at this point in the history
  • Loading branch information
Zephyruso authored and Zephyruso committed Sep 1, 2023
1 parent 540c398 commit 2584223
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
20 changes: 20 additions & 0 deletions src/components/ProxyCardGroups.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import InfiniteScroll from 'solid-infinite-scroll'
import { createMemo, createSignal } from 'solid-js'
import ProxyNodeCard from './ProxyNodeCard'

export default (props: { proxies: string[]; now?: string }) => {
const [maxRender, setMaxRender] = createSignal(30)
const proxies = createMemo(() => props.proxies.slice(0, maxRender()))

return (
<InfiniteScroll
each={proxies()}
hasMore={proxies().length < props.proxies.length}
next={() => setMaxRender(maxRender() + 30)}
>
{(proxy) => (
<ProxyNodeCard proxyName={proxy} isSelected={props.now === proxy} />
)}
</InfiniteScroll>
)
}
18 changes: 5 additions & 13 deletions src/pages/Proxies.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IconBrandSpeedtest, IconReload } from '@tabler/icons-solidjs'
import { For, Show, createSignal, onMount } from 'solid-js'
import Collapse from '~/components/Collpase'
import ProxyNodeCard from '~/components/ProxyNodeCard'
import ProxyCardGroups from '~/components/ProxyCardGroups'
import ProxyNodeDots from '~/components/ProxyNodeDots'
import SubscriptionInfo from '~/components/SubscriptionInfo'
import { useProxies } from '~/signals/proxies'
Expand Down Expand Up @@ -90,15 +90,7 @@ export default () => {
)

const content = (
<For each={proxy.all}>
{(proxyName) => (
<ProxyNodeCard
proxyName={proxyName}
isSelected={proxy.now === proxyName}
onClick={() => onProxyNodeClick(proxy, proxyName)}
/>
)}
</For>
<ProxyCardGroups proxies={proxy.all!} now={proxy.now} />
)

return (
Expand Down Expand Up @@ -169,9 +161,9 @@ export default () => {
</>
)
const content = (
<For each={proxyProvider.proxies}>
{(proxy) => <ProxyNodeCard proxyName={proxy.name} />}
</For>
<ProxyCardGroups
proxies={proxyProvider.proxies.map((i) => i.name)}
/>
)

return (
Expand Down

0 comments on commit 2584223

Please sign in to comment.