Skip to content

Commit

Permalink
[DTRA] henry/dtra-1645/remove-extra-and-invalid-contractsfor-calls-tr…
Browse files Browse the repository at this point in the history
…ader-v2 (#16506)

* fix: invalid contractsfor calls

* fix: chart needs active symbols to function

* fix: temporary fix to rectify page not loading when values arent cached
  • Loading branch information
henry-deriv committed Aug 26, 2024
1 parent 04994da commit 778a079
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
11 changes: 6 additions & 5 deletions packages/trader/src/AppV2/Hooks/useActiveSymbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
isTurbosContract,
isVanillaContract,
pickDefaultSymbol,
setTradeURLParams,
} from '@deriv/shared';
import { useStore } from '@deriv/stores';
import { localize } from '@deriv/translations';
Expand All @@ -29,6 +30,7 @@ const useActiveSymbols = () => {
onChange,
setActiveSymbolsV2,
symbol,
is_trade_component_mounted,
} = useTraderStore();

const default_symbol_ref = useRef('');
Expand Down Expand Up @@ -63,7 +65,8 @@ const useActiveSymbols = () => {
if (
(isVanillaContract(previous_contract_type) && is_vanilla) ||
(isTurbosContract(previous_contract_type) && is_turbos) ||
getContractTypesList().length === 0
// TODO: remove is_trade_component_mounted from check condition once akmals contracts_for_company changes are merged
(getContractTypesList().length === 0 && !is_trade_component_mounted)
) {
return;
}
Expand All @@ -82,10 +85,8 @@ const useActiveSymbols = () => {
setActiveSymbols(active_symbols);
setActiveSymbolsV2(active_symbols);
default_symbol_ref.current = symbol || (await pickDefaultSymbol(active_symbols)) || '1HZ100V';

if (symbol !== default_symbol_ref.current) {
onChange({ target: { name: 'symbol', value: default_symbol_ref.current } });
}
onChange({ target: { name: 'symbol', value: default_symbol_ref.current } });
setTradeURLParams({ symbol: default_symbol_ref.current, contractType: contract_type });
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
12 changes: 7 additions & 5 deletions packages/trader/src/Stores/Modules/Trading/trade-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,12 +685,15 @@ export default class TradeStore extends BaseStore {
};

async loadActiveSymbols(should_set_default_symbol = true, should_show_loading = true) {
if (this.is_dtrader_v2_enabled) {
await when(() => this.has_symbols_for_v2);
return;
}

this.should_show_active_symbols_loading = should_show_loading;

if (!this.is_dtrader_v2_enabled) {
await this.setActiveSymbols();
await this.root_store.active_symbols.setActiveSymbols();
}
await this.setActiveSymbols();
await this.root_store.active_symbols.setActiveSymbols();

const { symbol, showModal } = getTradeURLParams({ active_symbols: this.active_symbols });
if (showModal && should_show_loading && !this.root_store.client.is_logging_in) {
Expand Down Expand Up @@ -1860,7 +1863,6 @@ export default class TradeStore extends BaseStore {
});
}
if ('active_symbols' in req) {
if (this.is_dtrader_v2_enabled) return;
if (this.root_store.client.is_logged_in) {
return WS.authorized.activeSymbols('brief');
}
Expand Down

0 comments on commit 778a079

Please sign in to comment.