Skip to content

Commit eb36b4b

Browse files
authored
Merge pull request #59 from Bit-Quill/parse-response
Fix parsing bug
2 parents a304daa + 850924a commit eb36b4b

3 files changed

Lines changed: 19 additions & 11 deletions

File tree

apps/frontend/src/components/send-command/Response.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,28 @@ const Response = ({ filter, response }: { filter: string, response: JSONObject }
2323
R.tap(() => toast.success("Copied!")),
2424
)(filtered)
2525

26+
if (R.isEmpty(filtered)) return null
27+
2628
return (
27-
R.isNotEmpty(filtered) &&
2829
<>
2930
<CopyToClipboard onClick={onCopy} />
30-
{
31-
filtered.map(({ keyPath, keyPathString }) =>
31+
{filtered.map(({ keyPath, keyPathString }) => {
32+
const hasKey = keyPath.length > 0 && keyPathString.trim() !== ""
33+
34+
return (
3235
<KV key={keyPathString}>
33-
<KeyFilterable
34-
filter={filter}
35-
keyPathString={keyPathString}
36-
/>
36+
{hasKey && (
37+
<KeyFilterable
38+
filter={filter}
39+
keyPathString={keyPathString}
40+
/>
41+
)}
3742
<div className={cn("bg-white dark:bg-black", spacing)}>
3843
{R.path(keyPath as string[], response)}
3944
</div>
40-
</KV>)
41-
}
45+
</KV>
46+
)
47+
})}
4248
</>
4349
)
4450
}

apps/server/src/sendCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { GlideClient, GlideClusterClient } from "@valkey/valkey-glide"
22
import WebSocket from "ws"
33
import { VALKEY } from "../../../common/src/constants"
4-
import { parseInfo } from "./utils"
4+
import { parseResponse } from "./utils"
55

66
export async function sendValkeyRunCommand(
77
client: GlideClient | GlideClusterClient,
@@ -23,7 +23,7 @@ export async function sendValkeyRunCommand(
2323
}),
2424
)
2525
}
26-
response = parseInfo(response)
26+
response = parseResponse(response)
2727
}
2828

2929
ws.send(

apps/server/src/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export const parseInfo = (infoStr: string): Record<string, string> =>
1717
return acc
1818
}, {} as Record<string, string>)
1919

20+
export const parseResponse = R.when(R.includes(":"), parseInfo)
21+
2022
export const parseClusterInfo = (rawInfo: ClusterResponse<string>): ParsedClusterInfo =>
2123
{
2224
// Required to satisfy compiler

0 commit comments

Comments
 (0)