Commit a4ba2e3a authored by Max Alekseenko's avatar Max Alekseenko

add isEnabled param for useAppActionData

parent 7f6373db
......@@ -2,8 +2,8 @@ import { useMemo } from 'react';
import useAddressMetadataInfoQuery from 'lib/address/useAddressMetadataInfoQuery';
export default function useAppActionData(address: string | undefined = '') {
const memoizedArray = useMemo(() => address ? [ address ] : [], [ address ]);
export default function useAppActionData(address: string | undefined = '', isEnabled = false) {
const memoizedArray = useMemo(() => (address && isEnabled) ? [ address ] : [], [ address, isEnabled ]);
const { data } = useAddressMetadataInfoQuery(memoizedArray);
const metadata = data?.addresses[address?.toLowerCase()];
const tag = metadata?.tags?.find(({ tagType }) => tagType === 'protocol');
......
......@@ -40,7 +40,7 @@ const TokenDetails = ({ tokenQuery }: Props) => {
queryOptions: { enabled: Boolean(router.query.hash), placeholderData: TOKEN_COUNTERS },
});
const appActionData = useAppActionData(hash);
const appActionData = useAppActionData(hash, isActionButtonExperiment);
const changeUrlAndScroll = useCallback((tab: TokenTabs) => () => {
router.push(
......
......@@ -28,8 +28,8 @@ interface Props {
}
const TokenInstanceDetails = ({ data, token, scrollRef, isLoading }: Props) => {
const appActionData = useAppActionData(token?.address);
const { value: isActionButtonExperiment } = useFeatureValue('action_button_exp', false);
const appActionData = useAppActionData(token?.address, isActionButtonExperiment && !isLoading);
const handleCounterItemClick = React.useCallback(() => {
window.setTimeout(() => {
......
......@@ -29,8 +29,8 @@ const TxSubHeading = ({ hash, hasTag, txQuery }: Props) => {
const hasInterpretationFeature = feature.isEnabled;
const isNovesInterpretation = hasInterpretationFeature && feature.provider === 'noves';
const appActionData = useAppActionData(txQuery.data?.to?.hash);
const { value: isActionButtonExperiment } = useFeatureValue('action_button_exp', false);
const appActionData = useAppActionData(txQuery.data?.to?.hash, isActionButtonExperiment && !txQuery.isPlaceholderData);
const txInterpretationQuery = useApiQuery('tx_interpretation', {
pathParams: { hash },
......@@ -57,7 +57,9 @@ const TxSubHeading = ({ hash, hasTag, txQuery }: Props) => {
const hasViewAllInterpretationsLink =
!txInterpretationQuery.isPlaceholderData && txInterpretationQuery.data?.data.summaries && txInterpretationQuery.data?.data.summaries.length > 1;
const hasAnyInterpretation = (hasNovesInterpretation && novesInterpretationQuery.data) || hasInternalInterpretation;
const hasAnyInterpretation =
(hasNovesInterpretation && novesInterpretationQuery.data && !novesInterpretationQuery.isPlaceholderData) ||
(hasInternalInterpretation && !txInterpretationQuery.isPlaceholderData);
const content = (() => {
if (hasNovesInterpretation && novesInterpretationQuery.data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment