mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(frontend): resolve JSON.stringify performance issue
This commit is contained in:
parent
988a56609a
commit
9357a460e2
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import { ChipTypeMap } from "@mui/material";
|
import { ChipTypeMap } from "@mui/material";
|
||||||
import { AutocompleteProps } from "@mui/material/Autocomplete";
|
import { AutocompleteProps } from "@mui/material/Autocomplete";
|
||||||
|
import stringify from "fast-json-stable-stringify";
|
||||||
import { forwardRef, useEffect, useRef } from "react";
|
import { forwardRef, useEffect, useRef } from "react";
|
||||||
|
|
||||||
import { useInfiniteFind } from "@/hooks/crud/useInfiniteFind";
|
import { useInfiniteFind } from "@/hooks/crud/useInfiniteFind";
|
||||||
@ -102,7 +103,7 @@ const AutoCompleteEntitySelect = <
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchNextPage({ pageParam: params });
|
fetchNextPage({ pageParam: params });
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [JSON.stringify(searchPayload)]);
|
}, [stringify(searchPayload)]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AutoCompleteSelect<Value, Label, Multiple>
|
<AutoCompleteSelect<Value, Label, Multiple>
|
||||||
|
@ -22,6 +22,7 @@ import {
|
|||||||
RadioGroup,
|
RadioGroup,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
import stringify from "fast-json-stable-stringify";
|
||||||
import { FC, useCallback, useEffect, useMemo, useState } from "react";
|
import { FC, useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { Controller, useFieldArray, useForm } from "react-hook-form";
|
import { Controller, useFieldArray, useForm } from "react-hook-form";
|
||||||
import { useQuery } from "react-query";
|
import { useQuery } from "react-query";
|
||||||
@ -82,7 +83,7 @@ const NlpDatasetSample: FC<NlpDatasetSampleProps> = ({
|
|||||||
) as INlpDatasetKeywordEntity[],
|
) as INlpDatasetKeywordEntity[],
|
||||||
}),
|
}),
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
[allKeywordEntities, allTraitEntities, JSON.stringify(sample)],
|
[allKeywordEntities, allTraitEntities, stringify(sample)],
|
||||||
);
|
);
|
||||||
const { handleSubmit, control, register, reset, setValue, watch } =
|
const { handleSubmit, control, register, reset, setValue, watch } =
|
||||||
useForm<INlpSampleFormAttributes>({
|
useForm<INlpSampleFormAttributes>({
|
||||||
@ -167,7 +168,7 @@ const NlpDatasetSample: FC<NlpDatasetSampleProps> = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
reset(defaultValues);
|
reset(defaultValues);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [JSON.stringify(defaultValues)]);
|
}, [stringify(defaultValues)]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className="nlp-train" sx={{ position: "relative", p: 2 }}>
|
<Box className="nlp-train" sx={{ position: "relative", p: 2 }}>
|
||||||
@ -322,9 +323,7 @@ const NlpDatasetSample: FC<NlpDatasetSampleProps> = ({
|
|||||||
</ContentItem>
|
</ContentItem>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
{
|
{/* Keyword entities */}
|
||||||
/* Keyword entities */
|
|
||||||
}
|
|
||||||
<Box display="flex" flexDirection="column">
|
<Box display="flex" flexDirection="column">
|
||||||
{keywordEntities.map((keywordEntity, index) => (
|
{keywordEntities.map((keywordEntity, index) => (
|
||||||
<ContentItem
|
<ContentItem
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Grid, IconButton, Paper, Typography, styled } from "@mui/material";
|
import { Grid, IconButton, Paper, Typography, styled } from "@mui/material";
|
||||||
|
import stringify from "fast-json-stable-stringify";
|
||||||
import { FC, SVGProps } from "react";
|
import { FC, SVGProps } from "react";
|
||||||
|
|
||||||
import AttachmentIcon from "@/app-components/svg/toolbar/AttachmentIcon";
|
import AttachmentIcon from "@/app-components/svg/toolbar/AttachmentIcon";
|
||||||
@ -88,7 +89,7 @@ export const Block = ({
|
|||||||
onDragStart={(event) => {
|
onDragStart={(event) => {
|
||||||
event.dataTransfer.setData(
|
event.dataTransfer.setData(
|
||||||
"storm-diagram-node",
|
"storm-diagram-node",
|
||||||
JSON.stringify({
|
stringify({
|
||||||
...blockTemplate,
|
...blockTemplate,
|
||||||
name,
|
name,
|
||||||
}),
|
}),
|
||||||
|
@ -29,6 +29,7 @@ import {
|
|||||||
DiagramModel,
|
DiagramModel,
|
||||||
DiagramModelGenerics,
|
DiagramModelGenerics,
|
||||||
} from "@projectstorm/react-diagrams";
|
} from "@projectstorm/react-diagrams";
|
||||||
|
import stringify from "fast-json-stable-stringify";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { SyntheticEvent, useCallback, useEffect, useState } from "react";
|
import { SyntheticEvent, useCallback, useEffect, useState } from "react";
|
||||||
import { useQueryClient } from "react-query";
|
import { useQueryClient } from "react-query";
|
||||||
@ -340,7 +341,7 @@ const Diagrams = () => {
|
|||||||
});
|
});
|
||||||
}, [
|
}, [
|
||||||
selectedCategoryId,
|
selectedCategoryId,
|
||||||
JSON.stringify(
|
stringify(
|
||||||
blocks.map((b) => {
|
blocks.map((b) => {
|
||||||
return { ...b, position: undefined, updatedAt: undefined };
|
return { ...b, position: undefined, updatedAt: undefined };
|
||||||
}),
|
}),
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import stringify from "fast-json-stable-stringify";
|
||||||
import { useQuery, UseQueryOptions } from "react-query";
|
import { useQuery, UseQueryOptions } from "react-query";
|
||||||
|
|
||||||
import { EntityType, QueryType } from "@/services/types";
|
import { EntityType, QueryType } from "@/services/types";
|
||||||
@ -31,6 +32,6 @@ export const useCount = <TEntity extends IDynamicProps["entity"]>(
|
|||||||
return useQuery({
|
return useQuery({
|
||||||
...options,
|
...options,
|
||||||
queryFn: () => api.count({ where: params }),
|
queryFn: () => api.count({ where: params }),
|
||||||
queryKey: [QueryType.count, entity, JSON.stringify(params)],
|
queryKey: [QueryType.count, entity, stringify(params)],
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import stringify from "fast-json-stable-stringify";
|
||||||
import { io, ManagerOptions, Socket, SocketOptions } from "socket.io-client";
|
import { io, ManagerOptions, Socket, SocketOptions } from "socket.io-client";
|
||||||
|
|
||||||
import { IOIncomingMessage, IOOutgoingMessage } from "./types/io-message";
|
import { IOIncomingMessage, IOOutgoingMessage } from "./types/io-message";
|
||||||
@ -133,7 +134,7 @@ export class SocketIoClient {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Request failed with status code ${response.statusCode}: ${JSON.stringify(
|
`Request failed with status code ${response.statusCode}: ${stringify(
|
||||||
response.body,
|
response.body,
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user