Skip to content

Commit

Permalink
fix: btn disable && var name
Browse files Browse the repository at this point in the history
  • Loading branch information
Zephyruso authored and Zephyruso committed Sep 6, 2023
1 parent aecbfbf commit 6c88062
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
13 changes: 10 additions & 3 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ import { JSX, ParentComponent, Show, splitProps } from 'solid-js'
import { twMerge } from 'tailwind-merge'

export const Button: ParentComponent<
JSX.ButtonHTMLAttributes<HTMLButtonElement> & { loading?: boolean }
JSX.ButtonHTMLAttributes<HTMLButtonElement> & {
loading?: boolean
disabled?: boolean
}
> = (props) => {
const [local, others] = splitProps(props, ['class', 'loading'])
const [local, others] = splitProps(props, ['class', 'loading', 'disabled'])

return (
<button
class={twMerge('btn', local.loading ? 'btn-disabled' : local.class)}
class={twMerge(
'btn',
local.disabled && 'btn-disabled',
local.loading ? 'btn-disabled' : local.class,
)}
{...others}
>
<Show when={local.loading}>
Expand Down
16 changes: 8 additions & 8 deletions src/pages/Connections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ export default () => {

const [paused, setPaused] = createSignal(false)

const updateConnections =
(data: Connection[]) => (prevConnections: ConnectionWithSpeed[]) => {
const updateConnectionsWithSpeed =
(connections: Connection[]) => (prevConnections: ConnectionWithSpeed[]) => {
const prevMap = new Map<string, Connection>()
prevConnections.forEach((prev) => prevMap.set(prev.id, prev))

const connections = data.map((connection) => {
const connectionWithSpeed = connections.map((connection) => {
const prevConn = prevMap.get(connection.id)

if (!prevConn) {
Expand All @@ -96,25 +96,25 @@ export default () => {

const closedConnections = differenceWith(
prevConnections,
connections,
connectionWithSpeed,
(a, b) => a.id === b.id,
)

setClosedConnectionsWithSpeed((prev) =>
[...prev, ...closedConnections].slice(-1000),
)

return connections.slice(-200)
return connectionWithSpeed.slice(-200)
}

createEffect(() => {
const data = connections()?.connections
const connection = connections()?.connections

if (!data) {
if (!connection) {
return
}

const updater = updateConnections(data)
const updater = updateConnectionsWithSpeed(connection)

setActiveConnectionsWithSpeed(updater)
})
Expand Down
6 changes: 5 additions & 1 deletion src/pages/Proxies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default () => {
return (
<div class="flex flex-col gap-2">
<div class="flex items-center justify-between gap-2">
<div class="tabs-boxed tabs gap-2">
<div class="tabs tabs-boxed gap-2">
<For each={tabs()}>
{(tab) => (
<button
Expand All @@ -117,6 +117,7 @@ export default () => {

<Button
class="btn btn-circle"
disabled={isAllProviderUpdating()}
onClick={(e) => onUpdateAllProviderClick(e)}
>
<IconReload
Expand Down Expand Up @@ -148,6 +149,7 @@ export default () => {
<div>
<Button
class="btn btn-circle btn-sm mr-2"
disabled={updatingMap()[proxyProvider.name]}
onClick={(e) =>
onUpdateProviderClick(e, proxyProvider.name)
}
Expand All @@ -162,6 +164,7 @@ export default () => {

<Button
class="btn btn-circle btn-sm"
disabled={healthCheckingMap()[proxyProvider.name]}
onClick={(e) => onHealthCheckClick(e, proxyProvider.name)}
>
<IconBrandSpeedtest
Expand Down Expand Up @@ -223,6 +226,7 @@ export default () => {
<span>{proxy.name}</span>
<Button
class="btn-circle btn-sm"
disabled={latencyTestingMap()[proxy.name]}
onClick={(e) => onLatencyTestClick(e, proxy.name)}
>
<IconBrandSpeedtest
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Rules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default () => {
{t('ruleProviders')}
<Button
class="btn-circle btn-ghost btn-sm ml-2"
disabled={allProviderIsUpdating()}
onClick={(e) => onUpdateAllProviderClick(e)}
>
<IconReload
Expand All @@ -98,6 +99,7 @@ export default () => {
</div>
<Button
class="btn-circle btn-sm absolute right-2 top-2 mr-2 h-4"
disabled={updatingMap()[rulesProvider.name]}
onClick={(e) => onUpdateProviderClick(e, rulesProvider.name)}
>
<IconReload
Expand Down

0 comments on commit 6c88062

Please sign in to comment.