From e4072d5134bd0182a8879635095f792281a292c8 Mon Sep 17 00:00:00 2001 From: z0ccc Date: Thu, 26 Aug 2021 14:18:05 -0400 Subject: [PATCH] Detects if there is a name before showing hash --- frontend/src/components/FingerprintBlock.js | 19 ++++++++++++------- frontend/src/components/main.js | 3 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/FingerprintBlock.js b/frontend/src/components/FingerprintBlock.js index fe3ab5e..bdb2327 100644 --- a/frontend/src/components/FingerprintBlock.js +++ b/frontend/src/components/FingerprintBlock.js @@ -13,18 +13,23 @@ import { const FingerprintBlock = () => { const [name, setName] = useState(''); + const [load, setLoad] = useState(false); const [saved, setSaved] = useState(''); const hash = getHash([...getHardware(), ...getWebGL(), ...getSoftware()]); - getName(hash, setName); + getName(hash, setName, setLoad); return (

Fingerprint

- {name ? ( - - ) : ( -
-
{hash}
-
+ {load && ( + <> + {name ? ( +
+ ) : ( +
+
{hash}
+
+ )} + )}

Explanation: This is a unique identifier that can be used to diff --git a/frontend/src/components/main.js b/frontend/src/components/main.js index 9505126..abd67cd 100644 --- a/frontend/src/components/main.js +++ b/frontend/src/components/main.js @@ -322,13 +322,14 @@ const getFingerprint = (name, hash) => { const getHash = (data) => md5(JSON.stringify(data)).toString(); -const getName = (hash, setName) => { +const getName = (hash, setName, setLoad) => { axios .get(`https://api.vytal.io/fingerprint/?hash=${hash}`) .then((response) => { if (response.data.length !== 0) { setName(response.data[response.data.length - 1].name); } + setLoad(true); }); };