New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added feature to indicate the user if the content JSON is exploitable… #366
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import { | |
AiOutlineLock, | ||
AiOutlineUnlock, | ||
} from "react-icons/ai"; | ||
import { AiOutlineSafetyCertificate } from "react-icons/ai"; | ||
import { MdOutlineCheckCircleOutline } from "react-icons/md"; | ||
import { TbTransform } from "react-icons/tb"; | ||
import { | ||
|
@@ -114,11 +115,16 @@ export const BottomBar = () => { | |
const getFormat = useFile(state => state.getFormat); | ||
const [isPrivate, setIsPrivate] = React.useState(false); | ||
const [isUpdating, setIsUpdating] = React.useState(false); | ||
const contents = useFile(state => state.contents); | ||
|
||
React.useEffect(() => { | ||
setIsPrivate(data?.private ?? true); | ||
}, [data]); | ||
|
||
const isNotExploitableJson = (contentString: string): boolean => { | ||
return contentString[0] !== "[" && contentString[contentString.length - 1] !== "]"; | ||
}; | ||
|
||
const handleSaveJson = React.useCallback(async () => { | ||
if (!user) return setVisible("login")(true); | ||
|
||
|
@@ -273,6 +279,13 @@ export const BottomBar = () => { | |
Transform | ||
</StyledBottomBarItem> | ||
)} | ||
|
||
{isNotExploitableJson(contents) && ( | ||
<StyledBottomBarItem> | ||
<AiOutlineSafetyCertificate /> | ||
JSON is not exploitable | ||
</StyledBottomBarItem> | ||
)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's better to show the warning when it's exploitable instead of not exploitable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also we could use "Exploitable" instead of "JSON is exploitable" so it will consume less space. |
||
</StyledLeft> | ||
|
||
<StyledRight> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each time the contents in updated it will cause a rerender which is a performance concern for us. Instead we could make our calculations with in
useFile(state => ...)
to prevent rerender and only when the value is changed, referred as exploitable.