From 137a3a164b8e66ef7273c7bb1039914c8cc3a30e Mon Sep 17 00:00:00 2001 From: yashim-deriv Date: Thu, 20 Jun 2024 16:19:02 +0800 Subject: [PATCH] chore: why they do this --- .../hooks/use-third-party-flags.tsx | 51 +------------------ 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/themes/gatsby-theme-deriv/src/components/hooks/use-third-party-flags.tsx b/themes/gatsby-theme-deriv/src/components/hooks/use-third-party-flags.tsx index e11d76ea282..ddf55d78fa8 100644 --- a/themes/gatsby-theme-deriv/src/components/hooks/use-third-party-flags.tsx +++ b/themes/gatsby-theme-deriv/src/components/hooks/use-third-party-flags.tsx @@ -1,56 +1,7 @@ -import { useState, useEffect } from 'react' -import { initializeApp } from 'firebase/app' -import { getDatabase, ref, onValue } from 'firebase/database' -// import useRegion from 'components/hooks/use-region' import featuresConfig from '../../../static/appConfig' -const thirdPartyFlagsConfig = { - databaseURL: process.env.GATSBY_DATABASE_URL, -} - const useThirdPartyFlags = (featurePath) => { - const [data, setData] = useState(featuresConfig) - const [feature, setFeature] = useState(null) - - useEffect(() => { - const app = initializeApp(thirdPartyFlagsConfig, 'thirdPartyFlagsConfig') - const db = getDatabase(app) - - // let fetchedData = featuresConfig - const starCountRef = ref(db, 'remote_config/deriv-com') - const flagsData = onValue( - starCountRef, - (snapshot) => { - setData(snapshot.val()) - }, - (error) => { - console.error(error) - }, - ) - return flagsData - }, []) - - useEffect(() => { - const pathParts = featurePath.split('.') - let currentFeature = data - for (const part of pathParts) { - if (currentFeature[part] === undefined) { - return // Feature path does not exist - } - currentFeature = currentFeature[part] - } - if (typeof currentFeature === 'object') { - setFeature(currentFeature) - } else { - if (featurePath === 'maintenance_mode_content') { - setFeature(currentFeature) - } else { - setFeature(Boolean(currentFeature)) - } - } - }, [data, featurePath]) - - return feature + return featurePath ? featuresConfig : featuresConfig } export default useThirdPartyFlags