Skip to content

Commit a748971

Browse files
committed
Remove falling back and use the exposed useNativeInt var
1 parent 0141a32 commit a748971

File tree

2 files changed

+10
-27
lines changed

2 files changed

+10
-27
lines changed

redisinsight/ui/src/components/json-viewer/JSONViewer.tsx

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,20 @@ interface Props {
1212
fallbackToNonBigInt?: boolean
1313
}
1414

15-
const RenderJSONValue = (value: string, expanded: boolean, space: number, useNativeBigInt: boolean) => {
16-
const data = JSONBigInt({ useNativeBigInt }).parse(value)
17-
return (
18-
<div className={cx('jsonViewer', { 'jsonViewer-collapsed': !expanded })} data-testid="value-as-json">
19-
<JsonPretty data={data} space={space} />
20-
</div>
21-
)
22-
}
23-
2415
const JSONViewer = (props: Props) => {
25-
const { value, expanded = false, space = 2, useNativeBigInt = true, fallbackToNonBigInt } = props
16+
const { value, expanded = false, space = 2, useNativeBigInt = true } = props
2617

2718
try {
28-
const jsonValue = RenderJSONValue(value, expanded, space, useNativeBigInt)
19+
const data = JSONBigInt({ useNativeBigInt }).parse(value)
2920
return {
30-
value: jsonValue,
21+
value: (
22+
<div className={cx('jsonViewer', { 'jsonViewer-collapsed': !expanded })} data-testid="value-as-json">
23+
<JsonPretty data={data} space={space} />
24+
</div>
25+
),
3126
isValid: true
3227
}
3328
} catch (e) {
34-
if (fallbackToNonBigInt) {
35-
try {
36-
const jsonValue = RenderJSONValue(value, expanded, space, false)
37-
return {
38-
value: jsonValue,
39-
isValid: true
40-
}
41-
} catch (e) {
42-
// ignore
43-
}
44-
}
45-
4629
return {
4730
value,
4831
isValid: false

redisinsight/ui/src/utils/formatters/valueFormatters.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const bufferToJSON = (
6565
reply: RedisResponseBuffer,
6666
props: FormattingProps
6767
): { value: JSX.Element | string, isValid: boolean } =>
68-
JSONViewer({ value: bufferToUTF8(reply), fallbackToNonBigInt: true, ...props })
68+
JSONViewer({ value: bufferToUTF8(reply), useNativeBigInt: false, ...props })
6969

7070
const formattingBuffer = (
7171
reply: RedisResponseBuffer,
@@ -108,7 +108,7 @@ const formattingBuffer = (
108108
try {
109109
const vector = Array.from(bufferToFloat32Array(reply.data as Uint8Array))
110110
const value = JSONBigInt.stringify(vector)
111-
return JSONViewer({ value, fallbackToNonBigInt: true, ...props })
111+
return JSONViewer({ value, useNativeBigInt: false, ...props })
112112
} catch (e) {
113113
return { value: bufferToUTF8(reply), isValid: false }
114114
}
@@ -117,7 +117,7 @@ const formattingBuffer = (
117117
try {
118118
const vector = Array.from(bufferToFloat64Array(reply.data as Uint8Array))
119119
const value = JSONBigInt.stringify(vector)
120-
return JSONViewer({ value, fallbackToNonBigInt: true, ...props })
120+
return JSONViewer({ value, useNativeBigInt: false, ...props })
121121
} catch (e) {
122122
return { value: bufferToUTF8(reply), isValid: false }
123123
}

0 commit comments

Comments
 (0)