From f6ecde3d5ab06a32d956a33f94e2a6d0b9ed1a24 Mon Sep 17 00:00:00 2001 From: Joe Armani <93854858+JoeArmani@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:42:22 -0500 Subject: [PATCH] updates after 2nd review --- app.js | 15 +++------- index.html | 69 +++++++++++++++++++++++++++++++++++++++++++- js/event.js | 4 +-- js/pages/footer.js | 56 ----------------------------------- js/pages/homePage.js | 38 +++++++++++++++++------- js/shared.js | 16 ---------- 6 files changed, 101 insertions(+), 97 deletions(-) delete mode 100644 js/pages/footer.js diff --git a/app.js b/app.js index e11e6912..52e69562 100644 --- a/app.js +++ b/app.js @@ -10,7 +10,6 @@ import { renderSettingsPage } from "./js/pages/settings.js"; import { renderSupportPage } from "./js/pages/support.js"; import { renderPaymentPage } from "./js/pages/payment.js"; import { renderSamplesPage } from "./js/pages/samples.js"; -import { footerTemplate } from "./js/pages/footer.js"; import { renderVerifiedPage } from "./js/pages/verifiedPage.js"; import { firebaseConfig as devFirebaseConfig } from "./dev/config.js"; import { firebaseConfig as stageFirebaseConfig } from "./stage/config.js"; @@ -30,15 +29,16 @@ if ("serviceWorker" in navigator) { navigator.serviceWorker.ready.then(() => { if (navigator.serviceWorker.controller) { - navigator.serviceWorker.controller.postMessage({ action: "getAppVersion" }); + navigator.serviceWorker.controller.postMessage({ action: "getAppVersion" }); } }); navigator.serviceWorker.addEventListener("message", (event) => { if (event.data.action === "sendAppVersion") { - document.getElementById("appVersion").textContent = event.data.payload; + document.getElementById("appVersion").textContent = event.data.payload; } }); + } let auth = ''; @@ -128,11 +128,6 @@ window.onload = async () => { inactivityTime(); } }); - - const footer = document.getElementById('footer'); - if (footer) { - footer.innerHTML = footerTemplate(); - } } const handleVerifyEmail = (auth, actionCode) => { @@ -417,8 +412,6 @@ export const signOut = async () => { window.DD_RUM.stopSession(); isDataDogUserSessionSet = false; } - - console.log("signing current user out!"); localforage.clear(); await firebase.auth().signOut(); @@ -512,4 +505,4 @@ const updateFirebaseAuthPhoneTrigger = async (phone) => { hideAnimation(); throw error; } -}; \ No newline at end of file +}; diff --git a/index.html b/index.html index b592444b..d1eeb307 100644 --- a/index.html +++ b/index.html @@ -159,7 +159,74 @@ diff --git a/js/event.js b/js/event.js index cdbc1219..7ec3a870 100644 --- a/js/event.js +++ b/js/event.js @@ -769,7 +769,7 @@ export const environmentWarningModal = () => { const devWarningShown = appState.getState()?.isDevWarningShown; if (devWarningShown === true) return; - appState.setState({ isDevWarningShown: false }); + appState.setState({ isDevWarningShown: true }); document.getElementById('connectWarningModalHeader').style.display = 'block'; document.getElementById('connectWarningModalHeader').innerHTML = ` @@ -838,8 +838,6 @@ export const environmentWarningModal = () => { if (signInBtn) { signInBtn.focus(); } - - appState.setState({ isDevWarningShown: true }); }); modalElement.addEventListener('hidden.bs.modal', (event) => { diff --git a/js/pages/footer.js b/js/pages/footer.js deleted file mode 100644 index f90fbdf6..00000000 --- a/js/pages/footer.js +++ /dev/null @@ -1,56 +0,0 @@ -import { urls, translateHTML } from "./../shared.js"; - -export const footerTemplate = () => { - const footerHTML = ` - - `; - - return translateHTML(footerHTML); -}; diff --git a/js/pages/homePage.js b/js/pages/homePage.js index 541fe21a..f77bd49f 100644 --- a/js/pages/homePage.js +++ b/js/pages/homePage.js @@ -1,4 +1,4 @@ -import { getMyData, hasUserData, urls, fragment, checkAccount, debounceClick, validEmailFormat, validPhoneNumberFormat, getCleanSearchString, firebaseSignInRender, signInAnonymously, usGov, translateHTML, translateText, getFirebaseUI, showAnimation, hideAnimation } from "../shared.js"; +import { getMyData, hasUserData, urls, fragment, checkAccount, validEmailFormat, validPhoneNumberFormat, getCleanSearchString, firebaseSignInRender, signInAnonymously, usGov, translateHTML, translateText, getFirebaseUI, showAnimation, hideAnimation } from "../shared.js"; import { signInConfig } from "./signIn.js"; import { environmentWarningModal, downtimeWarning } from "../event.js"; @@ -529,14 +529,31 @@ export function signInSignUpEntryRender() { document.getElementById('signInWrapperDiv').replaceChildren(df); - signInBtn.addEventListener('click', debounceClick(async (e) => { + signInBtn.addEventListener('click', async (e) => { e.preventDefault(); - await signInCheckRender(); - })); - signUpBtn.addEventListener('click', debounceClick(async (e) => { + signInBtn.disabled = true; + + try { + await signInCheckRender(); + } catch (error) { + console.error('Error during sign-in:', error); + } finally { + signInBtn.disabled = false; + } + }); + + signUpBtn.addEventListener('click', async (e) => { e.preventDefault(); - await signUpRender({ signUpType: "phone" }); - })); + signUpBtn.disabled = true; + + try { + await signUpRender({ signUpType: "phone" }); + } catch (error) { + console.error('Error during sign-up:', error); + } finally { + signUpBtn.disabled = false; + } + }); } export function signInCheckRender () { @@ -576,8 +593,9 @@ export function signInCheckRender () { document.getElementById('signInWrapperDiv').replaceChildren(df); - signInBtn.addEventListener('click', debounceClick(async (e) => { + signInBtn.addEventListener('click', async (e) => { e.preventDefault(); + signInBtn.disabled = true; const inputStr = accountInput.value.trim(); const isEmail = !!inputStr.match(validEmailFormat); const isPhone = !!inputStr.match(validPhoneNumberFormat); @@ -626,9 +644,9 @@ export function signInCheckRender () { } finally { hideAnimation(); accountInput.value = ''; + signInBtn.disabled = false; } - - })); + }); signUpAnchor.addEventListener('click', async () => { await signUpRender({ signUpType: "phone" }); diff --git a/js/shared.js b/js/shared.js index 2cdf0be3..b5317201 100644 --- a/js/shared.js +++ b/js/shared.js @@ -2246,19 +2246,3 @@ export const getFirebaseUI = async () => { } } } - -/** - * Set a short timeout to disallow multiple repetitive actions (button clicks). - * @param {Function} func - Function to execute. - * @param {number} delay - Delay in milliseconds. - * @returns - */ -export const debounceClick = (func, delay) => { - let timeoutId; - return function(...args) { - clearTimeout(timeoutId); - timeoutId = setTimeout(() => { - func.apply(this, args); - }, delay); - } -}