From 7a09e7cdee8d5a41e7811e517c872c4b763954e7 Mon Sep 17 00:00:00 2001 From: harshithpabbati Date: Tue, 16 Nov 2021 15:16:54 +0530 Subject: [PATCH] Store and get name of the participant from localstorage --- custom/shared/components/HairCheck/HairCheck.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/custom/shared/components/HairCheck/HairCheck.js b/custom/shared/components/HairCheck/HairCheck.js index d7456cb..0b1fa0f 100644 --- a/custom/shared/components/HairCheck/HairCheck.js +++ b/custom/shared/components/HairCheck/HairCheck.js @@ -38,7 +38,9 @@ export const HairCheck = () => { const [waiting, setWaiting] = useState(false); const [joining, setJoining] = useState(false); const [denied, setDenied] = useState(); - const [userName, setUserName] = useState(''); + const [userName, setUserName] = useState( + localStorage.getItem('PLUOT_PARTICIPANT_NAME') || '' + ); // Initialise devices (even though we're not yet in a call) useEffect(() => { @@ -72,6 +74,7 @@ export const HairCheck = () => { if (granted) { // Note: we don't have to do any thing here as the call state will mutate console.log('👋 Access granted'); + localStorage.setItem('PLUOT_PARTICIPANT_NAME', userName); } else { console.log('❌ Access denied'); setDenied(true); @@ -187,6 +190,7 @@ export const HairCheck = () => { placeholder="Enter display name" variant="dark" disabled={joining} + value={userName} onChange={(e) => setUserName(e.target.value)} />