Skip to content

Commit

Permalink
fix: add condition (deriv-com#17118)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadtaimoor-deriv authored Oct 16, 2024
1 parent 1fd6468 commit 8ed6de6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion packages/trader/src/Stores/Modules/Trading/trade-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? '',
});
}

Expand Down

0 comments on commit 8ed6de6

Please sign in to comment.