From 8ed6de685d46b067122b1a2d2d2ddb468fec35dc Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:15:16 +0800 Subject: [PATCH] fix: add condition (#17118) --- .../shared/src/utils/contract/trade-url-params-config.ts | 5 ++++- packages/trader/src/Stores/Modules/Trading/trade-store.ts | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/shared/src/utils/contract/trade-url-params-config.ts b/packages/shared/src/utils/contract/trade-url-params-config.ts index d7cb1a7ced03..6d6a5ad2f7e6 100644 --- a/packages/shared/src/utils/contract/trade-url-params-config.ts +++ b/packages/shared/src/utils/contract/trade-url-params-config.ts @@ -68,7 +68,10 @@ export const getTradeURLParams = ({ active_symbols = [], contract_types_list = { contract_types_list[key]?.categories || []; return [...acc, ...categories.map(contract => (contract as TTextValueStrings).value)]; }, []); - const isTradeTypeValid = contractList.includes(trade_type ?? ''); + + const isTradeTypeValid = + (contractList.length === 0 && trade_type !== '') || + (contractList.length > 0 && contractList.includes(trade_type ?? '')); if (validInterval) result.granularity = Number(validInterval.value); if (validChartType) result.chartType = chartTypeParam; diff --git a/packages/trader/src/Stores/Modules/Trading/trade-store.ts b/packages/trader/src/Stores/Modules/Trading/trade-store.ts index e6817b8dd61b..eb72929d34c3 100644 --- a/packages/trader/src/Stores/Modules/Trading/trade-store.ts +++ b/packages/trader/src/Stores/Modules/Trading/trade-store.ts @@ -1838,17 +1838,22 @@ export default class TradeStore extends BaseStore { } setChartModeFromURL() { - const { chartType: chartTypeParam, granularity: granularityParam } = getTradeURLParams(); + const { chartType: chartTypeParam, granularity: granularityParam, contractType } = getTradeURLParams(); const { chart_type, granularity, updateChartType, updateGranularity } = this.root_store.contract_trade; + if (!isNaN(Number(granularityParam)) && granularityParam !== granularity) { updateGranularity(Number(granularityParam)); } if (chartTypeParam && chartTypeParam !== chart_type) { updateChartType(chartTypeParam); } + + this.contract_type = contractType ?? ''; + setTradeURLParams({ chartType: chartTypeParam ?? chart_type, granularity: granularityParam ?? Number(granularity), + contractType: contractType ?? '', }); }