Detects if there is a name before showing hash
This commit is contained in:
parent
783eee3799
commit
e4072d5134
2 changed files with 14 additions and 8 deletions
|
|
@ -13,18 +13,23 @@ import {
|
||||||
|
|
||||||
const FingerprintBlock = () => {
|
const FingerprintBlock = () => {
|
||||||
const [name, setName] = useState('');
|
const [name, setName] = useState('');
|
||||||
|
const [load, setLoad] = useState(false);
|
||||||
const [saved, setSaved] = useState('');
|
const [saved, setSaved] = useState('');
|
||||||
const hash = getHash([...getHardware(), ...getWebGL(), ...getSoftware()]);
|
const hash = getHash([...getHardware(), ...getWebGL(), ...getSoftware()]);
|
||||||
getName(hash, setName);
|
getName(hash, setName, setLoad);
|
||||||
return (
|
return (
|
||||||
<ScanBlock>
|
<ScanBlock>
|
||||||
<h1>Fingerprint</h1>
|
<h1>Fingerprint</h1>
|
||||||
{name ? (
|
{load && (
|
||||||
<Table data={getFingerprint(name, hash)} />
|
<>
|
||||||
) : (
|
{name ? (
|
||||||
<div className="boxWrap">
|
<Table data={getFingerprint(name, hash)} />
|
||||||
<div className="hash">{hash}</div>
|
) : (
|
||||||
</div>
|
<div className="boxWrap">
|
||||||
|
<div className="hash">{hash}</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
<p>
|
<p>
|
||||||
<b>Explanation:</b> This is a unique identifier that can be used to
|
<b>Explanation:</b> This is a unique identifier that can be used to
|
||||||
|
|
|
||||||
|
|
@ -322,13 +322,14 @@ const getFingerprint = (name, hash) => {
|
||||||
|
|
||||||
const getHash = (data) => md5(JSON.stringify(data)).toString();
|
const getHash = (data) => md5(JSON.stringify(data)).toString();
|
||||||
|
|
||||||
const getName = (hash, setName) => {
|
const getName = (hash, setName, setLoad) => {
|
||||||
axios
|
axios
|
||||||
.get(`https://api.vytal.io/fingerprint/?hash=${hash}`)
|
.get(`https://api.vytal.io/fingerprint/?hash=${hash}`)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.data.length !== 0) {
|
if (response.data.length !== 0) {
|
||||||
setName(response.data[response.data.length - 1].name);
|
setName(response.data[response.data.length - 1].name);
|
||||||
}
|
}
|
||||||
|
setLoad(true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue